Author Topic: How to do more damage with weapons? [Solved]  (Read 636 times)

Okay so i'm using deadzones weapons for an rpg that i'm making, and I cant seem to make the first slash do more than 100 damage.



datablock ProjectileData(BasicSwordShortFastProjectile)
{
   directDamage        = 20; When i make this more than 100 say 150 for example, it will only do 100 damage in game.
   directDamageType  = $DamageType::Duel_Strike;
   radiusDamageType  = $DamageType::Duel_Strike;
   stickExplosion        = BladeSmallMetalExplosion;
   bloodExplosion        = BladeMetalPlayerHitExplosion;
   explosion           = BladeSmallMetalExplosion;

   muzzleVelocity      = 65;
   velInheritFactor    = 1;
   explodeOnPlayerImpact = true;
   explodeOnDeath        = false;  

   armingDelay         = 80;
   lifetime            = 80;
   fadeDelay           = 80;
   isBallistic         = true;
   bounceAngle         = 170; //stick almost all the time
   minStickVelocity    = 10;
   bounceElasticity    = 0.2;
   bounceFriction      = 0.01;  
   gravityMod = 0.0;


   hasLight    = false;
   lightRadius = 3.0;
   lightColor  = "0 0 0.5";
};

Not too much of a coder just to mention that as well. I usually just edit code I can really only do that much

Code:
Code: [Select]
function BasicSwordSSImage::onFireFast(%this, %obj, %slot)
{

%projectile = BasicSwordShortFastProjectile;
%spread = 0.00008;
%shellcount = 1;

%obj.playThread(3, plant);
                serverPlay3D(WooshFastestSound,%obj.getPosition());

for(%shell=0; %shell<%shellcount; %shell++)
{
%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%velocity = MatrixMulVector(%mat, %velocity);

%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
}
return %p;
}

function BasicSwordSSImage::onFireStrong(%this, %obj, %slot)
{

%projectile = BasicSwordShortStrongProjectile;
%spread = 0.00008;
%shellcount = 1;

for(%shell=0; %shell<%shellcount; %shell++)
{
%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%velocity = MatrixMulVector(%mat, %velocity);

%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
}
return %p;
}

function BasicSwordSSImage::onCharged(%this, %obj, %slot)
{
%obj.playThread(2, plant);
        serverPlay3D(DuelChargedSound,%obj.getPosition());

}

function BasicSwordSSImage::onSwing(%this, %obj, %slot)
{
%obj.playThread(2, plant);
        serverPlay3D(WooshFastestSound,%obj.getPosition());

}

function BasicSwordSSImage::onMount(%this, %obj, %slot)
{

%obj.hideNode("LHand");
%obj.hideNode("RHand");
%obj.hideNode("LHook");
%obj.hideNode("RHook");
%obj.playThread(0, armreadyboth);
}

function BasicSwordSSImage::onUnMount(%this, %obj, %slot)
{

%obj.unhideNode("LHand");
%obj.unhideNode("RHand");
%obj.playThread(0, root);
}
« Last Edit: August 02, 2016, 04:02:31 PM by YounqD »

If the player only has 100 health left, and take over 100 damage, damage indicators will only display 100.

If the player only has 100 health left, and take over 100 damage, damage indicators will only display 100.

Well in game I was testing it while I had 1000 health, and when I would take damage from a weapon with (supposedly) 150 damage, I would only lose 100 hp leaving me with 900.

Post the entire bottom half of the code (after the states)

I had a similar issue with vehicles on my server. I cant make vehicles take more than 100 damage per shot. I havent tested with a completely vanilla build so im not entirely sure if this is an engine thing or a torque limitatation

Try hosting a freebuild gamemode and giving the gun a > 100 direct damage and see if it works there, maybe

Post the entire bottom half of the code (after the states)
Added it in the op


Added it in the op
right in this section, add what i wrote:

function BasicSwordSSImage::onFireFast(%this, %obj, %slot)
{
   
   %projectile = BasicSwordShortFastProjectile;
   %spread = 0.00008;
   %shellcount = 1;
   Announce(%projectile.directDamage);

   %obj.playThread(3, plant);
                serverPlay3D(WooshFastestSound,%obj.getPosition());

   for(%shell=0; %shell<%shellcount; %shell++)
   {
      %vector = %obj.getMuzzleVector(%slot);
      %objectVelocity = %obj.getVelocity();
      %vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
      %vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
      %velocity = VectorAdd(%vector1,%vector2);
      %x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
      %y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
      %z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
      %mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
      %velocity = MatrixMulVector(%mat, %velocity);


Save it, go ingame and swing the sword. Tell us what it says in chat

Save it, go ingame and swing the sword. Tell us what it says in chat

It says 150

It says 150

If the player only has 100 health left, and take over 100 damage, damage indicators will only display 100.
^^^ this is your problem here. If you try attacking a player with 150 or above hp it will deal 150 damage

The sword will deal 150 damage but it will appear to be 100 when you attack a 100 health player

^^^ this is your problem here. If you try attacking a player with 150 or above hp it will deal 150 damage

Well that's weird, cuz I used both this mod and this mod to change the health of players and it still only does 100 damage

Well that's weird, cuz I used both this mod and this mod to change the health of players and it still only does 100 damage
look at whatever you're trying to damage (literally look at it with your crosshair)

Type /getid in the chat

Take whatever number the id is, ie id=99999

Go to console, type echo(99999.getHealth());

Post the number you get in the console. (Keep in mind the id wont actually be 99999, this is an example for the sake of testing. In reality, it will say a different number, make sure you replace 99999 with that number)



I tried it twice, once at 10000 hp, and the second time at 1000 hp. And in the console it showed 10000, then 1000

im pretty sure the issue doesnt lie with the code behind the weapon or player max hp.
it most likely is some other code that overrides the damage function or something. or, even worse, possibly an engine limitation.


I got it heres how lol. So I had a different weapon that the charged attack would register as more than 100 so i checked the code to see what might be different and i found something and i changed a few things and i got it to work.

Code: [Select]
function BasicSwordShortFastProjectile::damage(%this,%obj,%col,%fade,%pos,%normal)
{
    if(%this.directDamage <= 0)
        return;

   %damageType = $DamageType::Direct;
    if(%this.DirectDamageType)
      %damageType = %this.DirectDamageType;

   %scale = getWord(%obj.getScale(), 1);
   %directDamage = %this.directDamage * 1;

    if(%col.getType() & $TypeMasks::PlayerObjectType)
   {
      %col.damage(%obj, %pos, %directDamage, %damageType);
    }
   else
   {
      %col.damage(%obj, %pos, %directDamage, %damageType);
    }
}

I'm not to much of a coder but i'm guessing that this makes the weapon mulitple the attack by 1?