Author Topic: [RESOURCE] Dynamic Attack System  (Read 937 times)

Dynamic Attack System I just wrote and tested.
It lets you set the attack of each weapon dynamic to each client.
You can input an image or you can use the image the client has in his hand.

function gameConnection::setAttack(%this, %attack, %image)
{
   if(!isObject(%this.player))
      return;
   %player = %this.player;
   if(!isObject(%image))
      %mnt = %player.getMountedImage(0);
   else
      %mnt = %image.getName();
   if(!isobject(%mnt))
      return;
   %mnt = %mnt.getName();
   %this.attack[%mnt] = %attack;
}

if(isPackage(attackSystem))
   deactivatepackage(attackSystem);
package attackSystem
{
   function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
   {
      if(%sourceObject.getClassName() $= "Projectile")
         %object = %sourceObject.client.player;
      if(%object.getClassName() $= "Player")
      {
         %mnt = %object.getMountedImage(0);
         %mnt = %mnt.getName();
         if(isObject(%client = %object.client)) // why am I evne doing this
         {
            %ddamage = %client.attack[%mnt];
            if(%damage !$= "")
               %damage = %ddamage;
         }
      }
      %r = parent::damage(%this, %obj, %sourceObject, %position, %damage, %damageType);
      return %r;
   }
};activatepackage(attackSystem);


I'm really unclear what exactly %attack is for, judging by the script, is the damage it does?

I'm really unclear what exactly %attack is for, judging by the script, is the damage it does?
Attack is the damage the weapon does?
read the OP.

Attack is the damage the weapon does?
read the OP.
the OP doesn't clearly describe in English what 'attack' means

i actually had to read over the code a couple times to understand myself :(

Dynamic Attack System I just wrote and tested.
It lets you set the attack of each weapon dynamic to each client.
You can input an image or you can use the image the client has in his hand.


AKA, you can make different clients do different damage with the same weapon.