diff options
Diffstat (limited to 'npc/functions')
-rw-r--r-- | npc/functions/siege.txt | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/npc/functions/siege.txt b/npc/functions/siege.txt index 261492ac2..1a0d92dbe 100644 --- a/npc/functions/siege.txt +++ b/npc/functions/siege.txt @@ -25,6 +25,12 @@ function script siege_calcdiff { .@bsum=0; .@highest=getarg(1, false); .@c = getunits(BL_PC, .@players, false, getarg(0)); + + // Fallback: No players on map, always return 0 + if (.@c == 0) + return 0; + + // There is at least one player, do things properly for (.@i = 0; .@i < .@c; .@i++) { .@b=readparam(BaseLevel, .@players[.@i]); .@bsum+=.@b; @@ -62,7 +68,7 @@ function script siege_push { // siege_selectmob ( blvl, difficulty{, tp_mask} ) function script siege_selectmob { .@blv=getarg(0); - .@dif=getarg(1); + .@dif=getarg(1, 0); .@tp=getarg(2, 0); // We don't need .@dif, so we convert difficulty to levels @@ -124,11 +130,10 @@ function script siege_selectmob { return; } - +///////////////////////////////////////////////////////////// // Prepare a siege with optional announce // siege_setup ( map{, announce} ) function script siege_setup { - debugmes "Cast"; .@m$=getarg(0); .@msg$=getarg(1, ""); @@ -136,8 +141,52 @@ function script siege_setup { changemusic .@m$, any("mythica.ogg", "eric_matyas_ghouls.ogg", "misuse.ogg", "Arabesque.ogg"); disablenpc("Mana Stone"); pvpon(.@m$); + setmapflag(.@m$,mf_bexp,rand(140,160)); // 40~60% EXP UP on siege maps if (.@msg$ != "") kamibroadcast(col(.@msg$,1)); return; } +// Revert what siege_setup did +// siege_revert ( map ) +function script siege_revert { + .@m$=getarg(0); + + removemapmask .@m$, MASK_MATTACK; + changemusic .@m$, "caketown.ogg"; // :> + enablenpc("Mana Stone"); + pvpoff(.@m$); + removemapflag(.@m$,mf_bexp); + killmonsterall(.@m$); + return; +} + +// Spawn some monsters +// siege_cast ( map, NPCName, {, difficulty{, tpflag}} ) +function script siege_cast { + // mz - map ; n - name ; d - difficulty ; tp - teleport + // a - ammount ; e - mobId + .@mz$=getarg(0); + .@n$=getarg(1); + .@d=getarg(2,0); + .@tp=getarg(3,0); + + siege_selectmob(siege_calcdiff(.@mz$), .@d, .@tp); + + // How many monsters? + .@a=(.@d/3)+1; + + .@e=any_of($@SIEGE_TMPMOBS); + array_remove($@SIEGE_TMPMOBS, .@e); + siege_spawn(.@mz$, .@e, .@a, .@n$+"::OnRespawn"); + + .@e=any_of($@SIEGE_TMPMOBS); + array_remove($@SIEGE_TMPMOBS, .@e); + siege_spawn(.@mz$, .@e, .@a, .@n$+"::OnRespawn"); + + .@e=any_of($@SIEGE_TMPMOBS); + array_remove($@SIEGE_TMPMOBS, .@e); + siege_spawn(.@mz$, .@e, .@a, .@n$+"::OnRespawn"); + return; +} + |