Author Topic: Packaged player kill function  (Read 1151 times)

I need a packaged function for my weapon that simply kills the player. This is as far as I got.
Code: [Select]
package InstantKill
{
function servercmdKill()
{
player.kill();
}
};
activatePackage(InstantKill);
I am not a scripter.

Like forcekill?

I'm not at all sure what you're asking for

Like forcekill?

I'm not at all sure what you're asking for
I think he means when you click a player it kills them.

I need a packaged function for my weapon that simply kills the player. This is as far as I got.
Code: [Select]
package InstantKill
{
function servercmdKill()
{
player.kill();
}
};
activatePackage(InstantKill);
I am not a scripter.
I have absolutely no idea what you're talking about.
The closest thing to executable code that is is a Self Delete command, in which case we already have "/Self Delete".

I'm making a dodgeball. The idea is that when the dodgeball hits the player it kills them. Me being all fancy and stuff would rather use this sort of a script to be the directDamage rather than making the ball deal 9999 damage.

I'm making a dodgeball. The idea is that when the dodgeball hits the player it kills them. Me being all fancy and stuff would rather use this sort of a script to be the directDamage rather than making the ball deal 9999 damage.
Why the hell are you packaging a server command then, those are called when you type a slash followed by the function name in the chat?
Also, dodgeballs have been already made.

Why the hell are you packaging a server command then, those are called when you type a slash followed by the function name in the chat?
I am not a scripter.
That's why I'm asking for help.
Also, dodgeballs have been already made.
The one Chao made isn't good enough for my needs.

Why not just have the onCollision function directly call the ::kill method then?

Pulling the arguments out of memory, they may not be right.
Code: [Select]
function dodgeballProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
    %col.kill();
}

Tried that already. McTwist whipped up this script.
Code: [Select]
package DodgeBallPackage
{
function Dodgeball_Projectile::OnCollision(%projectile, %obj, %col, %fade, %pos, %normal)
{
%client = %col.client;
if (isObject(%client) && isObject(%client.minigame) && %col.getType() & $TypeMasks::PlayerObjectType)
%col.kill();
}
};
activatePackage(DodgeBallPackage);
It worked quite well, but the correct CI wouldn't display. It just showed the skull and crossbones.

Wouldn't it be simpler to just give the weapon an absurd amount of damage?

Don't use the onCollision function to do that. That breaks all sorts of minigame checks.

Projectile::damage

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

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

   if(%col.getType() & $TypeMasks::PlayerObjectType)
   {
      %scale = getWord(%col.getScale(), 2);
      %directDamage = %col.getDatablock().maxDamage * 6 * %scale;
      
      %col.damage(%obj, %pos, %directDamage, %damageType);
   }
   else
   {
      %scale = getWord(%obj.getScale(), 2);
      %directDamage = 5 * %scale;
      %col.damage(%obj, %pos, %directDamage, %damageType);
   }
}
Does (6 x maximum health) damage to players. (in case of "Overheal" "armor" whatever) It should use the correct CI and everything.

Does a tiny amount of damage to vehicles.

Note that ".kill()" just does 10000 or so damage fixed.
« Last Edit: December 11, 2010, 03:42:01 PM by Space Guy »

I see. I'll just keep things simple and make it do 100,000 damage. Thanks for the help anyway.

Don't use the onCollision function to do that. That breaks all sorts of minigame checks.

Projectile::damage

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

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

   if(%col.getType() & $TypeMasks::PlayerObjectType)
   {
      %scale = getWord(%col.getScale(), 2);
      %directDamage = %col.getDatablock().maxDamage * 6 * %scale;
      
      %col.damage(%obj, %pos, %directDamage, %damageType);
   }
   else
   {
      %scale = getWord(%obj.getScale(), 2);
      %directDamage = 5 * %scale;
      %col.damage(%obj, %pos, %directDamage, %damageType);
   }
}
Does (6 x maximum health) damage to players. (in case of "Overheal" "armor" whatever) It should use the correct CI and everything.

Does a tiny amount of damage to vehicles.

Note that ".kill()" just does 10000 or so damage fixed.

But that means there must be some even higher up absolute death function.

But that means there must be some even higher up absolute death function.
That's what I was kinda searching for too. Just idiot proofing the weapon in case someone makes a player type with millions of health.

Which is what mine does - 6x maximum health.