# HG changeset patch # User nemo # Date 1252439089 0 # Node ID babe1a55e284ee2b65319f27588c3b8e46924d67 # Parent b756432fd4221d75b2d41ec26c809d07b7398308 Add an empty weapon to avoid selection of weapons which aren't yet ready. Might all be useful to switch to amNothing in certain situations, like after using up all ropes, instead of bazooka. diff -r b756432fd422 -r babe1a55e284 hedgewars/uAIAmmoTests.pas --- a/hedgewars/uAIAmmoTests.pas Tue Sep 08 16:58:43 2009 +0000 +++ b/hedgewars/uAIAmmoTests.pas Tue Sep 08 19:44:49 2009 +0000 @@ -45,6 +45,7 @@ const AmmoTests: array[TAmmoType] of TAmmoTest = ( + (proc: nil; flags: 0), // amNothing (proc: @TestGrenade; flags: 0), // amGrenade (proc: nil; flags: 0), // amClusterBomb (proc: @TestBazooka; flags: 0), // amBazooka diff -r b756432fd422 -r babe1a55e284 hedgewars/uAmmos.pas --- a/hedgewars/uAmmos.pas Tue Sep 08 16:58:43 2009 +0000 +++ b/hedgewars/uAmmos.pas Tue Sep 08 19:44:49 2009 +0000 @@ -63,7 +63,7 @@ ammos: TAmmoCounts; substr: shortstring; // TEMPORARY begin -TryDo(byte(s[0]) = byte(ord(High(TAmmoType)) + 1), 'Invalid ammo scheme (incompatible frontend)', true); +TryDo(byte(s[0]) = byte(ord(High(TAmmoType))), 'Invalid ammo scheme (incompatible frontend)', true); // FIXME - TEMPORARY hardcoded check on shoppa pending creation of probability editor substr:= Copy(s,1,15); @@ -71,7 +71,7 @@ (substr = '000000990000000') then shoppa:= true; for a:= Low(TAmmoType) to High(TAmmoType) do - if (ord(a) > 14) and (s[ord(a)+1] <> '0') then shoppa:= false; // TEMPORARY etc - this just avoids updating every time new wep is added + if (ord(a) > 14) and (s[ord(a)] <> '0') then shoppa:= false; // TEMPORARY etc - this just avoids updating every time new wep is added inc(StoreCnt); TryDo(StoreCnt <= cMaxHHs, 'Ammo stores overflow', true); @@ -79,32 +79,35 @@ for a:= Low(TAmmoType) to High(TAmmoType) do begin - cnt:= byte(s[ord(a) + 1]) - byte('0'); - if cnt = 9 then - begin - cnt:= AMMO_INFINITE; - Ammoz[a].Probability:= 0 - end; - if ((a = amLowGravity) and ((GameFlags and gfLowGravity) <> 0)) or - ((a = amInvulnerable) and ((GameFlags and gfInvulnerable) <> 0)) or - ((a = amLaserSight) and ((GameFlags and gfLaserSight) <> 0)) or - ((a = amVampiric) and ((GameFlags and gfVampiric) <> 0)) then + if a <> amNothing then begin - cnt:= 0; - Ammoz[a].Probability:= 0 - end - else if shoppa then // FIXME - TEMPORARY REMOVE WHEN CRATE PROBABILITY IS ADDED - if cnt <> AMMO_INFINITE then + cnt:= byte(s[ord(a)]) - byte('0'); + if cnt = 9 then + begin + cnt:= AMMO_INFINITE; + Ammoz[a].Probability:= 0 + end; + if ((a = amLowGravity) and ((GameFlags and gfLowGravity) <> 0)) or + ((a = amInvulnerable) and ((GameFlags and gfInvulnerable) <> 0)) or + ((a = amLaserSight) and ((GameFlags and gfLaserSight) <> 0)) or + ((a = amVampiric) and ((GameFlags and gfVampiric) <> 0)) then begin - if a = amGirder then - Ammoz[a].Probability:= 0 - else + cnt:= 0; + Ammoz[a].Probability:= 0 + end + else if shoppa then // FIXME - TEMPORARY REMOVE WHEN CRATE PROBABILITY IS ADDED + if cnt <> AMMO_INFINITE then begin - Ammoz[a].Probability:= 100; - Ammoz[a].NumberInCase:= 1; - end - end; - ammos[a]:= cnt + if a = amGirder then + Ammoz[a].Probability:= 0 + else + begin + Ammoz[a].Probability:= 100; + Ammoz[a].NumberInCase:= 1; + end + end; + ammos[a]:= cnt + end end; FillAmmoStore(StoresList[Pred(StoreCnt)], ammos) @@ -238,12 +241,15 @@ with Ammo^[CurSlot, CurAmmo] do begin - s:= trammo[Ammoz[AmmoType].NameId]; - if (Count <> AMMO_INFINITE) and not (Hedgehog.Team^.ExtDriven or (Hedgehog.BotLevel > 0)) then - s:= s + ' (' + IntToStr(Count) + ')'; - if (Propz and ammoprop_Timerable) <> 0 then - s:= s + ', ' + inttostr(Timer div 1000) + ' ' + trammo[sidSeconds]; - AddCaption(s, Team^.Clan^.Color, capgrpAmmoinfo); + if AmmoType <> amNothing then + begin + s:= trammo[Ammoz[AmmoType].NameId]; + if (Count <> AMMO_INFINITE) and not (Hedgehog.Team^.ExtDriven or (Hedgehog.BotLevel > 0)) then + s:= s + ' (' + IntToStr(Count) + ')'; + if (Propz and ammoprop_Timerable) <> 0 then + s:= s + ', ' + inttostr(Timer div 1000) + ' ' + trammo[sidSeconds]; + AddCaption(s, Team^.Clan^.Color, capgrpAmmoinfo); + end; if (Propz and ammoprop_NeedTarget) <> 0 then begin Gear^.State:= Gear^.State or gstHHChooseTarget; diff -r b756432fd422 -r babe1a55e284 hedgewars/uConsts.pas --- a/hedgewars/uConsts.pas Tue Sep 08 16:58:43 2009 +0000 +++ b/hedgewars/uConsts.pas Tue Sep 08 19:44:49 2009 +0000 @@ -95,7 +95,7 @@ sndRideOfTheValkyries, sndDenied, sndPlaced, sndBaseballBat, sndVaporize, sndWarp, sndSuddenDeath, sndMortar, sndShutter); - TAmmoType = (amGrenade, amClusterBomb, amBazooka, amUFO, amShotgun, amPickHammer, + TAmmoType = (amNothing, amGrenade, amClusterBomb, amBazooka, amUFO, amShotgun, amPickHammer, amSkip, amRope, amMine, amDEagle, amDynamite, amFirePunch, amWhip, amBaseballBat, amParachute, amAirAttack, amMineStrike, amBlowTorch, amGirder, amTeleport, amSwitch, amMortar, amKamikaze, amCake, @@ -681,6 +681,26 @@ PosCount: Longword; PosSprite: TSprite; end = ( + (NameId: sidNothing; + NameTex: nil; + Probability: 0; + NumberInCase: 0; + Ammo: (Propz: ammoprop_NoCrosshair or + ammoprop_DontHold or + ammoprop_Utility; + Count: AMMO_INFINITE; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amNothing); + Slot: 0; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: false; + SkipTurns: 9999; + PosCount: 1; + PosSprite: sprWater), (NameId: sidGrenade; NameTex: nil; Probability: 0; diff -r b756432fd422 -r babe1a55e284 hedgewars/uLocale.pas --- a/hedgewars/uLocale.pas Tue Sep 08 16:58:43 2009 +0000 +++ b/hedgewars/uLocale.pas Tue Sep 08 19:44:49 2009 +0000 @@ -18,7 +18,7 @@ unit uLocale; interface -type TAmmoStrId = (sidGrenade, sidClusterBomb, sidBazooka, sidUFO, sidShotgun, +type TAmmoStrId = (sidNothing, sidGrenade, sidClusterBomb, sidBazooka, sidUFO, sidShotgun, sidPickHammer, sidSkip, sidRope, sidMine, sidDEagle, sidDynamite, sidBaseballBat, sidFirePunch, sidSeconds, sidParachute, sidAirAttack, sidMineStrike, sidBlowTorch, @@ -56,7 +56,7 @@ first: array[TEventId] of boolean; e: TEventId; begin - +trammo[sidNothing]:= ' '; for e:= Low(TEventId) to High(TEventId) do first[e]:= true; {$I-} @@ -77,7 +77,7 @@ TryDo(s[6] = '=', 'Load locale: "=" expected', true); Delete(s, 1, 6); case a of - 0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammo[TAmmoStrId(b)]:= s; + 0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammo[TAmmoStrId(b+1)]:= s; 1: if (b >=0) and (b <= ord(High(TMsgStrId))) then trmsg[TMsgStrId(b)]:= s; 2: if (b >=0) and (b <= ord(High(TEventId))) then begin TryDo(trevt_n[TEventId(b)] < MAX_EVENT_STRINGS, 'Too many event strings in ' + inttostr(a) + ':' + inttostr(b), false); diff -r b756432fd422 -r babe1a55e284 hedgewars/uWorld.pas --- a/hedgewars/uWorld.pas Tue Sep 08 16:58:43 2009 +0000 +++ b/hedgewars/uWorld.pas Tue Sep 08 19:44:49 2009 +0000 @@ -123,7 +123,7 @@ dec(y, 33); DrawSprite(sprAMSlotName, x, y, 0); for i:= cMaxSlotIndex downto 0 do - if Ammo^[i, 0].Count > 0 then + if (Ammo^[i, 0].Count > 0) and (Ammo^[i, 0].AmmoType <> amNothing) then begin if (cScreenHeight - CursorPoint.Y >= y - 33) and (cScreenHeight - CursorPoint.Y < y) then Slot:= i; dec(y, 33); @@ -137,10 +137,10 @@ if l >= 0 then begin - DrawSprite(sprAMAmmosBW, x + t * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)); + DrawSprite(sprAMAmmosBW, x + t * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); DrawSprite(sprTurnsLeft, x + t * 33 + 51, y + 17, l); end else - DrawSprite(sprAMAmmos, x + t * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)); + DrawSprite(sprAMAmmos, x + t * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); if (Slot = i) and (CursorPoint.X >= x + t * 33 + 35) @@ -156,7 +156,7 @@ DrawSprite(sprAMBorders, x, y, 0); if (Pos >= 0) then - if Ammo^[Slot, Pos].Count > 0 then + if (Ammo^[Slot, Pos].Count > 0) and (Ammo^[Slot, Pos].AmmoType <> amNothing) then begin DrawTexture(cScreenWidth div 2 - 200 + AMxShift, cScreenHeight - 68, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);