Add 'Successful finish' trigger
authorunc0rr
Thu, 27 Sep 2007 16:55:49 +0000
changeset 613 e8cf72d0e0f7
parent 612 333d095319de
child 614 0e04504bc140
Add 'Successful finish' trigger
hedgewars.kdevelop
hedgewars/CCHandlers.inc
hedgewars/uTriggers.pas
share/hedgewars/Data/Trainings/001_Shotgun.txt
--- a/hedgewars.kdevelop	Mon Sep 24 20:34:28 2007 +0000
+++ b/hedgewars.kdevelop	Thu Sep 27 16:55:49 2007 +0000
@@ -158,6 +158,14 @@
       <path>share/hedgewars/Data/Themes/xtheme/Makefile</path>
       <path>share/hedgewars/Makefile</path>
       <path>share/Makefile</path>
+      <path>Makefile</path>
+      <path>tools</path>
+      <path>tools/templates</path>
+      <path>tools/templates/main.cpp</path>
+      <path>tools/templates/mainform.cpp</path>
+      <path>tools/templates/mainform.h</path>
+      <path>tools/templates/pixlabel.cpp</path>
+      <path>tools/templates/pixlabel.h</path>
     </blacklist>
     <general>
       <activedir/>
--- a/hedgewars/CCHandlers.inc	Mon Sep 24 20:34:28 2007 +0000
+++ b/hedgewars/CCHandlers.inc	Thu Sep 27 16:55:49 2007 +0000
@@ -475,7 +475,7 @@
 c:= s[1];
 Delete(s, 1, 1);
 case c of
-  's': begin // s12345 1 1 33 0 0 123456
+  's': begin // sTYPE TICKS LIVES GEARTYPE X Y GEARTRIGGER
        SplitBySpace(s, tmp);
        val(s, ttype);
        SplitBySpace(tmp, s);
@@ -492,5 +492,9 @@
        val(s, geartrig);
        AddTriggerSpawner(ttype, Ticks, Lives, X, Y, TGearType(gt), geartrig);
        end;
+  'C': begin
+       val(s, ttype);
+       AddTriggerSuccess(ttype);
+       end;
   end
 end;
--- a/hedgewars/uTriggers.pas	Mon Sep 24 20:34:28 2007 +0000
+++ b/hedgewars/uTriggers.pas	Thu Sep 27 16:55:49 2007 +0000
@@ -23,9 +23,10 @@
 {$INCLUDE options.inc}
 const trigTurns = $80000001;
 
-type TTrigAction = (taSpawnGear);
+type TTrigAction = (taSpawnGear, taSuccessFinish);
 
 procedure AddTriggerSpawner(id, Ticks, Lives: Longword; X, Y: LongInt; GearType: TGearType; GearTriggerId: Longword);
+procedure AddTriggerSuccess(tId: Longword);
 procedure TickTrigger(id: Longword);
 
 implementation
@@ -44,14 +45,23 @@
                 end;
 var TriggerList: PTrigger = nil;
 
+function AddTrigger: PTrigger;
+var tmp: PTrigger;
+begin
+new(tmp);
+FillChar(tmp^, sizeof(TTrigger), 0);
+if TriggerList <> nil then tmp^.Next:= TriggerList;
+TriggerList:= tmp;
+AddTrigger:= tmp
+end;
+
 procedure AddTriggerSpawner(id, Ticks, Lives: Longword; X, Y: LongInt; GearType: TGearType; GearTriggerId: Longword);
 var tmp: PTrigger;
 begin
 if (Ticks = 0) or (Lives = 0) then exit;
 {$IFDEF DEBUGFILE}AddFileLog('Add spawner trigger: ' + inttostr(id) + ', gear triggers  ' + inttostr(GearTriggerId));{$ENDIF}
-new(tmp);
-FillChar(tmp^, sizeof(TTrigger), 0);
 
+tmp:= AddTrigger;
 tmp^.id:= id;
 tmp^.Ticks:= Ticks;
 tmp^.TicksPerLife:= Ticks;
@@ -60,9 +70,18 @@
 tmp^.X:= X;
 tmp^.Y:= Y;
 tmp^.SpawnGearType:= GearType;
-tmp^.SpawnGearTriggerId:= GearTriggerId;
-if TriggerList <> nil then tmp^.Next:= TriggerList;
-TriggerList:= tmp
+tmp^.SpawnGearTriggerId:= GearTriggerId
+end;
+
+procedure AddTriggerSuccess(tId: Longword);
+begin
+with AddTrigger^ do
+     begin
+     id:= tId;
+     Ticks:= 1;
+     TicksPerLife:= 1;
+     Action:= taSuccessFinish
+     end
 end;
 
 procedure TickTriggerT(Trigger: PTrigger);
@@ -72,6 +91,9 @@
      taSpawnGear: begin
                   FollowGear:= AddGear(X, Y, SpawnGearType, 0, _0, _0, 0);
                   FollowGear^.TriggerId:= SpawnGearTriggerId
+                  end;
+ taSuccessFinish: begin
+                  GameState:= gsExit
                   end
   end
 end;
--- a/share/hedgewars/Data/Trainings/001_Shotgun.txt	Mon Sep 24 20:34:28 2007 +0000
+++ b/share/hedgewars/Data/Trainings/001_Shotgun.txt	Thu Sep 27 16:55:49 2007 +0000
@@ -11,4 +11,5 @@
 addtrig s3 1 1 33 635 215 4
 addtrig s4 1 1 33 1450 275 5
 addtrig s5 1 1 33 220 535 6
-addtrig s6 1 1 33 1410 505 0
+addtrig s6 1 1 33 1410 505 7
+addtrig C7