- Mine weapon
- Random mines on map
- Refactored code that places weapons to slots
- Generating more spawn points
- cMaxSlot -> cMaxSlotIndex, cMaxSlotAmmo -> cMaxSlotAmmoIndex
- Changed weapons to slots mapping
--- a/hedgewars/CCHandlers.inc Thu Sep 01 18:41:23 2005 +0000
+++ b/hedgewars/CCHandlers.inc Sat Sep 03 16:01:28 2005 +0000
@@ -261,6 +261,7 @@
amSkip: TurnTimeLeft:= 0;
amPickHammer: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y) + cHHHalfHeight, gtPickHammer, 0);
amRope: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y), gtRope, 0, xx, yy);
+ amMine: AddGear(round(X) + Sign(dX) + 7, round(Y), gtMine, 0, Sign(dX) * 0.01);
end;
Power:= 0;
if CurAmmoGear <> nil then
@@ -320,7 +321,7 @@
begin
if (s[0] <> #1) or (CurrentTeam = nil) then exit;
slot:= byte(s[1]) - 49;
-if slot > cMaxSlot then exit;
+if slot > cMaxSlotIndex then exit;
if not CurrentTeam.ExtDriven then SendIPC(char(byte(s[1]) + 79));
with CurrentTeam^ do
begin
@@ -333,7 +334,7 @@
if caSlot^ = slot then
begin
inc(caAmmo^);
- if (caAmmo^ > cMaxSlotAmmo) or (Ammo[slot, caAmmo^].Count = 0) then caAmmo^:= 0
+ if (caAmmo^ > cMaxSlotAmmoIndex) or (Ammo[slot, caAmmo^].Count = 0) then caAmmo^:= 0
end else
if Ammo[slot, 0].Count > 0 then
begin
Binary file hedgewars/Data/Graphics/MineOff.png has changed
Binary file hedgewars/Data/Graphics/MineOn.png has changed
--- a/hedgewars/GSHandlers.inc Thu Sep 01 18:41:23 2005 +0000
+++ b/hedgewars/GSHandlers.inc Sat Sep 03 16:01:28 2005 +0000
@@ -569,3 +569,28 @@
if Gear.State > 5 then DeleteGear(Gear)
end;
end;
+
+////////////////////////////////////////////////////////////////////////////////
+procedure doStepMine(Gear: PGear);
+begin
+if (Gear.dX <> 0) or (Gear.dY <> 0) then
+ begin
+ doStepFallingGear(Gear);
+ AllInactive:= false
+ end;
+CalcRotationDirAngle(Gear);
+if TurnTimeLeft = 0 then Gear.State:= Gear.State or gsttmpFlag;
+if ((Gear.State and gsttmpFlag) <> 0) then
+ if ((Gear.State and gstAttacking) = 0) then
+ if isGearNear(Gear, gtHedgehog, 42, 25) then Gear.State:= Gear.State or gstAttacking else
+ else // gstAttacking <> 0
+ begin
+ AllInactive:= false;
+ dec(Gear.Timer);
+ if Gear.Timer = 0 then
+ begin
+ doMakeExplosion(round(Gear.X), round(Gear.Y), 50, 0);
+ DeleteGear(Gear)
+ end;
+ end;
+end;
--- a/hedgewars/hw.dpr Thu Sep 01 18:41:23 2005 +0000
+++ b/hedgewars/hw.dpr Sat Sep 03 16:01:28 2005 +0000
@@ -76,6 +76,7 @@
end;
gsStart: begin
AssignHHCoords;
+ AddMiscGears;
AdjustColor(cColorNearBlack);
AdjustColor(cWhiteColor);
StoreLoad;
@@ -195,7 +196,6 @@
WriteLnToConsole(' -= by unC0Rr =- ');
GetParams;
Randomize;
-InitGears;
WriteToConsole('Init SDL... ');
SDLTry(SDL_Init(SDL_INIT_VIDEO) >= 0, true);
--- a/hedgewars/uAIAmmoTests.pas Thu Sep 01 18:41:23 2005 +0000
+++ b/hedgewars/uAIAmmoTests.pas Sat Sep 03 16:01:28 2005 +0000
@@ -68,6 +68,9 @@
),
( Test: nil;
Flags: 0;
+ ),
+ ( Test: nil;
+ Flags: 0;
)
);
--- a/hedgewars/uConsts.pas Thu Sep 01 18:41:23 2005 +0000
+++ b/hedgewars/uConsts.pas Sat Sep 03 16:01:28 2005 +0000
@@ -43,13 +43,15 @@
ptMapCurrent, ptDemos, ptSounds, ptGraves, ptFonts, ptForts);
TSprite = (sprWater, sprCloud, sprBomb, sprBigDigit, sprFrame,
sprLag, sprArrow, sprGrenade, sprTargetP, sprUFO,
- sprSmokeTrace, sprRopeHook, sprExplosion50);
+ sprSmokeTrace, sprRopeHook, sprExplosion50, sprMineOff,
+ sprMineOn);
TGearType = (gtCloud, gtAmmo_Bomb, gtHedgehog, gtAmmo_Grenade, gtHealthTag,
gtGrave, gtUFO, gtShotgunShot, gtActionTimer, gtPickHammer, gtRope,
- gtSmokeTrace, gtExplosion);
+ gtSmokeTrace, gtExplosion, gtMine);
TSound = (sndGrenadeImpact, sndExplosion, sndThrowPowerUp, sndThrowRelease, sndSplash,
sndShotgunReload, sndShotgunFire, sndGraveImpact);
- TAmmoType = (amGrenade, amBazooka, amUFO, amShotgun, amPickHammer, amSkip, amRope);
+ TAmmoType = (amGrenade, amBazooka, amUFO, amShotgun, amPickHammer, amSkip, amRope,
+ amMine);
THWFont = (fnt16, fntBig);
THHFont = record
Handle: PTTF_Font;
@@ -130,8 +132,8 @@
gm_HJump = $00000080;
gm_Destroy= $00000100;
- cMaxSlot = 4;
- cMaxSlotAmmo = 1;
+ cMaxSlotIndex = 6;
+ cMaxSlotAmmoIndex = 1;
ammoprop_Timerable = $00000001;
ammoprop_Power = $00000002;
@@ -221,7 +223,9 @@
(FileName: 'UFO.png'; Path: ptGraphics; Width: 32; Height: 32),// sprUFO
(FileName:'SmokeTrace.png'; Path: ptGraphics; Width: 32; Height: 32),// sprSmokeTrace
(FileName: 'RopeHook.png'; Path: ptGraphics; Width: 32; Height: 32),// sprRopeHook
- (FileName: 'Expl50.png'; Path: ptGraphics; Width: 64; Height: 64) // sprExplosion50
+ (FileName: 'Expl50.png'; Path: ptGraphics; Width: 64; Height: 64),// sprExplosion50
+ (FileName: 'MineOff.png'; Path: ptGraphics; Width: 16; Height: 16),// sprMineOff
+ (FileName: 'MineOn.png'; Path: ptGraphics; Width: 16; Height: 16) // sprMineOn
);
Soundz: array[TSound] of record
FileName: String[31];
@@ -250,7 +254,7 @@
NumPerTurn: 0;
Timer: 3000;
AmmoType: amGrenade);
- Slot: 0;
+ Slot: 1;
TimeAfterTurn: 3000),
(Name: 'Bazooka';
Ammo: (Propz: ammoprop_Power;
@@ -258,7 +262,7 @@
NumPerTurn: 0;
Timer: 0;
AmmoType: amBazooka);
- Slot: 1;
+ Slot: 0;
TimeAfterTurn: 3000),
(Name: 'UFO';
Ammo: (Propz: ammoprop_Power or ammoprop_NeedTarget;
@@ -282,7 +286,7 @@
NumPerTurn: 0;
Timer: 0;
AmmoType: amPickHammer);
- Slot: 3;
+ Slot: 4;
TimeAfterTurn: 0),
(Name: 'Skip turn';
Ammo: (Propz: 0;
@@ -290,7 +294,7 @@
NumPerTurn: 0;
Timer: 0;
AmmoType: amSkip);
- Slot: 4;
+ Slot: 6;
TimeAfterTurn: 0),
(Name: 'Rope';
Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_AttackInFall or ammoprop_AttackInJump;
@@ -298,8 +302,16 @@
NumPerTurn: 0;
Timer: 0;
AmmoType: amRope);
+ Slot: 5;
+ TimeAfterTurn: 0),
+ (Name: 'Mine';
+ Ammo: (Propz: 0;
+ Count: 5;
+ NumPerTurn: 0;
+ Timer: 0;
+ AmmoType: amMine);
Slot: 3;
- TimeAfterTurn: 0)
+ TimeAfterTurn: 3000)
);
Resolutions: array[0..3] of String = (
--- a/hedgewars/uGears.pas Thu Sep 01 18:41:23 2005 +0000
+++ b/hedgewars/uGears.pas Sat Sep 03 16:01:28 2005 +0000
@@ -68,7 +68,7 @@
procedure SetAllHHToActive;
procedure DrawGears(Surface: PSDL_Surface);
procedure FreeGearsList;
-procedure InitGears;
+procedure AddMiscGears;
procedure AssignHHCoords;
var CurAmmoGear: PGear = nil;
@@ -88,6 +88,7 @@
procedure DeleteGear(Gear: PGear); forward;
procedure doMakeExplosion(X, Y, Radius: integer; Mask: LongWord); forward;
+function isGearNear(Gear: PGear; Kind: TGearType; rX, rY: integer): boolean; forward;
{$INCLUDE GSHandlers.inc}
{$INCLUDE HHHandlers.inc}
@@ -105,7 +106,8 @@
doStepPickHammer,
doStepRope,
doStepSmokeTrace,
- doStepExplosion
+ doStepExplosion,
+ doStepMine
);
function AddGear(X, Y: integer; Kind: TGearType; State: Cardinal; const dX: real=0.0; dY: real=0.0; Timer: LongWord=0): PGear;
@@ -185,6 +187,13 @@
Result.X:= Result.X - 25;
Result.Y:= Result.Y - 25;
end;
+ gtMine: begin
+ Result.HalfWidth:= 3;
+ Result.HalfHeight:= 3;
+ Result.Elasticity:= 0.55;
+ Result.Friction:= 0.995;
+ Result.Timer:= 3000;
+ end;
end;
if GearsList = nil then GearsList:= Result
else begin
@@ -433,6 +442,9 @@
DrawSprite(sprRopeHook, Round(Gear.X) - 16 + WorldDx, Round(Gear.Y) - 16 + WorldDy, DxDy2Angle32(Gear.dY, Gear.dX), Surface);
end;
gtExplosion: DrawSprite(sprExplosion50, Round(Gear.X) + WorldDx, Round(Gear.Y) + WorldDy, Gear.State, Surface);
+ gtMine: if ((Gear.State and gstAttacking) = 0)or((Gear.Timer and $3FF) < 420)
+ then DrawSprite(sprMineOff , Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy, trunc(Gear.DirAngle), Surface)
+ else DrawSprite(sprMineOn , Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy, trunc(Gear.DirAngle), Surface);
end;
Gear:= Gear.NextGear
end;
@@ -453,11 +465,16 @@
end;
end;
-procedure InitGears;
-var i: integer;
+procedure AddMiscGears;
+var i, x, y: integer;
begin
for i:= 0 to cCloudsNumber do AddGear( - cScreenWidth + i * ((cScreenWidth * 2 + 2304) div cCloudsNumber), -128, gtCloud, random(4), (0.5-random)*0.01);
AddGear(0, 0, gtActionTimer, gtsStartGame, 0, 0, 2000).Health:= 3;
+for i:= 0 to 3 do
+ begin
+ GetHHPoint(x, y);
+ AddGear(X, Y + 9, gtMine, 0);
+ end;
end;
procedure doMakeExplosion(X, Y, Radius: integer; Mask: LongWord);
@@ -479,7 +496,8 @@
begin
dmg:= dmg shr 1;
case Gear.Kind of
- gtHedgehog: begin
+ gtHedgehog,
+ gtMine: begin
inc(Gear.Damage, dmg);
Gear.dX:= Gear.dX + dmg / 200 * sign(Gear.X - X);
Gear.dY:= Gear.dY + dmg / 200 * sign(Gear.Y - Y);
@@ -509,6 +527,25 @@
end
end;
+function isGearNear(Gear: PGear; Kind: TGearType; rX, rY: integer): boolean;
+var t: PGear;
+begin
+t:= GearsList;
+rX:= sqr(rX);
+rY:= sqr(rY);
+while t <> nil do
+ begin
+ if (t <> Gear) and (t.Kind = Kind) then
+ if sqr(Gear.X - t.X) / rX + sqr(Gear.Y - t.Y) / rY <= 1 then
+ begin
+ Result:= true;
+ exit
+ end;
+ t:= t.NextGear
+ end;
+Result:= false
+end;
+
initialization
finalization
--- a/hedgewars/uLand.pas Thu Sep 01 18:41:23 2005 +0000
+++ b/hedgewars/uLand.pas Sat Sep 03 16:01:28 2005 +0000
@@ -392,7 +392,7 @@
end;
procedure AddHHPoints;
-var i, x, y, t: integer;
+var x, y, t: integer;
function CountNonZeroz(x, y: integer): integer;
var i: integer;
@@ -404,10 +404,10 @@
end;
begin
-for i:= 0 to 9 do
+x:= 40;
+while x < 2010 do
begin
y:= -24;
- x:= i * 160 + 300;
while y < 1023 do
begin
repeat
@@ -421,6 +421,7 @@
if (t > 22) and (y < 1023) then AddHHPoint(x, y - 12);
inc(y, 100)
end;
+ inc(x, 160)
end;
end;
--- a/hedgewars/uTeams.pas Thu Sep 01 18:41:23 2005 +0000
+++ b/hedgewars/uTeams.pas Sat Sep 03 16:01:28 2005 +0000
@@ -50,7 +50,7 @@
visStepPos: LongWord;
BotLevel : LongWord; // 0 - Human player
end;
- THHAmmo = array[0..cMaxSlot, 0..cMaxSlotAmmo] of TAmmo;
+ THHAmmo = array[0..cMaxSlotIndex, 0..cMaxSlotAmmoIndex] of TAmmo;
TTeam = record
Next: PTeam;
Color: Cardinal;
@@ -168,6 +168,19 @@
end;
end;
+procedure FillAmmoGroup(Ammo: PHHAmmo);
+var mi: array[0..cMaxSlotIndex] of byte;
+ a: TAmmoType;
+begin
+FillChar(mi, sizeof(mi), 0);
+for a:= Low(TAmmoType) to High(TAmmoType) do
+ begin
+ TryDo(mi[Ammoz[a].Slot] <= cMaxSlotAmmoIndex, 'Ammo slot overflow', true);
+ Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]]:= Ammoz[a].Ammo;
+ inc(mi[Ammoz[a].Slot])
+ end;
+end;
+
procedure InitTeams;
var p: PTeam;
i: integer;
@@ -175,20 +188,13 @@
p:= TeamsList;
while p <> nil do
begin
+ FillAmmoGroup(@p.Ammos[0]);
for i:= 0 to cMaxHHIndex do
if p.Hedgehogs[i].Gear <> nil then
begin
- p.Ammos[i][0, 0]:= Ammoz[amGrenade].Ammo;
- p.Ammos[i][0, 1]:= Ammoz[amUFO].Ammo;
- p.Ammos[i][1, 0]:= Ammoz[amBazooka].Ammo;
- p.Ammos[i][2, 0]:= Ammoz[amShotgun].Ammo;
- p.Ammos[i][3, 0]:= Ammoz[amPickHammer].Ammo;
- p.Ammos[i][3, 1]:= Ammoz[amRope].Ammo;
- p.Ammos[i][4, 0]:= Ammoz[amSkip].Ammo;
p.Hedgehogs[i].Gear.Health:= 100;
- p.Hedgehogs[i].Ammo:= @p.Ammos[0]
- {0 - общее на всех оружие, i - у каждого своё
- можно группировать ёжиков, чтобы у каждой группы было своё оружие}
+ p.Hedgehogs[i].Ammo:= @p.Ammos[0] // 0 means all hedgehogs
+ // will have common set of ammo
end;
p:= p.Next
end;
@@ -203,7 +209,7 @@
if Ammo[CurSlot, CurAmmo].Count = 0 then
begin
CurAmmo:= 0;
- while (CurAmmo <= cMaxSlotAmmo) and (Ammo[CurSlot, CurAmmo].Count = 0) do inc(CurAmmo)
+ while (CurAmmo <= cMaxSlotAmmoIndex) and (Ammo[CurSlot, CurAmmo].Count = 0) do inc(CurAmmo)
end;
with Ammo[CurSlot, CurAmmo] do
@@ -234,7 +240,7 @@
repeat
b:= false;
ami:= 0;
- while (not b) and (ami < cMaxSlotAmmo) do
+ while (not b) and (ami < cMaxSlotAmmoIndex) do
if (Ammo[slot, ami].Count = 0)
and (Ammo[slot, ami + 1].Count > 0) then b:= true
else inc(ami);