Damage
by Anthony Ratcliffe · in Torque Game Engine · 10/23/2008 (9:21 pm) · 3 replies
Hey i'm having some problems but i cant find any errors in my script, the error is line 37 after this line
*if (%obj.getState() $ = "Dead") return;* basically the script is if u jump from a height u call a damage function inside onimpact, not greta at coding so i was wondering what i've done wrong
exec("~/data/shapes/orc/player.cs");
datablock PlayerData(PlayerDB){
renderFirstPerson = false;
emap = true;
shapeFile = "~/data/shapes/orc/player.dts";
cameraMaxDist = 4;
maxInv[GunAmmoDB] = 50;
maxInv[GunDB] = 1;
maxDamage = 100;
repairRate = 0.05;
boundingBox = "1.2 1.2 2.3";
boxNormalHeadPercentage = 0.83;
boxNormalTorsoPercentage = 0.49;
boxHeadLeftPercentage = 0;
boxHeadRightPercentage = 1;
boxHeadBackPercentage = 0;
boxHeadFrontPercentage = 1;
};
function PlayerDB::onImpact(%this,%obj,%collidedObject,%vec,%veclen)
{
echo("ON IMPACT CALLBACK");
%obj.applyDamage(%damage);
}
function Player::damage(%obj, %sourceObject, %position, %damage, %damageType){
if (%obj.getState() $ = "Dead") return;
echo("inflict some damage");
%location = %obj.getDamageLocation(%position);
%bodyLocation = firstWorld(%location);
switch$(%BodyLocation){
case "head" : %damage = 100;
case "legs" : %damage = 100;
case "torso" :%damage = 100;
}
echo ("Damage : " @ %damage);
%obj.applyDamage(%damage);
if (%obj.getState() $ = "Dead"){
%client = %obj.client;
%sourceClient = %sourceObject ? %sourceObject.client : 0;
%client.onDeath(%sourceObject %sourceClient, %damageType, %location);
}
}
function PlayerDB::onDisabled(%this,%obj,%state)
{
%obj.playDeathAnimation();
%obj.setImageTrigger(0,false);
}
function Player::playDeathAnimation(%this)
{
if(%this.deathldx++ > 11) %this.deathldx = 1;
%this.setActionThread("Death" @ %this.deathldx);
}
*if (%obj.getState() $ = "Dead") return;* basically the script is if u jump from a height u call a damage function inside onimpact, not greta at coding so i was wondering what i've done wrong
exec("~/data/shapes/orc/player.cs");
datablock PlayerData(PlayerDB){
renderFirstPerson = false;
emap = true;
shapeFile = "~/data/shapes/orc/player.dts";
cameraMaxDist = 4;
maxInv[GunAmmoDB] = 50;
maxInv[GunDB] = 1;
maxDamage = 100;
repairRate = 0.05;
boundingBox = "1.2 1.2 2.3";
boxNormalHeadPercentage = 0.83;
boxNormalTorsoPercentage = 0.49;
boxHeadLeftPercentage = 0;
boxHeadRightPercentage = 1;
boxHeadBackPercentage = 0;
boxHeadFrontPercentage = 1;
};
function PlayerDB::onImpact(%this,%obj,%collidedObject,%vec,%veclen)
{
echo("ON IMPACT CALLBACK");
%obj.applyDamage(%damage);
}
function Player::damage(%obj, %sourceObject, %position, %damage, %damageType){
if (%obj.getState() $ = "Dead") return;
echo("inflict some damage");
%location = %obj.getDamageLocation(%position);
%bodyLocation = firstWorld(%location);
switch$(%BodyLocation){
case "head" : %damage = 100;
case "legs" : %damage = 100;
case "torso" :%damage = 100;
}
echo ("Damage : " @ %damage);
%obj.applyDamage(%damage);
if (%obj.getState() $ = "Dead"){
%client = %obj.client;
%sourceClient = %sourceObject ? %sourceObject.client : 0;
%client.onDeath(%sourceObject %sourceClient, %damageType, %location);
}
}
function PlayerDB::onDisabled(%this,%obj,%state)
{
%obj.playDeathAnimation();
%obj.setImageTrigger(0,false);
}
function Player::playDeathAnimation(%this)
{
if(%this.deathldx++ > 11) %this.deathldx = 1;
%this.setActionThread("Death" @ %this.deathldx);
}
About the author
#2
i also tried this where as when you impact you take 50 away from maxdamage ( so 2 falls kills you).
then i added an if statment that if maxDamage is = 0 play the function above but again this doesnt work
exec("~/data/shapes/orc/player.cs");
datablock PlayerData(PlayerDB){
renderFirstPerson = false;
emap = true;
shapeFile = "~/data/shapes/orc/player.dts";
cameraMaxDist = 4;
maxDamage = 100;
boundingBox = "1.2 1.2 2.3";
boxNormalHeadPercentage = 0.83;
boxNormalTorsoPercentage = 0.49;
boxHeadLeftPercentage = 0;
boxHeadRightPercentage = 1;
boxHeadBackPercentage = 0;
boxHeadFrontPercentage = 1;
};
function PlayerDB::onImpact(%this,%obj,%collidedObject,%vec,%veclen)
{
echo("ON IMPACT CALLBACK");
%this.maxdamage - 50;
if %this.maxdamage = 0
{
%obj.playDeathAnimation();
}
function Player::playDeathAnimation(%this)
{
if(%this.deathldx++ > 11) %this.deathldx = 1;
%this.setActionThread("Death" @ %this.deathldx);
}
i also tried this where as when you impact you take 50 away from maxdamage ( so 2 falls kills you).
then i added an if statment that if maxDamage is = 0 play the function above but again this doesnt work
10/24/2008 (5:25 pm)
Yeah was gonna say lol, the whole idea is when you fall a distance onimapact is called which invokes apply damage which = - 100 from max damage. i cant see where i've gone wrong but i may be way offi also tried this where as when you impact you take 50 away from maxdamage ( so 2 falls kills you).
then i added an if statment that if maxDamage is = 0 play the function above but again this doesnt work
exec("~/data/shapes/orc/player.cs");
datablock PlayerData(PlayerDB){
renderFirstPerson = false;
emap = true;
shapeFile = "~/data/shapes/orc/player.dts";
cameraMaxDist = 4;
maxDamage = 100;
boundingBox = "1.2 1.2 2.3";
boxNormalHeadPercentage = 0.83;
boxNormalTorsoPercentage = 0.49;
boxHeadLeftPercentage = 0;
boxHeadRightPercentage = 1;
boxHeadBackPercentage = 0;
boxHeadFrontPercentage = 1;
};
function PlayerDB::onImpact(%this,%obj,%collidedObject,%vec,%veclen)
{
echo("ON IMPACT CALLBACK");
%this.maxdamage - 50;
if %this.maxdamage = 0
{
%obj.playDeathAnimation();
}
function Player::playDeathAnimation(%this)
{
if(%this.deathldx++ > 11) %this.deathldx = 1;
%this.setActionThread("Death" @ %this.deathldx);
}
i also tried this where as when you impact you take 50 away from maxdamage ( so 2 falls kills you).
then i added an if statment that if maxDamage is = 0 play the function above but again this doesnt work
#3
i also tried this where as when you impact you take 50 away from maxdamage ( so 2 falls kills you).
then i added an if statment that if maxDamage is = 0 play the function above but again this doesnt work
exec("~/data/shapes/orc/player.cs");
datablock PlayerData(PlayerDB){
renderFirstPerson = false;
emap = true;
shapeFile = "~/data/shapes/orc/player.dts";
cameraMaxDist = 4;
maxDamage = 100;
boundingBox = "1.2 1.2 2.3";
boxNormalHeadPercentage = 0.83;
boxNormalTorsoPercentage = 0.49;
boxHeadLeftPercentage = 0;
boxHeadRightPercentage = 1;
boxHeadBackPercentage = 0;
boxHeadFrontPercentage = 1;
};
function PlayerDB::onImpact(%this,%obj,%collidedObject,%vec,%veclen)
{
echo("ON IMPACT CALLBACK");
%this.maxdamage - 50;
if %this.maxdamage = 0
{
%obj.playDeathAnimation();
}
function Player::playDeathAnimation(%this)
{
if(%this.deathldx++ > 11) %this.deathldx = 1;
%this.setActionThread("Death" @ %this.deathldx);
}
i also tried this where as when you impact you take 50 away from maxdamage ( so 2 falls kills you).
then i added an if statment that if maxDamage is = 0 play the function above but again this doesnt work
10/24/2008 (6:27 pm)
Yeah was gonna say lol, the whole idea is when you fall a distance onimapact is called which invokes apply damage which = - 100 from max damage. i cant see where i've gone wrong but i may be way offi also tried this where as when you impact you take 50 away from maxdamage ( so 2 falls kills you).
then i added an if statment that if maxDamage is = 0 play the function above but again this doesnt work
exec("~/data/shapes/orc/player.cs");
datablock PlayerData(PlayerDB){
renderFirstPerson = false;
emap = true;
shapeFile = "~/data/shapes/orc/player.dts";
cameraMaxDist = 4;
maxDamage = 100;
boundingBox = "1.2 1.2 2.3";
boxNormalHeadPercentage = 0.83;
boxNormalTorsoPercentage = 0.49;
boxHeadLeftPercentage = 0;
boxHeadRightPercentage = 1;
boxHeadBackPercentage = 0;
boxHeadFrontPercentage = 1;
};
function PlayerDB::onImpact(%this,%obj,%collidedObject,%vec,%veclen)
{
echo("ON IMPACT CALLBACK");
%this.maxdamage - 50;
if %this.maxdamage = 0
{
%obj.playDeathAnimation();
}
function Player::playDeathAnimation(%this)
{
if(%this.deathldx++ > 11) %this.deathldx = 1;
%this.setActionThread("Death" @ %this.deathldx);
}
i also tried this where as when you impact you take 50 away from maxdamage ( so 2 falls kills you).
then i added an if statment that if maxDamage is = 0 play the function above but again this doesnt work
Associate Scott Burns
GG Alumni
You've got a space between them, it should $=.
edit:
Actually, after messing around in Torsion that appears to be valid syntax.