Game Development Community

This seems to work but looks wrong.

by Dreamer · in Torque Game Engine · 05/01/2005 (12:52 am) · 1 replies

Hello all, I wanted to create a ConsoleMethod to allow the scripts to update a players MaxDamage.
The following appears to work fine, but looks wrong to me, can someone please tell me if I'm just being paranoid, and if not, then how I should go about fixing it.
void ShapeBase::setMaxDamage(int damage){
	mDataBlock->maxDamage = damage;
	updateDamageLevel();
}

ConsoleMethod( ShapeBase, setMaxDamage, void, 3, 3, "(int MaxDamage)")
{
   object->setMaxDamage(dAtoi(argv[2]));
}

Thanks in advance.

#1
05/01/2005 (2:19 am)
Well, it's bad indeed, since you shouldn't be modifying a datablock's value. You should create an object variable to set the max damage and update that instead.