Basic TARDIS implementation. Still needs proper animation, and probably a check to force reappearance on death of last team mate
authornemo
Mon, 02 May 2011 01:55:14 -0400
changeset 5197 9fa96377a69c
parent 5196 04ce9666a692
child 5198 6533e5450a21
Basic TARDIS implementation. Still needs proper animation, and probably a check to force reappearance on death of last team mate
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uGears.pas
hedgewars/uGearsRender.pas
hedgewars/uTypes.pas
hedgewars/uVariables.pas
--- a/hedgewars/GSHandlers.inc	Mon May 02 02:07:28 2011 +0200
+++ b/hedgewars/GSHandlers.inc	Mon May 02 01:55:14 2011 -0400
@@ -4870,16 +4870,16 @@
        not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2,
        TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2,
        sprHHTelepMask, 0, false, false) then
-    begin
+        begin
         HHGear^.Message := HHGear^.Message and not gmAttack;
         HHGear^.State := HHGear^.State and not gstAttacking;
         HHGear^.State := HHGear^.State or gstHHChooseTarget;
         DeleteGear(Gear);
         isCursorVisible := true;
         PlaySound(sndDenied)
-    end
+        end
     else
-    begin
+        begin
         DeleteCI(HHGear);
         SetAllHHToActive;
         PlaySound(sndPlaced);
@@ -4894,7 +4894,49 @@
         hog^.Gear:= nil;
         Gear^.Hedgehog := hog;
         Gear^.doStep := @doStepStructure;
-    end;
+        end;
     TargetPoint.X := NoPointX;
 end;
 
+procedure doStepTardis(Gear: PGear);
+(*var 
+    i, x, y: LongInt;
+    dX, dY: hwFloat;
+    Fire: PGear;
+    vg: PVisualGear;*)
+begin
+    if (Gear^.State and gstTmpFlag) = 0 then dec(Gear^.Timer);
+    if (Gear^.Timer = 0) and (CurAmmoGear = Gear) then
+        begin
+        if (CurrentHedgehog = nil) or (CurrentHedgehog^.Gear = nil) then 
+            begin
+            DeleteGear(Gear);
+            exit
+            end;
+        if Gear = CurAmmoGear then CurAmmoGear := nil;
+        Gear^.Hedgehog:= CurrentHedgehog;
+        RemoveGearFromList(CurrentHedgehog^.Gear);
+        CurrentHedgehog^.Gear^.Z := cHHZ;
+        CurrentHedgehog^.Gear^.Active := false;
+        CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State and not gstHHDriven;
+        CurrentHedgehog^.GearHidden:= CurrentHedgehog^.Gear;
+        CurrentHedgehog^.Gear:= nil;
+        Gear^.State:= Gear^.State or gstTmpFlag;
+        Gear^.Timer:= GameTicks + GetRandom(cHedgehogTurnTime*TeamsCount)+cHedgehogTurnTime;
+        end
+    else if (((Gear^.State and gstTmpFlag) <> 0) and (Gear^.Timer = GameTicks)) or SuddenDeath then
+        begin
+        if Gear^.Hedgehog <> nil then
+            begin
+            Gear^.Hedgehog^.Gear:= Gear^.Hedgehog^.GearHidden;
+            Gear^.Hedgehog^.GearHidden:= nil;
+            FindPlace(Gear^.Hedgehog^.Gear, false, 0, LAND_WIDTH,true);
+            InsertGearToList(Gear^.Hedgehog^.Gear);
+            Gear^.Hedgehog^.Gear^.State:= (Gear^.Hedgehog^.Gear^.State or gstTmpFlag or gstAttacked) and not gstHHDriven;
+            Gear^.Hedgehog^.Gear^.Timer:= $FF;
+            Gear^.Hedgehog^.Gear^.doStep:= @doStepHedgehogReturn;
+            SetAllHHToActive;
+            end;
+            DeleteGear(Gear)
+        end
+end;
--- a/hedgewars/HHHandlers.inc	Mon May 02 02:07:28 2011 +0200
+++ b/hedgewars/HHHandlers.inc	Mon May 02 01:55:14 2011 -0400
@@ -317,6 +317,7 @@
                    amDrillStrike: AddGear(CurWeapon^.Pos, 0, gtAirAttack, 3, _0, _0, CurWeapon^.Timer);
                    //amMelonStrike: AddGear(CurWeapon^.Pos, 0, gtAirAttack, 4, _0, _0, 0);
                      amStructure: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtStructure, 0, _0, _0, 0);
+                        amTardis: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtTardis, 0, _0, _0, 5000);
                   end;
 
         // Clear FollowGear if using on a rope/parachute/saucer etc so focus stays with the hog's movement
@@ -996,3 +997,13 @@
     doStepHedgehogDriven(Gear)
     end;
 end;
+
+procedure doStepHedgehogReturn(Gear: PGear);
+begin
+if (Gear^.Timer > 0) and ((GameTicks mod 20) = 0) then dec(Gear^.Timer)
+else if (Gear^.Timer = 0) then
+    begin
+    Gear^.doStep:= @doStepHedgehog;
+    Gear^.State:= Gear^.State and not gstTmpFlag;
+    end
+end;
--- a/hedgewars/uGears.pas	Mon May 02 02:07:28 2011 +0200
+++ b/hedgewars/uGears.pas	Mon May 02 01:55:14 2011 -0400
@@ -72,6 +72,7 @@
 procedure AfterAttack; forward;
 procedure HedgehogStep(Gear: PGear); forward;
 procedure doStepHedgehogMoving(Gear: PGear); forward;
+procedure doStepHedgehogReturn(Gear: PGear); forward;
 procedure HedgehogChAngle(HHGear: PGear); forward;
 procedure ShotgunShot(Gear: PGear); forward;
 procedure PickUp(HH, Gear: PGear); forward;
@@ -147,8 +148,8 @@
             @doStepSnowball,
             @doStepSnowflake,
             @doStepPlaceStructure,
-            @doStepLandGun
-            );
+            @doStepLandGun,
+            @doStepTardis);
 
 procedure InsertGearToList(Gear: PGear);
 var tmp, ptmp: PGear;
--- a/hedgewars/uGearsRender.pas	Mon May 02 02:07:28 2011 +0200
+++ b/hedgewars/uGearsRender.pas	Mon May 02 01:55:14 2011 -0400
@@ -227,6 +227,13 @@
         Tint($FF, $FF, $FF, $FF)
         end;
 
+    if  (CurAmmoGear <> nil) and 
+        (CurrentHedgehog^.Gear <> nil) and
+        (CurrentHedgehog^.Gear = Gear) and 
+        (CurAmmoGear^.Kind = gtTardis) then Tint($FF, $FF, $FF, CurAmmoGear^.Timer div 20)
+    // probably will need a new flag for this
+    else if (Gear^.State and gstTmpFlag <> 0) then Tint($FF, $FF, $FF, $FF-Gear^.Timer);
+
     if ((Gear^.State and gstWinner) <> 0) and
     ((CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtPickHammer)) then
         begin
--- a/hedgewars/uTypes.pas	Mon May 02 02:07:28 2011 +0200
+++ b/hedgewars/uTypes.pas	Mon May 02 01:55:14 2011 -0400
@@ -97,7 +97,7 @@
             gtSniperRifleShot, gtJetpack, gtMolotov, gtExplosives, gtBirdy, // 45
             gtEgg, gtPortal, gtPiano, gtGasBomb, gtSineGunShot, gtFlamethrower, // 51
             gtSMine, gtPoisonCloud, gtHammer, gtHammerHit, gtResurrector, // 56
-            gtNapalmBomb, gtSnowball, gtFlake, gtStructure, gtLandGun); // 61
+            gtNapalmBomb, gtSnowball, gtFlake, gtStructure, gtLandGun, gtTardis); // 62
 
     // Gears that are _only_ of visual nature (e.g. background stuff, visual effects, speechbubbles, etc.)
     TVisualGearType = (vgtFlake, vgtCloud, vgtExplPart, vgtExplPart2, vgtFire,
--- a/hedgewars/uVariables.pas	Mon May 02 02:07:28 2011 +0200
+++ b/hedgewars/uVariables.pas	Mon May 02 01:55:14 2011 -0400
@@ -2041,8 +2041,6 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_ForwMsgs or
                           ammoprop_NoCrosshair or
-                          ammoprop_NeedTarget or
-                          ammoprop_AttackingPut or
                           ammoprop_Utility or
                           ammoprop_DontHold;
                 Count: 2;