hedgewars/uGears.pas
changeset 5313 5e18eaef65d0
parent 5296 0bb518ad2da8
child 5316 191cd6c06203
equal deleted inserted replaced
5310:4622f83623ac 5313:5e18eaef65d0
    37 
    37 
    38 procedure initModule;
    38 procedure initModule;
    39 procedure freeModule;
    39 procedure freeModule;
    40 function  AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
    40 function  AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
    41 function  SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content: Longword ): PGear;
    41 function  SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content: Longword ): PGear;
       
    42 function  SpawnFakeCrateAt(x, y: LongInt; crate: TCrateType; trap: boolean ): PGear;
    42 procedure ResurrectHedgehog(gear: PGear);
    43 procedure ResurrectHedgehog(gear: PGear);
    43 procedure ProcessGears;
    44 procedure ProcessGears;
    44 procedure EndTurnCleanup;
    45 procedure EndTurnCleanup;
    45 procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource);
    46 procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource);
    46 procedure SetAllToActive;
    47 procedure SetAllToActive;
   118             @doStepMortar,
   119             @doStepMortar,
   119             @doStepWhip,
   120             @doStepWhip,
   120             @doStepKamikaze,
   121             @doStepKamikaze,
   121             @doStepCake,
   122             @doStepCake,
   122             @doStepSeduction,
   123             @doStepSeduction,
   123             @doStepWatermelon,
   124             @doStepBomb,
   124             @doStepCluster,
   125             @doStepCluster,
   125             @doStepBomb,
   126             @doStepBomb,
   126             @doStepWaterUp,
   127             @doStepWaterUp,
   127             @doStepDrill,
   128             @doStepDrill,
   128             @doStepBallgun,
   129             @doStepBallgun,
   538                 gear^.Timer:= 1000;
   539                 gear^.Timer:= 1000;
   539                 gear^.Radius:= 5;
   540                 gear^.Radius:= 5;
   540                 gear^.Density:= _1_5;
   541                 gear^.Density:= _1_5;
   541                 end;
   542                 end;
   542    gtStructure: begin
   543    gtStructure: begin
   543                 gear^.ImpactSound:= sndGrenadeImpact;
   544                 gear^.Elasticity:= _0_55;
   544                 gear^.nImpactSounds:= 1;
   545                 gear^.Friction:= _0_995;
       
   546                 gear^.Density:= _0_9;
   545                 gear^.Radius:= 13;
   547                 gear^.Radius:= 13;
   546                 gear^.Elasticity:= _0_3;
   548                 gear^.Health:= 200;
   547                 gear^.Health:= 50;
       
   548                 gear^.Tag:= 3;
   549                 gear^.Tag:= 3;
   549                 end;
   550                 end;
   550     end;
   551     end;
   551 
   552 
   552 InsertGearToList(gear);
   553 InsertGearToList(gear);
  1605 function SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content: Longword): PGear;
  1606 function SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content: Longword): PGear;
  1606 begin
  1607 begin
  1607     FollowGear := AddGear(x, y, gtCase, 0, _0, _0, 0);
  1608     FollowGear := AddGear(x, y, gtCase, 0, _0, _0, 0);
  1608     cCaseFactor := 0;
  1609     cCaseFactor := 0;
  1609 
  1610 
  1610     if (content > ord(High(TAmmoType))) then content := ord(High(TAmmoType));
  1611     if (crate <> HealthCrate) and (content > ord(High(TAmmoType))) then content := ord(High(TAmmoType));
  1611 
  1612 
  1612     case crate of
  1613     case crate of
  1613         HealthCrate: begin
  1614         HealthCrate: begin
  1614             FollowGear^.Health := cHealthCaseAmount;
       
  1615             FollowGear^.Pos := posCaseHealth;
  1615             FollowGear^.Pos := posCaseHealth;
       
  1616             FollowGear^.Health := content;
  1616             AddCaption(GetEventString(eidNewHealthPack), cWhiteColor, capgrpAmmoInfo);
  1617             AddCaption(GetEventString(eidNewHealthPack), cWhiteColor, capgrpAmmoInfo);
  1617             end;
  1618             end;
  1618         AmmoCrate: begin
  1619         AmmoCrate: begin
  1619             FollowGear^.Pos := posCaseAmmo;
  1620             FollowGear^.Pos := posCaseAmmo;
  1620             FollowGear^.AmmoType := TAmmoType(content);
  1621             FollowGear^.AmmoType := TAmmoType(content);
  1628     end;
  1629     end;
  1629 
  1630 
  1630     if ( (x = 0) and (y = 0) ) then FindPlace(FollowGear, true, 0, LAND_WIDTH);
  1631     if ( (x = 0) and (y = 0) ) then FindPlace(FollowGear, true, 0, LAND_WIDTH);
  1631 
  1632 
  1632     SpawnCustomCrateAt := FollowGear;
  1633     SpawnCustomCrateAt := FollowGear;
       
  1634 end;
       
  1635 
       
  1636 function SpawnFakeCrateAt(x, y: LongInt; crate: TCrateType; trap: boolean): PGear;
       
  1637 begin
       
  1638     FollowGear := AddGear(x, y, gtCase, 0, _0, _0, 0);
       
  1639     cCaseFactor := 0;
       
  1640     
       
  1641     if trap then FollowGear^.Pos := posCaseTrap
       
  1642     else FollowGear^.Pos := posCaseDummy;
       
  1643 
       
  1644     case crate of
       
  1645         HealthCrate: begin
       
  1646             FollowGear^.Pos := FollowGear^.Pos + posCaseHealth;
       
  1647             AddCaption(GetEventString(eidNewHealthPack), cWhiteColor, capgrpAmmoInfo);
       
  1648             end;
       
  1649         AmmoCrate: begin
       
  1650             FollowGear^.Pos := FollowGear^.Pos + posCaseAmmo;
       
  1651             AddCaption(GetEventString(eidNewAmmoPack), cWhiteColor, capgrpAmmoInfo);
       
  1652             end;
       
  1653         UtilityCrate: begin
       
  1654             FollowGear^.Pos := FollowGear^.Pos + posCaseUtility;
       
  1655             AddCaption(GetEventString(eidNewUtilityPack), cWhiteColor, capgrpAmmoInfo);
       
  1656             end;
       
  1657     end;
       
  1658 
       
  1659     if ( (x = 0) and (y = 0) ) then FindPlace(FollowGear, true, 0, LAND_WIDTH);
       
  1660 
       
  1661     SpawnFakeCrateAt := FollowGear;
  1633 end;
  1662 end;
  1634 
  1663 
  1635 procedure SpawnBoxOfSmth;
  1664 procedure SpawnBoxOfSmth;
  1636 var t, aTot, uTot, a, h: LongInt;
  1665 var t, aTot, uTot, a, h: LongInt;
  1637     i: TAmmoType;
  1666     i: TAmmoType;