From fab305565f4621cbf44912b97276d8ba27501f6d Mon Sep 17 00:00:00 2001
From: Jessica Tölke <jtoelke@mail.upb.de>
Date: Sat, 3 Sep 2011 11:36:19 +0200
Subject: add check of return value from attachrid in several scripts

---
 world/map/npc/033-1/kimarr.txt  |   2 +-
 world/map/npc/034-1/ambushs.txt | 120 +++++++++++++++++++++++++++++++++++-----
 world/map/npc/042-1/hasan.txt   |   7 ++-
 3 files changed, 110 insertions(+), 19 deletions(-)

(limited to 'world')

diff --git a/world/map/npc/033-1/kimarr.txt b/world/map/npc/033-1/kimarr.txt
index c59d1036..7882d3d1 100644
--- a/world/map/npc/033-1/kimarr.txt
+++ b/world/map/npc/033-1/kimarr.txt
@@ -309,7 +309,7 @@ OnFluffyDeath:
     //  message strcharinfo(0), "Fluffies killed: " + $@Fluffy_Kills;
     if ($@Fluffy_Alive != 0)
         end;
-    if (attachrid($@Fluffy_FighterID))
+    if (attachrid($@Fluffy_FighterID) == 1)
         goto L_Killedall;
     goto L_GotOut;
     end;
diff --git a/world/map/npc/034-1/ambushs.txt b/world/map/npc/034-1/ambushs.txt
index 31d6cebb..a3d2d5a0 100644
--- a/world/map/npc/034-1/ambushs.txt
+++ b/world/map/npc/034-1/ambushs.txt
@@ -24,7 +24,8 @@
 end;
 
 OnAmbush:
-    attachrid($@Ambush0VictimID);
+    if (attachrid($@Ambush0VictimID) == 0)
+        goto L_Abort;
     set @wolvern_amount, 10;   // has to be same value as in birrod.txt
     set $@Ambush0_Spawn, 4 + rand(3);
     message strcharinfo(0), "An ambush!";
@@ -32,6 +33,11 @@ OnAmbush:
     set $@Ambush0VictimID, 0;
     end;
 
+L_Abort:
+    set $@Ambush0_Active, 0;
+    set $@Ambush0VictimID, 0;
+    end;
+
 OnWolvernDeath:
     set @MobID, 1089; // TODO: adapt
 
@@ -72,7 +78,8 @@ OnWolvernDeath:
 end;
 
 OnAmbush:
-    attachrid($@Ambush1VictimID);
+    if (attachrid($@Ambush1VictimID) == 0)
+        end;
     set @wolvern_amount, 10;   // has to be same value as in birrod.txt
     set $@Ambush1_Spawn, 4 + rand(3);
     message strcharinfo(0), "An ambush!";
@@ -80,6 +87,11 @@ OnAmbush:
     set $@Ambush1VictimID, 0;
     end;
 
+L_Abort:
+    set $@Ambush1_Active, 0;
+    set $@Ambush1VictimID, 0;
+    end;
+
 OnWolvernDeath:
     set @MobID, 1089; // TODO: adapt
 
@@ -120,7 +132,8 @@ OnWolvernDeath:
 end;
 
 OnAmbush:
-    attachrid($@Ambush2VictimID);
+    if (attachrid($@Ambush2VictimID) == 0)
+        goto L_Abort;
     set @wolvern_amount, 10;   // has to be same value as in birrod.txt
     set $@Ambush2_Spawn, 4 + rand(3);
     message strcharinfo(0), "An ambush!";
@@ -128,6 +141,11 @@ OnAmbush:
     set $@Ambush2VictimID, 0;
     end;
 
+L_Abort:
+    set $@Ambush2_Active, 0;
+    set $@Ambush2VictimID, 0;
+    end;
+
 OnWolvernDeath:
     set @MobID, 1089; // TODO: adapt
 
@@ -168,7 +186,8 @@ OnWolvernDeath:
 end;
 
 OnAmbush:
-    attachrid($@Ambush3VictimID);
+    if (attachrid($@Ambush3VictimID) == 0)
+        goto L_Abort;
     set @wolvern_amount, 10;   // has to be same value as in birrod.txt
     set $@Ambush3_Spawn, 4 + rand(3);
     message strcharinfo(0), "An ambush!";
@@ -176,6 +195,11 @@ OnAmbush:
     set $@Ambush3VictimID, 0;
     end;
 
+L_Abort:
+    set $@Ambush3_Active, 0;
+    set $@Ambush3VictimID, 0;
+    end;
+
 OnWolvernDeath:
     set @MobID, 1089; // TODO: adapt
 
@@ -216,7 +240,8 @@ OnWolvernDeath:
 end;
 
 OnAmbush:
-    attachrid($@Ambush4VictimID);
+    if (attachrid($@Ambush4VictimID) == 0)
+        goto L_Abort;
     set @wolvern_amount, 10;   // has to be same value as in birrod.txt
     set $@Ambush4_Spawn, 4 + rand(3);
     message strcharinfo(0), "An ambush!";
@@ -224,6 +249,11 @@ OnAmbush:
     set $@Ambush4VictimID, 0;
     end;
 
+L_Abort:
+    set $@Ambush4_Active, 0;
+    set $@Ambush4VictimID, 0;
+    end;
+
 OnWolvernDeath:
     set @MobID, 1089; // TODO: adapt
 
@@ -264,7 +294,8 @@ OnWolvernDeath:
 end;
 
 OnAmbush:
-    attachrid($@Ambush5VictimID);
+    if (attachrid($@Ambush5VictimID) == 0)
+        goto L_Abort;
     set @wolvern_amount, 10;   // has to be same value as in birrod.txt
     set $@Ambush5_Spawn, 4 + rand(3);
     message strcharinfo(0), "An ambush!";
@@ -272,6 +303,11 @@ OnAmbush:
     set $@Ambush5VictimID, 0;
     end;
 
+L_Abort:
+    set $@Ambush5_Active, 0;
+    set $@Ambush5VictimID, 0;
+    end;
+
 OnWolvernDeath:
     set @MobID, 1089; // TODO: adapt
 
@@ -312,7 +348,8 @@ OnWolvernDeath:
 end;
 
 OnAmbush:
-    attachrid($@Ambush6VictimID);
+    if (attachrid($@Ambush6VictimID) == 0)
+        goto L_Abort;
     set @wolvern_amount, 10;   // has to be same value as in birrod.txt
     set $@Ambush6_Spawn, 4 + rand(3);
     message strcharinfo(0), "An ambush!";
@@ -320,6 +357,11 @@ OnAmbush:
     set $@Ambush6VictimID, 0;
     end;
 
+L_Abort:
+    set $@Ambush6_Active, 0;
+    set $@Ambush6VictimID, 0;
+    end;
+
 OnWolvernDeath:
     set @MobID, 1089; // TODO: adapt
 
@@ -360,7 +402,8 @@ OnWolvernDeath:
 end;
 
 OnAmbush:
-    attachrid($@Ambush7VictimID);
+    if (attachrid($@Ambush7VictimID) == 0)
+        goto L_Abort;
     set @wolvern_amount, 10;   // has to be same value as in birrod.txt
     set $@Ambush7_Spawn, 4 + rand(3);
     message strcharinfo(0), "An ambush!";
@@ -368,6 +411,11 @@ OnAmbush:
     set $@Ambush7VictimID, 0;
     end;
 
+L_Abort:
+    set $@Ambush7_Active, 0;
+    set $@Ambush7VictimID, 0;
+    end;
+
 OnWolvernDeath:
     set @MobID, 1089; // TODO: adapt
 
@@ -408,7 +456,8 @@ OnWolvernDeath:
 end;
 
 OnAmbush:
-    attachrid($@Ambush8VictimID);
+    if (attachrid($@Ambush8VictimID) == 0)
+        goto L_Abort;
     set @wolvern_amount, 10;   // has to be same value as in birrod.txt
     set $@Ambush8_Spawn, 4 + rand(3);
     message strcharinfo(0), "An ambush!";
@@ -416,6 +465,11 @@ OnAmbush:
     set $@Ambush8VictimID, 0;
     end;
 
+L_Abort:
+    set $@Ambush8_Active, 0;
+    set $@Ambush8VictimID, 0;
+    end;
+
 OnWolvernDeath:
     set @MobID, 1089; // TODO: adapt
 
@@ -456,7 +510,8 @@ OnWolvernDeath:
 end;
 
 OnAmbush:
-    attachrid($@Ambush9VictimID);
+    if (attachrid($@Ambush9VictimID) == 0)
+        goto L_Abort;
     set @wolvern_amount, 10;   // has to be same value as in birrod.txt
     set $@Ambush9_Spawn, 4 + rand(3);
     message strcharinfo(0), "An ambush!";
@@ -464,6 +519,11 @@ OnAmbush:
     set $@Ambush9VictimID, 0;
     end;
 
+L_Abort:
+    set $@Ambush9_Active, 0;
+    set $@Ambush9VictimID, 0;
+    end;
+
 OnWolvernDeath:
     set @MobID, 1089; // TODO: adapt
 
@@ -504,7 +564,8 @@ OnWolvernDeath:
 end;
 
 OnAmbush:
-    attachrid($@Ambush10VictimID);
+    if (attachrid($@Ambush10VictimID) == 0)
+        goto L_Abort;
     set @wolvern_amount, 10;   // has to be same value as in birrod.txt
     set $@Ambush10_Spawn, 4 + rand(3);
     message strcharinfo(0), "An ambush!";
@@ -512,6 +573,11 @@ OnAmbush:
     set $@Ambush10VictimID, 0;
     end;
 
+L_Abort:
+    set $@Ambush10_Active, 0;
+    set $@Ambush10VictimID, 0;
+    end;
+
 OnWolvernDeath:
     set @MobID, 1089; // TODO: adapt
 
@@ -552,7 +618,8 @@ OnWolvernDeath:
 end;
 
 OnAmbush:
-    attachrid($@Ambush11VictimID);
+    if (attachrid($@Ambush11VictimID) == 0)
+        goto L_Abort;
     set @wolvern_amount, 10;   // has to be same value as in birrod.txt
     set $@Ambush11_Spawn, 4 + rand(3);
     message strcharinfo(0), "An ambush!";
@@ -560,6 +627,11 @@ OnAmbush:
     set $@Ambush11VictimID, 0;
     end;
 
+L_Abort:
+    set $@Ambush11_Active, 0;
+    set $@Ambush11VictimID, 0;
+    end;
+
 OnWolvernDeath:
     set @MobID, 1089; // TODO: adapt
 
@@ -600,7 +672,8 @@ OnWolvernDeath:
 end;
 
 OnAmbush:
-    attachrid($@Ambush12VictimID);
+    if (attachrid($@Ambush12VictimID) == 0)
+        goto L_Abort;
     set @wolvern_amount, 10;   // has to be same value as in birrod.txt
     set $@Ambush12_Spawn, 4 + rand(3);
     message strcharinfo(0), "An ambush!";
@@ -608,6 +681,11 @@ OnAmbush:
     set $@Ambush12VictimID, 0;
     end;
 
+L_Abort:
+    set $@Ambush12_Active, 0;
+    set $@Ambush12VictimID, 0;
+    end;
+
 OnWolvernDeath:
     set @MobID, 1089; // TODO: adapt
 
@@ -648,7 +726,8 @@ OnWolvernDeath:
 end;
 
 OnAmbush:
-    attachrid($@Ambush13VictimID);
+    if (attachrid($@Ambush13VictimID) == 0)
+        goto L_Abort;
     set @wolvern_amount, 10;   // has to be same value as in birrod.txt
     set $@Ambush13_Spawn, 4 + rand(3);
     message strcharinfo(0), "An ambush!";
@@ -656,6 +735,11 @@ OnAmbush:
     set $@Ambush13VictimID, 0;
     end;
 
+L_Abort:
+    set $@Ambush13_Active, 0;
+    set $@Ambush13VictimID, 0;
+    end;
+
 OnWolvernDeath:
     set @MobID, 1089; // TODO: adapt
 
@@ -696,7 +780,8 @@ OnWolvernDeath:
 end;
 
 OnAmbush:
-    attachrid($@Ambush14VictimID);
+    if (attachrid($@Ambush14VictimID) == 0)
+        goto L_Abort;
     set @wolvern_amount, 10;   // has to be same value as in birrod.txt
     set $@Ambush14_Spawn, 4 + rand(3);
     message strcharinfo(0), "An ambush!";
@@ -704,6 +789,11 @@ OnAmbush:
     set $@Ambush14VictimID, 0;
     end;
 
+L_Abort:
+    set $@Ambush14_Active, 0;
+    set $@Ambush14VictimID, 0;
+    end;
+
 OnWolvernDeath:
     set @MobID, 1089; // TODO: adapt
 
diff --git a/world/map/npc/042-1/hasan.txt b/world/map/npc/042-1/hasan.txt
index 1d5a67fd..5e9dfdc5 100644
--- a/world/map/npc/042-1/hasan.txt
+++ b/world/map/npc/042-1/hasan.txt
@@ -193,7 +193,8 @@ OnTimer5000:
         goto L_Clean;
     set $@ScorpionTimer, $@ScorpionTimer + 5;
     if ($@ScorpionTimer >= 300) goto L_Clean;
-    attachrid(getcharid(3,$@ScorpionFighter$));
+    if (attachrid(getcharid(3,$@ScorpionFighter$)) == 0)
+        end;
     if (PC_DIE_COUNTER > $@ScorpDeath) goto L_Clean;
     setnpctimer 0;
     end;
@@ -224,11 +225,11 @@ OnInit:
 
 OnTouch:
     end;
-    if ($@scorp && $@ScorpionFighter$ == strcharinfo(0)) 
+    if ($@scorp && $@ScorpionFighter$ == strcharinfo(0))
         end;
     if ((FLAGS & FLAG_TUTORIAL_DONE) || (hasan == 4))
         end;
-    if ($@scorp && $@ScorpionFighter$ != strcharinfo(0)) 
+    if ($@scorp && $@ScorpionFighter$ != strcharinfo(0))
         goto L_Scared;
 
 L_Normal:
-- 
cgit v1.2.3-70-g09d2