# HG changeset patch
# User unc0rr
# Date 1190912149 0
# Node ID e8cf72d0e0f7ffa1222947b95d34f6b7e38dc69c
# Parent 333d095319dee7e32b322154f9f9b8e64298777d
Add 'Successful finish' trigger
diff -r 333d095319de -r e8cf72d0e0f7 hedgewars.kdevelop
--- 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 @@
share/hedgewars/Data/Themes/xtheme/Makefile
share/hedgewars/Makefile
share/Makefile
+ Makefile
+ tools
+ tools/templates
+ tools/templates/main.cpp
+ tools/templates/mainform.cpp
+ tools/templates/mainform.h
+ tools/templates/pixlabel.cpp
+ tools/templates/pixlabel.h
diff -r 333d095319de -r e8cf72d0e0f7 hedgewars/CCHandlers.inc
--- 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;
diff -r 333d095319de -r e8cf72d0e0f7 hedgewars/uTriggers.pas
--- 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;
diff -r 333d095319de -r e8cf72d0e0f7 share/hedgewars/Data/Trainings/001_Shotgun.txt
--- 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