// TMW 2 Script
// Author:
// Jesusalva
// Micksha
// Description:
// Basement Boss Fight
// We'll be counting attendance now.
042-2,41,22,0 script #KDoor0422 NPC_HIDDEN,0,0,{
function kdoor0422Spawn;
end;
OnTouch:
.@label$=instance_npcname(.name$)+"::OnKillBoss";
.@g=getcharid(2);
if (.@g < 1) die();
if (($KAMELOT_QUEST[.@g] & 4) && !mobcount(getmap(), .@label$)) {
warp "042-3@"+.@g, 58, 139;
} else {
dispbottom l("Powerful magic repels you!");
percentheal -5, -5;
slide 38, 28;
}
end;
OnArrival:
//debugmes "Arrival detected";
.@m$=instance_mapname("042-2");
.@g=getcharid(2);
if (.@g < 1)
die();
//debugmes getmap();
if (getmap() != "042-2@"+.@g)
end;
//debugmes $@KAMELOT_WAVE[.@g];
if ($@KAMELOT_WAVE[.@g] > 3)
end;
$@KAMELOT_WAVE[.@g]=100;
setd("$@GTEMP_PC_"+.@m$, $KAMELOT_PC[.@g]);
setd("$@GTEMP_MX_"+.@m$, $KAMELOT_MX[.@g]);
initnpctimer;
//debugmes "Timer Started";
end;
OnTimer1000:
.@m$=instance_mapname("042-2");
mapannounce .@m$, "??? : What's this? Why do I hear a commotion up there??", 0;
.@gcount=getd("$@GTEMP_PC_"+.@m$);
kdoor0422Spawn(.@gcount*2, 20, 24, 59, 59); // Prologue monsters
end;
OnTimer30000:
.@m$=instance_mapname("042-2");
mapannounce .@m$, "??? : WHAT?! This is not possible. Who are you, and how did you manage to come down here?", 0;
end;
OnTimer35000:
.@m$=instance_mapname("042-2");
.@n$=instance_npcname(.name$);
mapannounce .@m$, "??? : The sheer power of our lord should prevent anyone not under his control to go here.", 0;
maptimer .@m$, 5000, .@n$+"::OnVerifyIntent";
end;
OnTimer60000:
.@m$=instance_mapname("042-2");
mapannounce .@m$, "??? : HAHAHA! Meh, you will die anyways, so I can tell you that you never will even see our Lord.", 0;
end;
OnTimer67000:
.@m$=instance_mapname("042-2");
mapannounce .@m$, b("??? : You require the key hidden in the caves, additionally you must overcome the magical seal."), 0;
end;
OnTimer74000:
.@m$=instance_mapname("042-2");
mapannounce .@m$, "??? : Both is impossible for weaklings like you lot.", 0;
end;
OnTimer80000:
.@m$=instance_mapname("042-2");
mapannounce .@m$, "General Krukan : ##1I am General Krukan the Strong. Minions, ATTACK!", 0;
.@gcount=getd("$@GTEMP_PC_"+.@m$);
kdoor0422Spawn(.@gcount*2, 20, 24, 59, 59);
end;
OnTimer100000:
.@m$=instance_mapname("042-2");
mapannounce .@m$, "General Krukan : MUhahahahaha! Minions, Dispose of these Adventurers! Kill them already!", 0;
.@gcount=getd("$@GTEMP_PC_"+.@m$);
kdoor0422Spawn(.@gcount*2, 20, 24, 59, 59);
end;
OnTimer120000:
.@m$=instance_mapname("042-2");
mapannounce .@m$, "General Krukan : *facepalm* Now, you're just being pathetic minions. How about you try a different approach and kill them already!", 0;
.@gcount=getd("$@GTEMP_PC_"+.@m$);
kdoor0422Spawn(.@gcount*2, 20, 24, 59, 59);
end;
OnTimer180000:
.@m$=instance_mapname("042-2");
.@n$=instance_npcname(.name$);
mapannounce .@m$, "General Krukan : Looks like if you want something done right you have to do it yourself. ##1Charge!", 0;
.@gcount=getd("$@GTEMP_PC_"+.@m$);
.@avg=getd("$@GTEMP_MX_"+.@m$);
kdoor0422Spawn(.@gcount*3, 20, 24, 59, 59);
.@avg=getd("$@GTEMP_MX_"+.@m$);
//debugmes "BOSS - %d, map %s (power %d)", .@gcount, .@m$, .@avg;
.@mob=monster(.@m$, 34, 26, strmobinfo(1, GeneralKrukan), GeneralKrukan, 1, .@n$+"::OnKillBoss");
// Reconfigure the monster
setunitdata(.@mob, UDT_LEVEL, .@avg);
setunitdata(.@mob, UDT_STR, 1+.@avg/3);
setunitdata(.@mob, UDT_AGI, 1+.@avg/3);
setunitdata(.@mob, UDT_VIT, 1+.@avg/3);
setunitdata(.@mob, UDT_INT, 1+.@avg/3);
setunitdata(.@mob, UDT_DEX, 1+.@avg/3);
setunitdata(.@mob, UDT_LUK, 1+.@avg/3);
setunitdata(.@mob, UDT_ADELAY, 1372);
setunitdata(.@mob, UDT_ATKRANGE, 3);
// Battle Status
setunitdata(.@mob, UDT_MAXHP, .@avg*320);
setunitdata(.@mob, UDT_HP, .@avg*320);
setunitdata(.@mob, UDT_ATKMIN, .@avg*65/10);
setunitdata(.@mob, UDT_ATKMAX, .@avg*85/10);
setunitdata(.@mob, UDT_DEF, 1+.@avg);
setunitdata(.@mob, UDT_MDEF, 1+.@avg*8/10);
setunitdata(.@mob, UDT_HIT, .@avg*12); // Advised: x3
setunitdata(.@mob, UDT_FLEE, .@avg*39/10); // Advised: x4
// Critical calculation
.@min=15;
.@max=max(.@min, min(50, .@avg/4));
setunitdata(.@mob, UDT_CRIT, rand2(.@min, .@max));
// Loop through
setd("$@GTEMP_"+.@m$, .@mob);
setd("$@GTEMP_HP_"+.@m$, 10);
end;
OnTimer185000:
//debugmes "Timer Running";
.@m$=instance_mapname("042-2");
.@mob=getd("$@GTEMP_"+.@m$);
.@gcount=getd("$@GTEMP_PC_"+.@m$);
.@ratio=getunitdata(.@mob, UDT_HP)*10/getunitdata(.@mob, UDT_MAXHP);
//debugmes "Ratio %d/%d", .@ratio, getd("$@GTEMP_HP_"+.@m$);
if (.@ratio < getd("$@GTEMP_HP_"+.@m$)) {
mapannounce .@m$, "General Krukan : "+any("Charge!", "To the Abyss with you already!", "Kill them already!", "More of them might be coming!", "Minions, ATTACK!"), 0;
kdoor0422Spawn(.@gcount*2, 20, 24, 59, 59);
setd("$@GTEMP_HP_"+.@m$, .@ratio);
}
//debugmes "Restart timer";
setnpctimer 180001;
end;
OnVerifyIntent:
.@g=getcharid(2);
if (.@g < 1) die();
mesq l("Who are you, and how did you manage to come down here? The sheer power of our Lord prevents anyone not under his control to go here.");
select
l("We are strong fighters, and we want to free the King from his obsession."),
l("Oh, yea, you are right, it was a mistake. Bye-bye.");
mes "";
if (@menu == 2) {
mesc l("ARE YOU SURE?"), 1;
mesc l("This will remove you from the quest!");
next;
if (askyesno() == ASK_YES) {
mapannounce getmap(), "General Krukan : I praise you for running away, "+strcharinfo(0)+". You're not a fool it seems.", 0;
warp "014-4", 67, 27;
percentheal 100, 100;
closeclientdialog;
end;
}
} else {
getexp $KAMELOT_MX[.@g]*6, $KAMELOT_MX[.@g]*2;
}
mesc l("With fresh conviction, you prepare yourself to the fight which draws near.");
getitem GuildCoin, 1;
close;
OnKillMob:
if (!playerattached()) end;
.@g=getcharid(2);
if (.@g < 1) die();
getexp $KAMELOT_MX[.@g]*5, $KAMELOT_MX[.@g]*2;
end;
OnKillBoss:
.@m$=instance_mapname("042-2");
.@n$=instance_npcname(.name$);
stopnpctimer;
setd("$@GTEMP_"+.@m$, 0);
setd("$@GTEMP_HP_"+.@m$, 0);
setd("$@GTEMP_PC_"+.@m$, 0);
setd("$@GTEMP_MX_"+.@m$, 0);
.@g=getcharid(2);
// Player Reward for completing this stage
getitem GuildCoin, min(1, $KAMELOT_MX[.@g]/20);
getexp $KAMELOT_MX[.@g]*50, $KAMELOT_MX[.@g]*10;
// Guild Reward for completing this stage
.@ggp=1200+$KAMELOT_MX[.@g]*5;
.@gxp=$KAMELOT_MX[.@g]*10;
$GUILD_BANK[.@g]+=.@ggp;
guildgetexp(.@gxp); // 10xp per player average level (max 1000/1500)
// Announce
mapannounce getmap(), strcharinfo(0)+" has defeated Krukan!", 0;
// Guild Master Notification
.@gm$=getguildmaster(.@g);
if (!getcharid(3, .@gm$)) end;
.@gma=getcharid(3, .@gm$);
.@gmb=getcharid(0, .@gm$);
if (!isloggedin(.@gma, .@gmb)) end;
message .@gm$, strcharinfo(0)+" defeated Krukan: Guild GP +"+.@ggp+" Guild XP +"+.@gxp;
// Arrest scene + exp
maptimer .@m$, 1500, .@n$+"::OnReward";
setd("$@GTEMP_"+.@m$, .@g);
setnpctimer 1000000; // Prefix 1M
startnpctimer;
end;
///////////////////////////////////////////////////////////////////////
OnTimer1002000:
.@m$=instance_mapname("042-2");
.@n$=instance_npcname(.name$);
// Bring Razha (the only mob with fixed difficulty in Kamelot)
.@raz=monster(.@m$, 41, 23, strmobinfo(1, GeneralRazha), GeneralRazha, 1,
.@n$+"::OnOptionalBoss");
// Configure the optional boss
setunitdata(.@raz, UDT_LEVEL, 150);
setunitdata(.@raz, UDT_STR, 150);
setunitdata(.@raz, UDT_AGI, 150);
setunitdata(.@raz, UDT_VIT, 150);
setunitdata(.@raz, UDT_INT, 150);
setunitdata(.@raz, UDT_DEX, 150);
setunitdata(.@raz, UDT_LUK, 150);
setunitdata(.@raz, UDT_ADELAY, 1072);
setunitdata(.@raz, UDT_ATKRANGE, 3);
// Battle Status
setunitdata(.@raz, UDT_MAXHP, 150000);
setunitdata(.@raz, UDT_HP, 150000);
setunitdata(.@raz, UDT_ATKMIN, 400);
setunitdata(.@raz, UDT_ATKMAX, 750);
setunitdata(.@raz, UDT_DEF, 300);
setunitdata(.@raz, UDT_MDEF, 300);
setunitdata(.@raz, UDT_HIT, 32767); // Advised: x3
setunitdata(.@raz, UDT_FLEE, 420); // Advised: x4
setunitdata(.@raz, UDT_CRIT, 70);
// Loop through
sc_start(SC_STUN, 15000, 1, 10000, SCFLAG_NOAVOID|SCFLAG_FIXEDTICK, .@raz);
unittalk(.@raz, "What is happening here??");
mapannounce .@m$, "General Razha : ##1What's happening here??", 0;
sleep(100);
sc_end(SC_STUN, .@raz);
unitwalk(.@raz, 41, 24);
sleep(200);
sc_start(SC_STUN, 15000, 1, 10000, SCFLAG_NOAVOID|SCFLAG_FIXEDTICK, .@raz);
end;
OnTimer1007000:
.@m$=instance_mapname("042-2");
mapannounce .@m$, "General Razha : GUARDS!!", 0;
end;
OnTimer1007500:
.@m$=instance_mapname("042-2");
.@r1=monster(.@m$, 40, 24, strmobinfo(1, CursedSoldier), CursedSoldier, 1);
.@r2=monster(.@m$, 42, 24, strmobinfo(1, CursedArcher), CursedArcher, 1);
sc_start(SC_STUN, 15000, 1, 10000, SCFLAG_NOAVOID|SCFLAG_FIXEDTICK, .@r1);
sc_start(SC_STUN, 15000, 1, 10000, SCFLAG_NOAVOID|SCFLAG_FIXEDTICK, .@r2);
kdoor0422Spawn(49, 20, 24, 59, 59); // 1225 tiles, 1 per 25 tiles
end;
OnTimer1012000:
.@m$=instance_mapname("042-2");
mapannounce .@m$, "General Razha : Arrest them all!!", 0;
end;
OnTimer1015000:
.@m$=instance_mapname("042-2");
.@t$=instance_mapname("042-3");
.@g=getd("$@GTEMP_"+.@m$);
.@n$="#KSlimeSpawn"; //instance_npcname("#KSlimeSpawn", $KAMELOT_ID[.@g]);
setarray .@x, 33, 84, 41, 74, 36, 57, 79, 43, 24, 86, 59, 38;
setarray .@y, 135, 127, 119, 107, 96, 84, 63, 67, 67, 22, 49, 27;
.@c=getunits(BL_PC, .@unt, false, .@m$, 20, 24, 59, 59);
for (.@i = 0; .@i < .@c; .@i++) {
specialeffect(FX_HIT, AREA, .@unt[.@i]);
.@v = (.@i % 12);
.@r=attachrid(.@unt[.@i]);
if (.@r) {
warp .@t$, .@x[.@v], .@y[.@v];
if (!countitem(Lockpicks))
addtimer 700, .@n$+"::OnFirstSlime";
setpcblock(255, false);
} else {
unitwarp(.@unt[.@i], .@t$, .@x[.@v], .@y[.@v]); // And good luck D:
debugmes "FATAL: Could not attach: %d", .@unt[.@i];
}
}
$KAMELOT_QUEST[.@g]=$KAMELOT_QUEST[.@g]|4; // This part is complete
setd("$@GTEMP_"+.@m$, 0);
stopnpctimer;
end;
OnReward:
.@g=getcharid(2);
if (.@g < 1) die();
setpcblock(255, true);
getitem GuildCoin, min(1, $KAMELOT_MX[.@g]/25);
getexp $KAMELOT_MX[.@g]*50, $KAMELOT_MX[.@g]*10;
dispbottom l("Wait- Something is happening!");
end;
OnOptionalBoss:
.@g=getcharid(2);
// Player Reward for completing this stage
getitem GuildCoin, 5;
getexp 50000, 10000;
// Guild Reward for completing this stage
.@ggp=12000;
.@gxp=100000;
$GUILD_BANK[.@g]+=.@ggp;
guildgetexp(.@gxp); // 10xp per player average level (max 1000/1500)
// Announce
mapannounce getmap(), strcharinfo(0)+" has defeated Razha!", 0;
// Guild Master Notification
.@gm$=getguildmaster(.@g);
if (!getcharid(3, .@gm$)) end;
.@gma=getcharid(3, .@gm$);
.@gmb=getcharid(0, .@gm$);
if (!isloggedin(.@gma, .@gmb)) end;
message .@gm$, strcharinfo(0)+" defeated Razha: Guild GP +"+.@ggp+" Guild XP +"+.@gxp;
end;
function kdoor0422Spawn {
//debugmes "Spawning";
.@label$=instance_npcname(.name$)+"::OnKillMob";
.@gcount=getarg(0);
.@x1=getarg(1);
.@y1=getarg(2);
.@x2=getarg(3);
.@y2=getarg(4);
.@m$=instance_mapname("042-2");
.@avg=getd("$@GTEMP_MX_"+.@m$);
//debugmes "Total %d, map %s (power %d)", .@gcount, .@m$, .@avg;
freeloop(true);
for (.@i=0; .@i < .@gcount; .@i++) {
.@mobId=any(CursedSoldier, CursedArcher); // 50-50 ratio
.@mob=areamonster(.@m$, .@x1, .@y1, .@x2, .@y2, strmobinfo(1, .@mobId), .@mobId, 1, .@label$);
// Reconfigure the monster
setunitdata(.@mob, UDT_LEVEL, .@avg);
setunitdata(.@mob, UDT_STR, 1+.@avg/4);
setunitdata(.@mob, UDT_AGI, 1+.@avg/4);
setunitdata(.@mob, UDT_VIT, 1+.@avg/4);
setunitdata(.@mob, UDT_INT, 1+.@avg/4);
setunitdata(.@mob, UDT_DEX, 1+.@avg/4);
setunitdata(.@mob, UDT_LUK, 1+.@avg/4);
setunitdata(.@mob, UDT_ADELAY, 1672);
setunitdata(.@mob, UDT_ATKRANGE, (.@mobId == CursedArcher ? any(6,7) : any(1,2)));
// Battle Status
setunitdata(.@mob, UDT_MAXHP, .@avg*33);
setunitdata(.@mob, UDT_HP, .@avg*33);
setunitdata(.@mob, UDT_ATKMIN, .@avg*40/10);
setunitdata(.@mob, UDT_ATKMAX, .@avg*60/10);
setunitdata(.@mob, UDT_DEF, 1+.@avg*9/10);
setunitdata(.@mob, UDT_MDEF, 1+.@avg*5/10);
setunitdata(.@mob, UDT_HIT, .@avg*45/10); // Advised: x3
setunitdata(.@mob, UDT_FLEE, .@avg*35/10); // Advised: x4
// Critical calculation
.@min=2;
.@max=max(.@min, min(25, .@avg/5));
setunitdata(.@mob, UDT_CRIT, rand2(.@min, .@max));
// Loop through
}
freeloop(false);
//debugmes "Done spawn 042-2";
return;
}
// Script end
}
// Required exit
042-2,44,60,0 script #KDoor0422B NPC_HIDDEN,0,0,{
end;
OnTouch:
.@g=getcharid(2);
if ($KAMELOT_QUEST[.@g] & 4) {
warp "042-1@"+.@g, 51, 24;
} else {
dispbottom l("Oh noes! The guards locked the door!");
}
end;
}