hedgewars/uGears.pas
changeset 4900 8ad0e23e6d63
parent 4895 481dfbe69cd2
child 4932 f11d80bac7ed
equal deleted inserted replaced
4899:8163c9aaad0c 4900:8ad0e23e6d63
   180 function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
   180 function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
   181 const Counter: Longword = 0;
   181 const Counter: Longword = 0;
   182 var gear: PGear;
   182 var gear: PGear;
   183 begin
   183 begin
   184 inc(Counter);
   184 inc(Counter);
   185 {$IFDEF DEBUGFILE}
       
   186 AddFileLog('AddGear: #' + inttostr(Counter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
   185 AddFileLog('AddGear: #' + inttostr(Counter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
   187 {$ENDIF}
       
   188 
   186 
   189 New(gear);
   187 New(gear);
   190 FillChar(gear^, sizeof(TGear), 0);
   188 FillChar(gear^, sizeof(TGear), 0);
   191 gear^.X:= int2hwFloat(X);
   189 gear^.X:= int2hwFloat(X);
   192 gear^.Y:= int2hwFloat(Y);
   190 gear^.Y:= int2hwFloat(Y);
   600                 inc(Team^.stats.AIKills);
   598                 inc(Team^.stats.AIKills);
   601                 if Team^.AIKillsTex <> nil then FreeTexture(Team^.AIKillsTex);
   599                 if Team^.AIKillsTex <> nil then FreeTexture(Team^.AIKillsTex);
   602                 Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16);
   600                 Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16);
   603                 end
   601                 end
   604         end;
   602         end;
   605 {$IFDEF DEBUGFILE}
   603 with Gear^ do
   606 with Gear^ do AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
   604     AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
   607 {$ENDIF}
       
   608 
   605 
   609 if CurAmmoGear = Gear then CurAmmoGear:= nil;
   606 if CurAmmoGear = Gear then CurAmmoGear:= nil;
   610 if FollowGear = Gear then FollowGear:= nil;
   607 if FollowGear = Gear then FollowGear:= nil;
   611 if lastGearByUID = Gear then lastGearByUID := nil;
   608 if lastGearByUID = Gear then lastGearByUID := nil;
   612 RemoveGearFromList(Gear);
   609 RemoveGearFromList(Gear);
  1044            spawnHealthTagForHH(CurrentHedgehog^.Gear, tmpDmg);
  1041            spawnHealthTagForHH(CurrentHedgehog^.Gear, tmpDmg);
  1045            end;
  1042            end;
  1046         end;
  1043         end;
  1047     end else if Gear^.Kind <> gtStructure then // not gtHedgehog nor gtStructure
  1044     end else if Gear^.Kind <> gtStructure then // not gtHedgehog nor gtStructure
  1048         begin
  1045         begin
  1049         {$IFDEF DEBUGFILE}
       
  1050         AddFileLog('Assigning hedgehog ' + inttostr(LongInt(AttackerHog)) + ' to gear ' + inttostr(Gear^.uid));
  1046         AddFileLog('Assigning hedgehog ' + inttostr(LongInt(AttackerHog)) + ' to gear ' + inttostr(Gear^.uid));
  1051         {$ENDIF}
       
  1052         Gear^.Hedgehog:= AttackerHog;
  1047         Gear^.Hedgehog:= AttackerHog;
  1053         end;
  1048         end;
  1054     inc(Gear^.Damage, Damage);
  1049     inc(Gear^.Damage, Damage);
  1055     ScriptCall('onGearDamage', Gear^.UID, Damage);
  1050     ScriptCall('onGearDamage', Gear^.UID, Damage);
  1056 end;
  1051 end;
  1168     fX, fY: hwFloat;
  1163     fX, fY: hwFloat;
  1169     vg: PVisualGear;
  1164     vg: PVisualGear;
  1170     i, cnt: LongInt;
  1165     i, cnt: LongInt;
  1171 begin
  1166 begin
  1172 TargetPoint.X:= NoPointX;
  1167 TargetPoint.X:= NoPointX;
  1173 {$IFDEF DEBUGFILE}if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF}
  1168 if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');
  1174 if Radius > 25 then KickFlakes(Radius, X, Y);
  1169 if Radius > 25 then KickFlakes(Radius, X, Y);
  1175 
  1170 
  1176 if ((Mask and EXPLNoGfx) = 0) then
  1171 if ((Mask and EXPLNoGfx) = 0) then
  1177     begin
  1172     begin
  1178     vg:= nil;
  1173     vg:= nil;
  1211                         if hwRound(hwAbs(Gear^.X-fX)+hwAbs(Gear^.Y-fY)) < dmgBase then
  1206                         if hwRound(hwAbs(Gear^.X-fX)+hwAbs(Gear^.Y-fY)) < dmgBase then
  1212                             dmg:= dmgBase - hwRound(Distance(Gear^.X - fX, Gear^.Y - fY));
  1207                             dmg:= dmgBase - hwRound(Distance(Gear^.X - fX, Gear^.Y - fY));
  1213                         if dmg > 1 then
  1208                         if dmg > 1 then
  1214                             begin
  1209                             begin
  1215                             dmg:= ModifyDamage(min(dmg div 2, Radius), Gear);
  1210                             dmg:= ModifyDamage(min(dmg div 2, Radius), Gear);
  1216                             //{$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF}
  1211                             //AddFileLog('Damage: ' + inttostr(dmg));
  1217                             if (Mask and EXPLNoDamage) = 0 then
  1212                             if (Mask and EXPLNoDamage) = 0 then
  1218                                 begin
  1213                                 begin
  1219                                 if not Gear^.Invulnerable then
  1214                                 if not Gear^.Invulnerable then
  1220                                     ApplyDamage(Gear, AttackingHog, dmg, dsExplosion)
  1215                                     ApplyDamage(Gear, AttackingHog, dmg, dsExplosion)
  1221                                 else
  1216                                 else
  1773 if cnt2 > 0 then
  1768 if cnt2 > 0 then
  1774     with ar2[GetRandom(cnt2)] do
  1769     with ar2[GetRandom(cnt2)] do
  1775         begin
  1770         begin
  1776         Gear^.X:= int2hwFloat(x);
  1771         Gear^.X:= int2hwFloat(x);
  1777         Gear^.Y:= int2hwFloat(y);
  1772         Gear^.Y:= int2hwFloat(y);
  1778         {$IFDEF DEBUGFILE}
       
  1779         AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')');
  1773         AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')');
  1780         {$ENDIF}
       
  1781         end
  1774         end
  1782     else
  1775     else
  1783     begin
  1776     begin
  1784     OutError('Can''t find place for Gear', false);
  1777     OutError('Can''t find place for Gear', false);
  1785     if Gear^.Kind = gtHedgehog then Gear^.Hedgehog^.Effects[heResurrectable] := false;
  1778     if Gear^.Kind = gtHedgehog then Gear^.Hedgehog^.Effects[heResurrectable] := false;