Game Development Community

Armor Damage

by Thomas Hise · in Torque Game Engine Advanced · 08/26/2006 (3:17 pm) · 3 replies

Ok, so I was trying to get a powerup so once you had it you could cause twice the amount of damage as normal. But I have run into a problem:

I create the Item:
datablock ItemData(DoubleDamage)
{
   // Mission editor category, this datablock will show up in the
   // specified category under the "shapes" root category.
   category = "PowerUps";

   // Basic Item properties
   shapeFile = "~/data/shapes/items/healthKit.dts";
   mass = 1;
   friction = 1;
   elasticity = 0.3;

   // Dynamic properties defined by the scripts
   pickupName = "a double damage powerup";
   damageAmount = 50;
};

Added the maxInv[DoubleDamage] = 1 to the player. Then in Armor::onDamage:
function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
{
   if (%obj.getState() $= "Dead")
      return;
   if (%sourceObject.getInventory("DoubleDamage") $= 1) {
       %damage = %damage*4;
       messageAll('VerboseData','%1 damages %2', %sourceObject.client.name, %obj.client.name);
   }
That did not work, so I did some searching:
Inventory items and damage thread
Still no go.. I've tried %sourceObject.getInventory and %sourceObject.client.getInventory and yet neither work. Any ideas?

About the author

Recent Threads


#1
08/26/2006 (3:43 pm)
Try to echo the sourceObject. Is it NULL?
#2
08/26/2006 (3:51 pm)
Ok, I did an echo and it echo'ed off 1527. So I did a dump for 1527 which returned the player that it should have.. But it did not show a getInventory method listed. But what I did see was that:
Player = "1911"

Which is what is listed in the map editor, not 1527. I'm quessing that this is the problem.. And frankly have the slightest clue on how to fix it. Would it be possible to get the aforementioned player tagged field so I have the right one?
#3
08/26/2006 (6:35 pm)
Ok, update...
It's fixed:
I did what I mentioned above..

%attacker = %sourceClient.Player;
   if (%attacker.getInventory("DoubleDamage") > 0) {
       %damage = %damage*4;
       messageAll('CallBackNULL','%1 damages %2', %sourceObject.client.name, %obj.client.name);
   }

That works now. It les me check whether the attacker has "DoubleDamage" in their inventory.
Thanks for letting type outloud. Also, thanks for the quick reply Stefan..

Tom