// TMW 2 Script
// Author:
// Jesusalva
// Micksha
// Description:
// Controls sewers.
// FIXME: People should not be able to return here once they leave to 042-10
// Spawn monsters and respawns them.
// A simple random treasure chest - to be sure players were introduced to this
// awesome system. Same rules as any treasure box still applies.
042-6,65,89,0 script #chest_0426 NPC_CHEST,{
KamelotTreasure(8);
specialeffect(.dir == 0 ? 24 : 25, AREA, getnpcid()); // closed ? opening : closing
close;
OnInit:
.distance = 2;
end;
OnInstanceInit:
// Yes, we just hope it works out of box
explode(.@map$, .map$, "@");
.@g=atoi(.@map$[1]);
if (.@g < 1) {
debugmes "[ERROR] [KAMELOT] Unable to spawn for Kamelot %s", .map$;
debugmes "[ERROR] [KAMELOT] Using dummy data (returned: %d)", .@g;
.@g=0;
}
debugmes "Spawning monsters for guild %d", .@g;
.@mx=getguildavg(.@g);
// Corritors
KamelotCaveSpawn(2, 21, 75, 50, 85, .@mx, "042-6");
KamelotCaveSpawn(7, 45, 45, 74, 80, .@mx, "042-6");
KamelotCaveSpawn(5, 52, 21, 90, 60, .@mx, "042-6");
KamelotCaveSpawn(3, 54, 28, 82, 39, .@mx, "042-6");
// Boss Chamber
KamelotCaveSpawn(5, 59, 71, 82, 91, .@mx, "042-6");
KamelotBoss("042-6", 74, 80, .@mx+1, .name$);
// Boss monster
// TODO
// Neutral monsters
areamonster(.map$, 20, 20, 90, 90, strmobinfo(1, YellowSlime), YellowSlime, 5);
areamonster(.map$, 20, 20, 90, 90, strmobinfo(1, ManaGhost), ManaGhost, max(1, .@mx/10));
areamonster(.map$, 20, 20, 90, 90, strmobinfo(1, CaveMaggot), CaveMaggot, 30);
// Bonus monsters
if (!rand2(2))
areamonster(.map$, 45, 20, 90, 90, strmobinfo(1, MagicBif), MagicBif, 2);
if (!rand2(2))
areamonster(.map$, 20, 20, 90, 90, strmobinfo(1, GoldenChest), GoldenChest, 1);
if (!rand2(2))
areamonster(.map$, 20, 20, 90, 90, strmobinfo(1, SilverChest), SilverChest, 2);
if (!rand2(2))
areamonster(.map$, 20, 20, 90, 90, strmobinfo(1, BronzeChest), BronzeChest, 3);
end;
OnKillBoss:
if (!playerattached())
goto OnRespawn;
// Maybe a reward is due
.@g=getcharid(2);
if (.@g < 1) percentheal -100, -100;
getitem GuildCoin, 2+min(13, $KAMELOT_MX[.@g]/10);
getexp $KAMELOT_MX[.@g]*14, $KAMELOT_MX[.@g]*8;
mapannounce getmap(), strcharinfo(0)+" has defeated the boss!", 0;
.@delay=max(3000, 21000-$KAMELOT_PC[.@g]*1000);
goto OnRespawn;
OnKillMob:
if (!playerattached())
goto OnRespawn;
// Maybe a reward is due
.@g=getcharid(2);
if (.@g < 1) percentheal -100, -100;
getexp $KAMELOT_MX[.@g]*7, $KAMELOT_MX[.@g]*4;
.@delay=max(3000, 21000-$KAMELOT_PC[.@g]*1000);
// FALLTHROUGH
OnRespawn:
.@delay=(.@delay ? .@delay : 3000);
sleep(.@delay);
// Yes, we just hope it works out of box
explode(.@map$, .map$, "@");
.@g=atoi(.@map$[1]);
if (.@g < 1) {
debugmes "[ERROR] [KAMELOT] Unable to respawn for Kamelot %s", .map$;
.@g=0;
}
KamelotCaveSpawn(1, 20, 20, 115, 100, $KAMELOT_MX[.@g], "042-6");
end;
}
// The exit only works before chest is looted
042-6,21,76,0 script #KDoor0426 NPC_HIDDEN,0,3,{
end;
OnTouch:
.@g=getcharid(2);
if (.@g < 1) percentheal -100, -100;
if ($KAMELOT_KEYMASK[.@g] & 8) goto L_NoAccess;
warp "042-5@"+.@g, 58, 53;
end;
L_NoAccess:
dispbottom l("OH NOES! The ceiling seems to have collapsed when the chest was open! We are forced to go forward!!");
end;
}