summaryrefslogtreecommitdiff
path: root/npc
diff options
context:
space:
mode:
Diffstat (limited to 'npc')
-rw-r--r--npc/functions/siege.txt99
-rw-r--r--npc/functions/timer.txt1
2 files changed, 100 insertions, 0 deletions
diff --git a/npc/functions/siege.txt b/npc/functions/siege.txt
index 010ef0da3..6fe15287c 100644
--- a/npc/functions/siege.txt
+++ b/npc/functions/siege.txt
@@ -17,3 +17,102 @@ function script siege_spawn {
return;
}
+// Calculate player average level
+// if highest is set, it will return highest player level, with minimum the value
+// passed. (A level "0" is clearly not valid, of course)
+// siege_calcdiff ( map{, highest_lvl} )
+function script siege_calcdiff {
+ .@bsum=0;
+ .@highest=getarg(1, false);
+ .@c = getunits(BL_PC, .@players, false, getarg(0));
+ for (.@i = 0; .@i < .@c; .@i++) {
+ .@b=;readparam(BaseLevel, .@players[.@i])
+ .@bsum+=.@b;
+ if (.@b > .@highest)
+ .@highest=.@b;
+ }
+ if (getarg(1,false))
+ return .@highest;
+ else
+ return (.@bsum/.@c);
+}
+
+// push to @mobs the <mobID> if their level is within a 20 level range
+// above or below <level>
+// siege_push ( mobID, level )
+function script siege_push {
+ .@mi=getarg(0);
+ .@lv=getarg(1,0);
+
+ if (is_between(.@lv-20, .@lv+20, atoi(strmobinfo(3, .@mi)) ) )
+ array_push(@mobs, .@mi);
+ return;
+}
+
+// Selects a monster based on player average strength and base difficulty
+// It'll select monsters from 20 levels below to 20 levels above
+// tp_mask is the same as TP_* constants and changes mobs present. Only TP_TULIM,
+// TP_HURNS and TP_NIVAL are supported. You can use them with the "|" operand, eg.,
+// TP_TULIM | TP_HURNS.
+//
+// It currently only creates @mobs, you need to use any_of() manually.
+// siege_selectmob ( blvl, difficulty{, tp_mask} )
+function script siege_selectmob {
+ .@blv=getarg(0);
+ .@dif=getarg(1);
+ .@tp=getarg(2, 0);
+
+ // We don't need .@dif, so we convert difficulty to levels
+ .@blv+=.@dif*3;
+
+ deletearray @mobs;
+ setarray @mobs, ManaGhost, CandiedSlime, Bif;
+ // Now we must select mobs, using array_push() to @mobs
+ // First, mobs on all envs
+ siege_push(BlackScorpion, .@blv);
+ siege_push(GreenSlime, .@blv);
+ siege_push(CaveMaggot, .@blv);
+ siege_push(MagicGoblin, .@blv);
+ siege_push(AngryBat, .@blv);
+ siege_push(BlackSlime, .@blv);
+ siege_push(BlackScorpion, .@blv);
+ siege_push(Forain, .@blv);
+ siege_push(GreenDragon, .@blv);
+ siege_push(Terranite, .@blv);
+ siege_push(JackO, .@blv);
+ siege_push(BlackMamba, .@blv);
+ siege_push(TerraniteProtector, .@blv);
+
+ // Now, mobs on only certain envs
+ if (.@tp & TP_TULIM) {
+ siege_push(AngryScorpion, .@blv);
+ siege_push(AngryRedScorpion, .@blv);
+ siege_push(DesertBandit, .@blv);
+ siege_push(LavaSlime, .@blv);
+ siege_push(OldSnake, .@blv);
+ siege_push(Snake, .@blv);
+ }
+ if (.@tp & TP_HURNS) {
+ siege_push(RedSlime, .@blv);
+ siege_push(Bandit, .@blv);
+ siege_push(RedMushroom, .@blv);
+ siege_push(RobinBandit, .@blv);
+ siege_push(AngryYellowSlime, .@blv);
+ siege_push(GrassSnake, .@blv);
+ siege_push(WickedMushroom, .@blv);
+ }
+ if (.@tp & TP_NIVAL) {
+ siege_push(Bluepar, .@blv);
+ siege_push(Wolvern, .@blv);
+ siege_push(Yeti, .@blv);
+ siege_push(Moggun, .@blv); // PS. Not aggressive
+ }
+
+ // Removed
+ //siege_push(DarkLizard, .@blv);
+ //siege_push(Crafty, .@blv);
+
+ return;
+}
+
+
diff --git a/npc/functions/timer.txt b/npc/functions/timer.txt
index cd1684b94..ac7d130bd 100644
--- a/npc/functions/timer.txt
+++ b/npc/functions/timer.txt
@@ -46,6 +46,7 @@ function script maptimer {
return .@i;
}
+// Same as maptimer() but deletes any previously running timer
// maptimer2("<map>", <tick>, "<npc>::<event>")
function script maptimer2 {
.@c = getunits(BL_PC, .@players, false, getarg(0));