Teleportation tool
authorunc0rr
Thu, 24 May 2007 19:41:51 +0000
changeset 520 e83dfb7ffead
parent 519 981df6f6e2a9
child 521 bc8fd78d7598
Teleportation tool
hedgewars/CCHandlers.inc
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uAIAmmoTests.pas
hedgewars/uConsts.pas
hedgewars/uGears.pas
hedgewars/uLandGraphics.pas
hedgewars/uLocale.pas
share/hedgewars/Data/Graphics/CMakeLists.txt
share/hedgewars/Data/Graphics/hhMask.png
share/hedgewars/Data/Locale/en.txt
share/hedgewars/Data/Locale/ru.txt
--- a/hedgewars/CCHandlers.inc	Thu May 24 18:48:35 2007 +0000
+++ b/hedgewars/CCHandlers.inc	Thu May 24 19:41:51 2007 +0000
@@ -53,7 +53,7 @@
 if isDeveloperMode then
    begin
    inc(TeamsCount);
-   ParseCommand('ammstore 939192942219121033', true);
+   ParseCommand('ammstore 9391929422191210332', true);
    TryDo(TeamsCount <= 5, 'Too many teams', true);
    AddTeam
    end;
--- a/hedgewars/GSHandlers.inc	Thu May 24 18:48:35 2007 +0000
+++ b/hedgewars/GSHandlers.inc	Thu May 24 19:41:51 2007 +0000
@@ -1087,7 +1087,7 @@
 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
 if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2,
                       TargetPoint.Y - SpritesData[sprAmGirder].Height div 2,
-                      sprAmGirder, Gear^.State) then
+                      sprAmGirder, Gear^.State, true) then
         begin
         HHGear^.Message:= HHGear^.Message and not gm_Attack;
         HHGear^.State:= HHGear^.State and not gstAttacking;
@@ -1101,3 +1101,31 @@
         end;
 TargetPoint.X:= NoPointX
 end;
+
+////////////////////////////////////////////////////////////////////////////////
+
+procedure doStepTeleport(Gear: PGear);
+var HHGear: PGear;
+begin
+AllInactive:= false;
+
+HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
+if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2,
+                      TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2,
+                      sprHHTelepMask, 0, false) then
+        begin
+        HHGear^.Message:= HHGear^.Message and not gm_Attack;
+        HHGear^.State:= HHGear^.State and not gstAttacking;
+        HHGear^.State:= HHGear^.State or gstHHChooseTarget;
+        DeleteGear(Gear);
+        isCursorVisible:= true
+        end
+   else begin
+        DeleteCI(HHGear);
+        HHGear^.X:= int2hwFloat(TargetPoint.X);
+        HHGear^.Y:= int2hwFloat(TargetPoint.Y);
+        DeleteGear(Gear);
+        AfterAttack
+        end;
+TargetPoint.X:= NoPointX
+end;
--- a/hedgewars/HHHandlers.inc	Thu May 24 18:48:35 2007 +0000
+++ b/hedgewars/HHHandlers.inc	Thu May 24 19:41:51 2007 +0000
@@ -72,6 +72,7 @@
                    amMineStrike: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 1, _0, _0, 0);
                     amBlowTorch: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtBlowTorch, 0, SignAs(_0_5, dX), _0, 0);
                        amGirder: CurAmmoGear:= AddGear(0, 0, gtGirder, Ammo^[CurSlot, CurAmmo].Pos, _0, _0, 0);
+                     amTeleport: CurAmmoGear:= AddGear(0, 0, gtTeleport, 0, _0, _0, 0);
                   end;
         Power:= 0;
         if CurAmmoGear <> nil then
--- a/hedgewars/uAIAmmoTests.pas	Thu May 24 18:48:35 2007 +0000
+++ b/hedgewars/uAIAmmoTests.pas	Thu May 24 19:41:51 2007 +0000
@@ -47,7 +47,8 @@
 {amAirAttack}     nil,
 {amMineStrike}    nil,
 {amBlowTorch}     nil,
-{amGirder}        nil
+{amGirder}        nil,
+{amTeleport}      nil
                   );
 
 const BadTurn = Low(LongInt) div 4;
--- a/hedgewars/uConsts.pas	Thu May 24 18:48:35 2007 +0000
+++ b/hedgewars/uConsts.pas	Thu May 24 19:41:51 2007 +0000
@@ -39,14 +39,15 @@
                    sprClusterBomb, sprClusterParticle, sprFlame, sprHorizont,
                    sprSky, sprAMBorders, sprAMSlot, sprAMSlotName, sprAMAmmos,
                    sprAMSlotKeys, sprAMSelection, sprFinger, sprAirBomb,
-                   sprAirplane, sprAmAirplane, sprAmGirder);
+                   sprAirplane, sprAmAirplane, sprAmGirder, sprHHTelepMask);
 
      TGearType  = (gtCloud, gtAmmo_Bomb, gtHedgehog, gtAmmo_Grenade, gtHealthTag,
                    gtGrave, gtUFO, gtShotgunShot, gtPickHammer, gtRope,
                    gtSmokeTrace, gtExplosion, gtMine, gtCase, gtDEagleShot, gtDynamite,
                    gtTeamHealthSorter, gtClusterBomb, gtCluster, gtShover, gtFlame,
                    gtFirePunch, gtATStartGame, gtATSmoothWindCh, gtATFinishGame,
-                   gtParachute, gtAirAttack, gtAirBomb, gtBlowTorch, gtGirder);
+                   gtParachute, gtAirAttack, gtAirBomb, gtBlowTorch, gtGirder,
+                   gtTeleport);
 
      TGearsType = set of TGearType;
 
@@ -57,7 +58,7 @@
      TAmmoType  = (amGrenade, amClusterBomb, amBazooka, amUFO, amShotgun, amPickHammer,
                    amSkip, amRope, amMine, amDEagle, amDynamite, amFirePunch,
                    amBaseballBat, amParachute, amAirAttack, amMineStrike, amBlowTorch,
-                   amGirder);
+                   amGirder, amTeleport);
 
      THWFont    = (fnt16, fntBig);
 
@@ -318,7 +319,9 @@
                      (FileName:'amAirplane'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
                      Width:  64; Height: 32; hasAlpha:  true),// sprAirplane
                      (FileName:  'amGirder'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
-                     Width: 160; Height:160; hasAlpha: false) // sprAmGirder
+                     Width: 160; Height:160; hasAlpha: false),// sprAmGirder
+                     (FileName:    'hhMask'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+                     Width:  32; Height: 32; hasAlpha: false) // sprHHTelepMask
                      );
       Soundz: array[TSound] of record
                                        FileName: String[31];
@@ -639,7 +642,24 @@
                                    minAngle: 0;
                                    maxAngle: 0;
                                    PosCount: 8;
-                                   PosSprite: sprAmGirder));
+                                   PosSprite: sprAmGirder),
+                                  (NameId: sidTeleport;
+                                   Probability: 400;
+                                   NumberInCase: 1;
+                                   Ammo: (Propz: ammoprop_NoCrosshair or
+                                                 ammoprop_NeedTarget or
+                                                 ammoprop_AttackingPut;
+                                          Count: 2;
+                                          NumPerTurn: 0;
+                                          Timer: 0;
+                                          Pos: 0;
+                                          AmmoType: amTeleport);
+                                   Slot: 7;
+                                   TimeAfterTurn: 0;
+                                   minAngle: 0;
+                                   maxAngle: 0;
+                                   PosCount: 1;
+                                   PosSprite: sprWater));
 
 implementation
 
--- a/hedgewars/uGears.pas	Thu May 24 18:48:35 2007 +0000
+++ b/hedgewars/uGears.pas	Thu May 24 19:41:51 2007 +0000
@@ -126,7 +126,8 @@
                                                                @doStepAirAttack,
                                                                @doStepAirBomb,
                                                                @doStepBlowTorch,
-                                                               @doStepGirder
+                                                               @doStepGirder,
+                                                               @doStepTeleport
                                                                );
 
 procedure InsertGearToList(Gear: PGear);
--- a/hedgewars/uLandGraphics.pas	Thu May 24 18:48:35 2007 +0000
+++ b/hedgewars/uLandGraphics.pas	Thu May 24 19:41:51 2007 +0000
@@ -32,7 +32,7 @@
 procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword);
 procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean);
 
-function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt): boolean;
+function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean;
 
 implementation
 uses SDLh, uMisc, uLand;
@@ -320,7 +320,7 @@
    SDL_UnlockSurface(LandSurface)
 end;
 
-function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt): boolean;
+function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean;
 var X, Y, bpp, h, w: LongInt;
     p: PByteArray;
     r, rr: TSDL_Rect;
@@ -384,6 +384,9 @@
             end;
      end;
 
+TryPlaceOnLand:= true;
+if not doPlace then exit;
+
 // Checked, now place
 p:= @(PByteArray(Image^.pixels)^[Image^.pitch * Frame * h]);
 case bpp of
@@ -418,9 +421,7 @@
 r.h:= SpritesData[Obj].Height;
 rr.x:= cpX;
 rr.y:= cpY;
-SDL_UpperBlit(Image, @r, LandSurface, @rr);
-
-TryPlaceOnLand:= true
+SDL_UpperBlit(Image, @r, LandSurface, @rr)
 end;
 
 
--- a/hedgewars/uLocale.pas	Thu May 24 18:48:35 2007 +0000
+++ b/hedgewars/uLocale.pas	Thu May 24 19:41:51 2007 +0000
@@ -22,7 +22,7 @@
                    sidPickHammer, sidSkip, sidRope, sidMine, sidDEagle,
                    sidDynamite, sidBaseballBat, sidFirePunch, sidSeconds,
                    sidParachute, sidAirAttack, sidMineStrike, sidBlowTorch,
-                   sidGirder);
+                   sidGirder, sidTeleport);
 
      TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume, sidPaused);
 
--- a/share/hedgewars/Data/Graphics/CMakeLists.txt	Thu May 24 18:48:35 2007 +0000
+++ b/share/hedgewars/Data/Graphics/CMakeLists.txt	Thu May 24 19:41:51 2007 +0000
@@ -24,11 +24,13 @@
 	Girder.png
 	Grenade.png
 	Hedgehog.png
+	hhMask.png
 	Lag.png
 	MineOff.png
 	MineOn.png
 	Power.png
 	PowerBar.png
+	Progress.png
 	RopeHook.png
 	RopeNode.png
 	SmokeTrace.png
Binary file share/hedgewars/Data/Graphics/hhMask.png has changed
--- a/share/hedgewars/Data/Locale/en.txt	Thu May 24 18:48:35 2007 +0000
+++ b/share/hedgewars/Data/Locale/en.txt	Thu May 24 19:41:51 2007 +0000
@@ -19,6 +19,7 @@
 00:16=Mine Strike
 00:17=Blow Torch
 00:18=Construction
+00:19=Teleportation
 
 01:00=Let's fight!
 01:01=Round draw
--- a/share/hedgewars/Data/Locale/ru.txt	Thu May 24 18:48:35 2007 +0000
+++ b/share/hedgewars/Data/Locale/ru.txt	Thu May 24 19:41:51 2007 +0000
@@ -19,6 +19,7 @@
 00:16=Минный удар
 00:17=Бур
 00:18=Конструктор
+00:19=Телепортация
 
 01:00=Вперёд к победе!
 01:01=Ничья