hedgewars/uGearsUtils.pas
branchqmlfrontend
changeset 10748 dc587913987c
parent 10668 a15d57d941a1
child 10789 acbf69e2e5cf
equal deleted inserted replaced
10616:20a2d5e6930a 10748:dc587913987c
    79 var Gear: PGear;
    79 var Gear: PGear;
    80     dmg, dmgBase: LongInt;
    80     dmg, dmgBase: LongInt;
    81     fX, fY, tdX, tdY: hwFloat;
    81     fX, fY, tdX, tdY: hwFloat;
    82     vg: PVisualGear;
    82     vg: PVisualGear;
    83     i, cnt: LongInt;
    83     i, cnt: LongInt;
       
    84     wrap: boolean;
    84 begin
    85 begin
    85 if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');
    86 if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');
    86 if Radius > 25 then KickFlakes(Radius, X, Y);
    87 if Radius > 25 then KickFlakes(Radius, X, Y);
    87 
    88 
    88 if ((Mask and EXPLNoGfx) = 0) then
    89 if ((Mask and EXPLNoGfx) = 0) then
    99     dmgRadius:= Radius shl 1
   100     dmgRadius:= Radius shl 1
   100 else
   101 else
   101     dmgRadius:= Radius;
   102     dmgRadius:= Radius;
   102 dmgBase:= dmgRadius + cHHRadius div 2;*)
   103 dmgBase:= dmgRadius + cHHRadius div 2;*)
   103 dmgBase:= Radius shl 1 + cHHRadius div 2;
   104 dmgBase:= Radius shl 1 + cHHRadius div 2;
       
   105 
       
   106 // we might have to run twice if weWrap is enabled
       
   107 wrap:= false;
       
   108 repeat
       
   109 
   104 fX:= int2hwFloat(X);
   110 fX:= int2hwFloat(X);
   105 fY:= int2hwFloat(Y);
   111 fY:= int2hwFloat(Y);
   106 Gear:= GearsList;
   112 Gear:= GearsList;
       
   113 
   107 while Gear <> nil do
   114 while Gear <> nil do
   108     begin
   115     begin
   109     dmg:= 0;
   116     dmg:= 0;
   110     //dmg:= dmgRadius  + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y)));
   117     //dmg:= dmgRadius  + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y)));
   111     //if (dmg > 1) and
   118     //if (dmg > 1) and
   186         if (cnt > 0) and (SpritesData[sprChunk].Texture <> nil) then
   193         if (cnt > 0) and (SpritesData[sprChunk].Texture <> nil) then
   187             for i:= 0 to cnt do
   194             for i:= 0 to cnt do
   188                 AddVisualGear(X, Y, vgtChunk)
   195                 AddVisualGear(X, Y, vgtChunk)
   189         end;
   196         end;
   190 
   197 
       
   198 if (WorldEdge = weWrap) then
       
   199     begin
       
   200     // already wrapped? let's not wrap again!
       
   201     if wrap then
       
   202         break;
       
   203 
       
   204     // Radius + 5 because that's the actual radius the explosion changes graphically
       
   205     if X + (Radius + 5) > LongInt(rightX) then
       
   206         begin
       
   207         dec(X, playWidth);
       
   208         wrap:= true;
       
   209         end
       
   210     else if X - (Radius + 5) < LongInt(leftX) then
       
   211         begin
       
   212         inc(X, playWidth);
       
   213         wrap:= true;
       
   214         end;
       
   215     end;
       
   216 
       
   217 until (not wrap);
       
   218 
   191 uAIMisc.AwareOfExplosion(0, 0, 0)
   219 uAIMisc.AwareOfExplosion(0, 0, 0)
   192 end;
   220 end;
   193 
   221 
   194 function ModifyDamage(dmg: Longword; Gear: PGear): Longword;
   222 function ModifyDamage(dmg: Longword; Gear: PGear): Longword;
   195 var i: hwFloat;
   223 var i: hwFloat;
   668 
   696 
   669         // splash sound animation and droplets
   697         // splash sound animation and droplets
   670         if isImpact or isSkip then
   698         if isImpact or isSkip then
   671             addSplashForGear(Gear, isSkip);
   699             addSplashForGear(Gear, isSkip);
   672 
   700 
       
   701         if isSkip then
       
   702             ScriptCall('onGearWaterSkip', Gear^.uid);
   673         end
   703         end
   674     else
   704     else
   675         begin
   705         begin
   676         if (not ((Gear^.Kind = gtJetpack) or (Gear^.Kind = gtBee))) then
   706         if (not ((Gear^.Kind = gtJetpack) or (Gear^.Kind = gtBee))) then
   677             Gear^.State:= (Gear^.State and (not gstSubmersible));  // making it temporary for most gears is more attractive I think
   707             Gear^.State:= (Gear^.State and (not gstSubmersible));  // making it temporary for most gears is more attractive I think
   698     if (CurrentHedgehog^.Effects[heResurrectable] = 0) or ((CurrentHedgehog^.Effects[heResurrectable] <> 0)
   728     if (CurrentHedgehog^.Effects[heResurrectable] = 0) or ((CurrentHedgehog^.Effects[heResurrectable] <> 0)
   699           and (Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan)) then
   729           and (Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan)) then
   700         with CurrentHedgehog^ do
   730         with CurrentHedgehog^ do
   701             begin
   731             begin
   702             inc(Team^.stats.AIKills);
   732             inc(Team^.stats.AIKills);
   703             FreeTexture(Team^.AIKillsTex);
   733             FreeAndNilTexture(Team^.AIKillsTex);
   704             Team^.AIKillsTex := RenderStringTex(ansistring(inttostr(Team^.stats.AIKills)), Team^.Clan^.Color, fnt16);
   734             Team^.AIKillsTex := RenderStringTex(ansistring(inttostr(Team^.stats.AIKills)), Team^.Clan^.Color, fnt16);
   705             end;
   735             end;
   706     tempTeam := gear^.Hedgehog^.Team;
   736     tempTeam := gear^.Hedgehog^.Team;
   707     DeleteCI(gear);
   737     DeleteCI(gear);
   708     gX := hwRound(gear^.X);
   738     gX := hwRound(gear^.X);