Author Topic: How to make a player die if touches another  (Read 1228 times)

If a specific playertype touches another player, it will insta-kill them

ex.) Playertype1 touches Playertype2, Playertype2 will die

Use the script from Pompmakers MC Zombie. Just increase the damage it does on touch.

Use the script from Pompmakers MC Zombie. Just increase the damage it does on touch.
Yes, exactly what i did, but does it only work for players, not Bots? If so that is fine

something like this could work

Code: [Select]
function armor::onCollision(%obj,%col,%vec)
{
      //psuedocode starts here
      if(%col's datablock $= "Player")
                %col.kill();
}

might be wrong, need someone like zeblote or jes to swoom in and correct me

function Armor::onCollision(%this, %obj, %col, %vec, %force)
Make sure to package this and parent it

if(%col's datablock $= "Player") to if((%col.getType() & $TypeMasks::PlayerObjectType) && %col.getState() !$= "dead")

Yes, onCollision can also detect dead bodies

You should parent it before you kill the player.

Here's some old code I found. When the ghost player touches another player, he kills them.
Code: [Select]
package playerGhost
{
//Snip

function armor::onCollision(%this, %obj, %col, %pos, %vel)
{
parent::onCollision(%this, %obj, %col, %pos, %vel);

if(!isObject(%obj) || !isObject(%client = %obj.client) || !isObject(%col))
{
return;
}

if(%obj.getClassName() !$= "Player" || %col.getClassName() !$= "Player")
{
return;
}

if(%this.getID() != playerGhost.getID())
{
return;
}

if(!isObject(%client.minigame) || !isObject(%col.client.minigame))
{
return;
}

//Snip

if(!minigameCanDamage(%obj, %col))
{
return;
}

//Snip

%col.damage(%client, "0 0 0", %col.getDatablock().maxDamage - %col.getDamageLevel(), $DamageType::GhostTouch);

//Snip
}

//Snip
};
activatePackage(playerGhost);
You should use .damage instead of .kill. That way it counts as one player killing another, not just some guy dying mysteriously. Change the damage type to something else though. There's a generic damage type but I don't have time to get what it is right now.
« Last Edit: May 03, 2016, 12:22:33 PM by jes00 »

export(); is useful for getting a list of variables like $DamageType.  I think it'd be something like: export("$DamageType*","base/listname.txt");

export(); is useful for getting a list of variables like $DamageType.  I think it'd be something like: export("$DamageType*","base/listname.txt");

Most of the time it's enough to do export("$DamageType::*"); to dump them in your console.

Most of the time it's enough to do export("$DamageType::*"); to dump them in your console.
Woah. Never knew this was a thing. The more you know.

Anyway. I'd suggest using $DamageType::Default.
« Last Edit: May 07, 2016, 08:00:47 PM by jes00 »