hedgewars/uGears.pas
changeset 4881 35e6269227b6
parent 4867 e604ee83e34f
child 4883 7cddc9201a1d
equal deleted inserted replaced
4880:07e9849c6a70 4881:35e6269227b6
    57 function  CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; forward;
    57 function  CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; forward;
    58 procedure SpawnBoxOfSmth; forward;
    58 procedure SpawnBoxOfSmth; forward;
    59 procedure AfterAttack; forward;
    59 procedure AfterAttack; forward;
    60 procedure HedgehogStep(Gear: PGear); forward;
    60 procedure HedgehogStep(Gear: PGear); forward;
    61 procedure doStepHedgehogMoving(Gear: PGear); forward;
    61 procedure doStepHedgehogMoving(Gear: PGear); forward;
    62 procedure HedgehogChAngle(Gear: PGear); forward;
    62 procedure HedgehogChAngle(HHGear: PGear); forward;
    63 procedure ShotgunShot(Gear: PGear); forward;
    63 procedure ShotgunShot(Gear: PGear); forward;
    64 procedure PickUp(HH, Gear: PGear); forward;
    64 procedure PickUp(HH, Gear: PGear); forward;
    65 procedure HHSetWeapon(Gear: PGear); forward;
    65 procedure HHSetWeapon(HHGear: PGear); forward;
    66 procedure doStepCase(Gear: PGear); forward;
    66 procedure doStepCase(Gear: PGear); forward;
    67 
    67 
    68 {$INCLUDE "GSHandlers.inc"}
    68 {$INCLUDE "GSHandlers.inc"}
    69 {$INCLUDE "HHHandlers.inc"}
    69 {$INCLUDE "HHHandlers.inc"}
    70 
    70 
   126             @doStepHammer,
   126             @doStepHammer,
   127             @doStepHammerHit,
   127             @doStepHammerHit,
   128             @doStepResurrector,
   128             @doStepResurrector,
   129             @doStepNapalmBomb,
   129             @doStepNapalmBomb,
   130             @doStepSnowball,
   130             @doStepSnowball,
   131             @doStepSnowflake
   131             @doStepSnowflake,
       
   132             @doStepStructure
   132             );
   133             );
   133 
   134 
   134 procedure InsertGearToList(Gear: PGear);
   135 procedure InsertGearToList(Gear: PGear);
   135 var tmp, ptmp: PGear;
   136 var tmp, ptmp: PGear;
   136 begin
   137 begin
   511                 end;
   512                 end;
   512   gtNapalmBomb: begin
   513   gtNapalmBomb: begin
   513                 gear^.Timer:= 1000;
   514                 gear^.Timer:= 1000;
   514                 gear^.Radius:= 5;
   515                 gear^.Radius:= 5;
   515                 gear^.Density:= _1_5;
   516                 gear^.Density:= _1_5;
       
   517                 end;
       
   518    gtStructure: begin
       
   519                 gear^.ImpactSound:= sndGrenadeImpact;
       
   520                 gear^.nImpactSounds:= 1;
       
   521                 gear^.Radius:= 13;
       
   522                 gear^.Elasticity:= _0_3;
       
   523                 gear^.Timer:= 5000;
       
   524                 gear^.Health:= 50;
   516                 end;
   525                 end;
   517     end;
   526     end;
   518 
   527 
   519 InsertGearToList(gear);
   528 InsertGearToList(gear);
   520 AddGear:= gear;
   529 AddGear:= gear;
  1032            begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid
  1041            begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid
  1033            inc(CurrentHedgehog^.Gear^.Karma, tmpDmg);
  1042            inc(CurrentHedgehog^.Gear^.Karma, tmpDmg);
  1034            spawnHealthTagForHH(CurrentHedgehog^.Gear, tmpDmg);
  1043            spawnHealthTagForHH(CurrentHedgehog^.Gear, tmpDmg);
  1035            end;
  1044            end;
  1036         end;
  1045         end;
  1037     end else // not gtHedgehog
  1046     end else if Gear^.Kind <> gtStructure then // not gtHedgehog nor gtStructure
  1038         begin
  1047         begin
  1039         AddFileLog('Assigning hedgehog ' + inttostr(LongInt(AttackerHog)) + ' to gear ' + inttostr(Gear^.uid));
  1048         AddFileLog('Assigning hedgehog ' + inttostr(LongInt(AttackerHog)) + ' to gear ' + inttostr(Gear^.uid));
  1040         Gear^.Hedgehog:= AttackerHog;
  1049         Gear^.Hedgehog:= AttackerHog;
  1041         end;
  1050         end;
  1042     inc(Gear^.Damage, Damage);
  1051     inc(Gear^.Damage, Damage);
  1191                 gtMine,
  1200                 gtMine,
  1192                 gtSMine,
  1201                 gtSMine,
  1193                 gtCase,
  1202                 gtCase,
  1194                 gtTarget,
  1203                 gtTarget,
  1195                 gtFlame,
  1204                 gtFlame,
  1196                 gtExplosives: begin
  1205                 gtExplosives,
       
  1206                 gtStructure: begin
  1197 // Run the calcs only once we know we have a type that will need damage
  1207 // Run the calcs only once we know we have a type that will need damage
  1198                         if hwRound(hwAbs(Gear^.X-fX)+hwAbs(Gear^.Y-fY)) < dmgBase then
  1208                         if hwRound(hwAbs(Gear^.X-fX)+hwAbs(Gear^.Y-fY)) < dmgBase then
  1199                             dmg:= dmgBase - hwRound(Distance(Gear^.X - fX, Gear^.Y - fY));
  1209                             dmg:= dmgBase - hwRound(Distance(Gear^.X - fX, Gear^.Y - fY));
  1200                         if dmg > 1 then
  1210                         if dmg > 1 then
  1201                             begin
  1211                             begin
  1266         gtHedgehog,
  1276         gtHedgehog,
  1267             gtMine,
  1277             gtMine,
  1268             gtSMine,
  1278             gtSMine,
  1269             gtCase,
  1279             gtCase,
  1270             gtTarget,
  1280             gtTarget,
  1271             gtExplosives: begin
  1281             gtExplosives,
       
  1282             gtStructure: begin
  1272                     if (not t^.Invulnerable) then
  1283                     if (not t^.Invulnerable) then
  1273                         ApplyDamage(t, Gear^.Hedgehog, dmg, dsBullet)
  1284                         ApplyDamage(t, Gear^.Hedgehog, dmg, dsBullet)
  1274                     else
  1285                     else
  1275                         Gear^.State:= Gear^.State or gstWinner;
  1286                         Gear^.State:= Gear^.State or gstWinner;
  1276 
  1287 
  1330             gtHedgehog,
  1341             gtHedgehog,
  1331             gtMine,
  1342             gtMine,
  1332             gtSMine,
  1343             gtSMine,
  1333             gtTarget,
  1344             gtTarget,
  1334             gtCase,
  1345             gtCase,
  1335             gtExplosives: begin
  1346             gtExplosives,
       
  1347             gtStructure: begin
  1336                     if (Ammo^.Kind = gtDrill) then begin Ammo^.Timer:= 0; exit; end;
  1348                     if (Ammo^.Kind = gtDrill) then begin Ammo^.Timer:= 0; exit; end;
  1337                     if (not Gear^.Invulnerable) then
  1349                     if (not Gear^.Invulnerable) then
  1338                         ApplyDamage(Gear, Ammo^.Hedgehog, tmpDmg, dsShove)
  1350                         ApplyDamage(Gear, Ammo^.Hedgehog, tmpDmg, dsShove)
  1339                     else
  1351                     else
  1340                         Gear^.State:= Gear^.State or gstWinner;
  1352                         Gear^.State:= Gear^.State or gstWinner;