nemo:
authorunc0rr
Thu, 05 Mar 2009 14:54:02 +0000
changeset 1861 98de5dc5fda7
parent 1860 ce140b2b928a
child 1862 7f303aa066da
nemo: - Utility box - Some bugfixes
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uConsts.pas
hedgewars/uGears.pas
hedgewars/uLandGraphics.pas
hedgewars/uMisc.pas
share/hedgewars/Data/Graphics/Utility.png
--- a/hedgewars/GSHandlers.inc	Wed Mar 04 16:35:36 2009 +0000
+++ b/hedgewars/GSHandlers.inc	Thu Mar 05 14:54:02 2009 +0000
@@ -48,7 +48,7 @@
 	else
 		PlaySound(sndOw1, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
 
-	dmg:= 1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70);
+	dmg:= modifyDamage(1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70));
 	inc(Gear^.Damage, dmg);
 	AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, dmg, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color);
 	end
--- a/hedgewars/HHHandlers.inc	Wed Mar 04 16:35:36 2009 +0000
+++ b/hedgewars/HHHandlers.inc	Thu Mar 05 14:54:02 2009 +0000
@@ -271,6 +271,7 @@
 begin
 Gear^.Message:= gm_Destroy;
 case Gear^.Pos of
+       posCaseUtility, 
        posCaseAmmo: begin
                     a:= TAmmoType(Gear^.State);
                     AddAmmo(PHedgehog(HH^.Hedgehog)^, a);
--- a/hedgewars/uConsts.pas	Wed Mar 04 16:35:36 2009 +0000
+++ b/hedgewars/uConsts.pas	Thu Mar 05 14:54:02 2009 +0000
@@ -50,7 +50,7 @@
 			sprCakeWalk, sprCakeDown, sprAMAmmosBW, sprWatermelon,
 			sprEvilTrace, sprHellishBomb, sprSeduction, sprDress,
 			sprCensored, sprDrill, sprHandDrill, sprHandBallgun, sprBalls,
-			sprPlane, sprHandPlane);
+			sprPlane, sprHandPlane, sprUtility);
 
 	TGearType = (gtAmmo_Bomb, gtHedgehog, gtAmmo_Grenade, gtHealthTag, // 3
 			gtGrave, gtUFO, gtShotgunShot, gtPickHammer, gtRope, // 8
@@ -246,6 +246,7 @@
 
 	posCaseAmmo    = $00000001;
 	posCaseHealth  = $00000002;
+	posCaseUtility = $00000004;
 
 	NoPointX = Low(LongInt);
 
@@ -471,7 +472,9 @@
 			(FileName:      'RCPlane'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
 			Width:  32; Height: 32; saveSurf: false),// sprPlane
 			(FileName:    'amRCPlane'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
-			Width:  32; Height: 32; saveSurf: false) // sprHandPlane
+			Width:  32; Height: 32; saveSurf: false), // sprHandPlane
+			(FileName:       'Utility'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
+			Width:  40; Height: 32; saveSurf: false) // sprUtility
 			);
 
 	Wavez: array [TWave] of record
@@ -1170,7 +1173,7 @@
 			PosSprite: sprWater),
 			(NameId: sidLowGravity;
 			NameTex: nil;
-			Probability: 200;
+			Probability: 20;
 			NumberInCase: 1;
 			Ammo: (Propz: ammoprop_NoCrosshair or
 						  ammoprop_DontHold or
@@ -1190,7 +1193,7 @@
 			PosSprite: sprWater),
 			(NameId: sidExtraDamage;
 			NameTex: nil;
-			Probability: 200;
+			Probability: 15;
 			NumberInCase: 1;
 			Ammo: (Propz: ammoprop_NoCrosshair or
 						  ammoprop_DontHold or
@@ -1210,7 +1213,7 @@
 			PosSprite: sprWater),
 			(NameId: sidInvulnerable;
 			NameTex: nil;
-			Probability: 200;
+			Probability: 20;
 			NumberInCase: 1;
 			Ammo: (Propz: ammoprop_NoCrosshair or
 						  ammoprop_DontHold or
@@ -1230,7 +1233,7 @@
 			PosSprite: sprWater),
 			(NameId: sidExtraTime;
 			NameTex: nil;
-			Probability: 200;
+			Probability: 30;
 			NumberInCase: 1;
 			Ammo: (Propz: ammoprop_NoCrosshair or
 						  ammoprop_DontHold or
@@ -1250,7 +1253,7 @@
 			PosSprite: sprWater),
 			(NameId: sidLaserSight;
 			NameTex: nil;
-			Probability: 200;
+			Probability: 15;
 			NumberInCase: 1;
 			Ammo: (Propz: ammoprop_NoCrosshair or
 						  ammoprop_DontHold or
--- a/hedgewars/uGears.pas	Wed Mar 04 16:35:36 2009 +0000
+++ b/hedgewars/uGears.pas	Thu Mar 05 14:54:02 2009 +0000
@@ -430,27 +430,27 @@
 while Gear <> nil do
 	begin
 	if Gear^.Kind = gtHedgehog then
-        begin
+		begin
 		if (Gear^.Damage <> 0) and
 		(not Gear^.Invulnerable) then
-		    begin
-            CheckNoDamage:= false;
-            uStats.HedgehogDamaged(Gear);
-            dmg:= HwRound(int2HwFloat(Gear^.Damage) * cDamageModifier);
-            if Gear^.Health < dmg then
-                Gear^.Health:= 0
-            else
-                dec(Gear^.Health, dmg);
+			begin
+			CheckNoDamage:= false;
+			uStats.HedgehogDamaged(Gear);
+			dmg:= Gear^.Damage;
+			if Gear^.Health < dmg then
+				Gear^.Health:= 0
+			else
+				dec(Gear^.Health, dmg);
 
-            AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) - cHHRadius - 12,
-                    gtHealthTag, dmg, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog;
+			AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) - cHHRadius - 12,
+					gtHealthTag, dmg, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog;
 
-            RenderHealth(PHedgehog(Gear^.Hedgehog)^);
-            RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team);
+			RenderHealth(PHedgehog(Gear^.Hedgehog)^);
+			RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team);
 
-		    end;
-	    Gear^.Damage:= 0;
-        end;
+			end;
+		Gear^.Damage:= 0;
+		end;
 	Gear:= Gear^.NextGear
 	end;
 end;
@@ -1044,8 +1044,8 @@
 						// reached edge of land. assume infinite beam. Extend it way out past camera
 						if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then
 							begin
-							lx:= lx + dx * (LAND_WIDTH div 4);
-							ly:= ly + dy * (LAND_WIDTH div 4)
+							tx:= round(lx + dx * (LAND_WIDTH div 4));
+							ty:= round(ly + dy * (LAND_WIDTH div 4));
 							end;
 						
 						//if (abs(lx-tx)>8) or (abs(ly-ty)>8) then
@@ -1208,6 +1208,9 @@
                                         if i > 12 then i:= 0;
                                         DrawSprite(sprFAid, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, i);
                                         end;
+                         posCaseUtility: begin
+                                        DrawSprite(sprUtility, hwRound(Gear^.X) - 20 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0);
+                                        end;
                          end;
         gtDynamite: DrawSprite2(sprDynamite, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, Gear^.Tag and 1, Gear^.Tag shr 1);
      gtClusterBomb: DrawRotated(sprClusterBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
@@ -1287,7 +1290,7 @@
 	if (dmg > 1) and
 		((Gear^.State and gstNoDamage) = 0) then
 		begin
-		dmg:= min(dmg div 2, Radius);
+		dmg:= modifyDamage(min(dmg div 2, Radius));
 		case Gear^.Kind of
 			gtHedgehog,
 				gtMine,
@@ -1337,7 +1340,7 @@
 t:= GearsList;
 while t <> nil do
 	begin
-	dmg:= min(Gear^.Radius + t^.Radius - hwRound(Distance(Gear^.X - t^.X, Gear^.Y - t^.Y)), 25);
+	dmg:= modifyDamage(min(Gear^.Radius + t^.Radius - hwRound(Distance(Gear^.X - t^.X, Gear^.Y - t^.Y)), 25));
 	if dmg > 0 then
 	case t^.Kind of
 		gtHedgehog,
@@ -1375,6 +1378,8 @@
 t:= CheckGearsCollision(Ammo);
 i:= t^.Count;
 
+Damage:= modifyDamage(Damage);
+
 while i > 0 do
 	begin
 	dec(i);
@@ -1553,27 +1558,49 @@
    (getrandom(cCaseFactor) <> 0) then exit;
 
 FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0);
-case getrandom(2) of
-     0: begin
+case getrandom(20) of
+     0..6: begin
         FollowGear^.Health:= 25;
         FollowGear^.Pos:= posCaseHealth
         end;
-     1: begin
+     7..13: begin
         t:= 0;
         for i:= Low(TAmmoType) to High(TAmmoType) do
-            inc(t, Ammoz[i].Probability);
+            if (Ammoz[i].Ammo.Propz and ammoprop_Utility) = 0 then
+                inc(t, Ammoz[i].Probability);
         t:= GetRandom(t);
         i:= Low(TAmmoType);
-        dec(t, Ammoz[i].Probability);
+        if (Ammoz[i].Ammo.Propz and ammoprop_Utility) = 0 then
+            dec(t, Ammoz[i].Probability);
         while t >= 0 do
           begin
           inc(i);
-          dec(t, Ammoz[i].Probability)
+          if (Ammoz[i].Ammo.Propz and ammoprop_Utility) = 0 then
+              dec(t, Ammoz[i].Probability)
           end;
         PlaySound(sndReinforce, false, CurrentTeam^.voicepack);
         FollowGear^.Pos:= posCaseAmmo;
         FollowGear^.State:= Longword(i)
         end;
+     14..19: begin 
+        t:= 0;
+        for i:= Low(TAmmoType) to High(TAmmoType) do
+            if (Ammoz[i].Ammo.Propz and ammoprop_Utility) <> 0 then
+                inc(t, Ammoz[i].Probability);
+        t:= GetRandom(t);
+        i:= Low(TAmmoType);
+        if (Ammoz[i].Ammo.Propz and ammoprop_Utility) <> 0 then
+            dec(t, Ammoz[i].Probability);
+        while t >= 0 do
+          begin
+          inc(i);
+          if (Ammoz[i].Ammo.Propz and ammoprop_Utility) <> 0 then
+              dec(t, Ammoz[i].Probability)
+          end;
+        PlaySound(sndReinforce, false, CurrentTeam^.voicepack);
+        FollowGear^.Pos:= posCaseUtility;
+        FollowGear^.State:= Longword(i)
+        end;
      end;
  
 FindPlace(FollowGear, true, 0, LAND_WIDTH)
--- a/hedgewars/uLandGraphics.pas	Wed Mar 04 16:35:36 2009 +0000
+++ b/hedgewars/uLandGraphics.pas	Thu Mar 05 14:54:02 2009 +0000
@@ -67,26 +67,34 @@
    begin
    if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
       for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
-          if (Land[y + dy, i] > 0) then dec(Land[y + dy, i]); // check > 0 because explosion can erase collision data
+          if (Land[y + dy, i] > 0) and (Land[y + dy, i] < 256) then dec(Land[y + dy, i]); // check > 0 because explosion can erase collision data
    if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
       for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
-          if (Land[y - dy, i] > 0) then dec(Land[y - dy, i]);
+          if (Land[y - dy, i] > 0) and (Land[y - dy, i] < 256) then dec(Land[y - dy, i]);
    if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
       for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
-          if (Land[y + dx, i] > 0) then dec(Land[y + dx, i]);
+          if (Land[y + dx, i] > 0) and (Land[y + dx, i] < 256) then dec(Land[y + dx, i]);
    if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
       for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
-          if (Land[y - dx, i] > 0) then dec(Land[y - dx, i]);
+          if (Land[y - dx, i] > 0) and (Land[y - dx, i] < 256) then dec(Land[y - dx, i]);
    end else
    begin
    if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
-      for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do inc(Land[y + dy, i]);
+      for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do 
+          if (Land[y + dy, i] < 256) then
+              inc(Land[y + dy, i]);
    if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
-      for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do inc(Land[y - dy, i]);
+      for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do 
+          if (Land[y - dy, i] < 256) then
+              inc(Land[y - dy, i]);
    if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
-      for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do inc(Land[y + dx, i]);
+      for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
+          if (Land[y + dx, i] < 256) then
+              inc(Land[y + dx, i]);
    if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
-      for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do inc(Land[y - dx, i]);
+      for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
+          if (Land[y - dx, i] < 256) then
+              inc(Land[y - dx, i]);
    end
 end;
 
--- a/hedgewars/uMisc.pas	Wed Mar 04 16:35:36 2009 +0000
+++ b/hedgewars/uMisc.pas	Thu Mar 05 14:54:02 2009 +0000
@@ -134,6 +134,7 @@
 function  toPowerOf2(i: Longword): Longword;
 function DecodeBase64(s: shortstring): shortstring;
 procedure MakeScreenshot(s: shortstring);
+function modifyDamage(dmg: Longword): Longword;
 
 var CursorPoint: TPoint;
     TargetPoint: TPoint = (X: NoPointX; Y: 0);
@@ -404,6 +405,11 @@
 FreeMem(p)
 end;
 
+function modifyDamage(dmg: Longword): Longword;
+begin
+ModifyDamage:= hwRound(int2HwFloat(dmg) * cDamageModifier)
+end;
+
 {$IFDEF DEBUGFILE}
 procedure AddFileLog(s: shortstring);
 begin
Binary file share/hedgewars/Data/Graphics/Utility.png has changed