// TMW2 Scripts
// Author:
// The Mana World Brazil
// Jesusalva
// Description:
// Traps and other functions.
// SteelTrap( {damage=80%}, {delay=15s}, {stun=3s}, {npcname=auto} )
function script SteelTrap {
.@dmg=getarg(0, 80);
.@delay=getarg(1, 15);
.@stun=getarg(2, 3);
.@n$=getarg(3, strnpcinfo(0));
// It was disarmed
if (getnpctimer(0) == 0)
{
initnpctimer;
setnpcdisplay .@n$, NPC_TRAP_ONLINE;
return;
}
// Fire!!
setnpctimer 9000;
setnpcdisplay .@n$, NPC_TRAP_TRIGGERED;
// Boom - Hurt players and/or stun monsters
// This means you can - and SHOULD - lead Forains into these traps
if (playerattached())
{
percentheal -(.@dmg), 0;
}
else
{
.@stun*=1000;
sc_start SC_WALKSPEED,(.@delay*1000),60;
sc_start SC_STUN,rand(.@stun,.@stun*3),0;
}
// A minor special effect and we're done.
specialeffect 11;
return;
}
// Unlike SteelTrap, presents same behavior and absolute damage
// IronTrap( {damage=100}, {delay=15s}, {stun=3s}, {npcname=auto} )
function script IronTrap {
.@dmg=getarg(0, 100);
.@delay=getarg(1, 15);
.@stun=getarg(2, 3);
.@n$=getarg(3, strnpcinfo(0));
// It was disarmed
if (getnpctimer(0) == 0 && .@delay)
{
initnpctimer;
setnpcdisplay .@n$, NPC_TRAP_ONLINE;
return;
}
// Fire!!
setnpctimer 9000;
setnpcdisplay .@n$, NPC_TRAP_TRIGGERED;
// Boom - Hurt and Stun (only works on players and mobs)
.@stun*=1000;
sc_start SC_STUN, rand2(.@stun,.@stun*3), 0;
.@gid=(playerattached() ? playerattached() : mobattached());
// Just to be sure
if (.@gid > 0)
harm(.@gid, .@dmg, HARM_MISC);
else
Exception("IronTrap \""+.@n$+"\" called without GID!", RB_DEBUGMES);
// A minor special effect and we're done.
specialeffect 11;
return;
}
// WorldHeartTrap( {damage=8%}, {delay=6s}, {npcname=auto} )
function script WorldHeartTrap {
.@dmg=getarg(0, 8);
.@delay=getarg(1, 6);
.@n$=getarg(2, strnpcinfo(0));
// It cannot be disarmed, but unhide it anyway
if (getnpctimer(0) == 0 && getnpcclass() == NPC_TRAP)
{
initnpctimer;
setnpcdisplay .@n$, NPC_TRAP_ONLINE;
setnpctimer 9000;
}
// Fire!!
setnpcdisplay .@n$, NPC_TRAP_TRIGGERED;
// Unlike regular traps, the damage is centered on players
// Monsters are largely unaffected by them!
if (playerattached()) {
percentheal -(.@dmg), 0;
sc_start SC_WALKSPEED,(.@delay*1000),60;
} else {
sc_start SC_WALKSPEED,(.@delay*1000),64;
}
// A minor special effect and we're done.
specialeffect 11;
return;
}
// SkillTrap( {damage=100}, {delay=2s}, {npcname=auto} )
function script SkillTrap {
.@dmg=getarg(0, 100);
.@delay=getarg(1, 2);
.@n$=getarg(2, strnpcinfo(0));
// Fire!!
awake(.@n$);
setnpcdisplay .@n$, NPC_TRAP_TRIGGERED;
// Skill traps does not distinguish between players or monsters
// (and does not work on homunculus, mercenaries, etc.)
sc_start SC_STUN, .@delay, 0;
.@gid=(playerattached() ? playerattached() : mobattached());
// Just to be sure
if (.@gid > 0)
harm(.@gid, .@dmg, HARM_MISC);
else
Exception("SkillTrap \""+.@n$+"\" called without GID!", RB_DEBUGMES);
// A minor special effect and we're done.
specialeffect 11;
sleep(800);
setnpcdisplay .@n$, NPC_TRAP_ONLINE;
return;
}