Second Stand
by Adam Gardner · in Torque 3D Beginner · 02/02/2013 (2:36 pm) · 4 replies
Is there any way to say put a character in second stand instead of killing the player.
#2
would that be here because I would believe the %delta > 0 is where its checking for 0 hp but not 100% sure.
02/02/2013 (3:08 pm)
function Armor::onDamage(%this, %obj, %delta)
{
// This method is invoked by the ShapeBase code whenever the
// object's damage level changes.
if (%delta > 0 && %obj.getState() !$= "Dead")
{
// Apply a damage flash
%obj.setDamageFlash(1);
// If the pain is excessive, let's hear about it.
%obj.playPain();
}
}would that be here because I would believe the %delta > 0 is where its checking for 0 hp but not 100% sure.
#3
Something along the lines of that should work.
Good luck!
02/02/2013 (3:37 pm)
Oh my mistake, look at Armor::damage. Essentially you want to do this:function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
{
if (!isObject(%obj) || %obj.getState() $= "Dead" || !%damage)
return;
// Deal with client callbacks here because we don't have this
// information in the onDamage or onDisable methods
%client = %obj.client;
%sourceClient = %sourceObject ? %sourceObject.sourceObject.client : 0;
if(%damage+%obj.getDamageLevel() > %obj.getDatablock().maxDamage) {
//force into second stand state
return;
}
%obj.applyDamage(%damage);
%location = "Body";
%obj.damagedBy[%sourceClient] = true;
%obj.damageType[%sourceClient] = %damageType;
if(%sourceObject.getType() & $TypeMasks::PlayerObjectType) {
%obj.lastDamagedBy = %sourceObject;
}
else {
%obj.lastDamagedBy = %sourceObject.sourceObject;
}
// Update the numerical Health HUD
%obj.updateHealth();
if (isObject(%client))
{
// Determine damage direction
if (%damageType !$= "Suicide")
%obj.setDamageDirection(%sourceObject, %position);
if (%obj.getState() $= "Dead")
%client.onDeath(%sourceObject, %sourceClient, %damageType, %location);
}
}Something along the lines of that should work.
Good luck!
#4
02/02/2013 (3:57 pm)
Haha cheers for your help I see where it is now now comes the fun part on creating the last stand with new animations ai coding to not attack the last stand person and giving them something to do on the ground =D
Torque Owner Robert Fritzen
Phantom Games Development
To answer in code:
What you want to do is look at the onDamage portion of player.cs and where you see the code that checks for 0HP, add a function to replace the "death" call to one where you enter your second stance of life.