hedgewars/uGearsList.pas
changeset 6580 6155187bf599
parent 6543 697e9b730189
child 6581 e510d1245bd7
equal deleted inserted replaced
6579:fc52f7c22c9b 6580:6155187bf599
    46 
    46 
    47     if ptmp <> tmp then
    47     if ptmp <> tmp then
    48         begin
    48         begin
    49         Gear^.NextGear:= ptmp^.NextGear;
    49         Gear^.NextGear:= ptmp^.NextGear;
    50         Gear^.PrevGear:= ptmp;
    50         Gear^.PrevGear:= ptmp;
    51         if ptmp^.NextGear <> nil then ptmp^.NextGear^.PrevGear:= Gear;
    51         if ptmp^.NextGear <> nil then
       
    52             ptmp^.NextGear^.PrevGear:= Gear;
    52         ptmp^.NextGear:= Gear
    53         ptmp^.NextGear:= Gear
    53         end
    54         end
    54     else
    55     else
    55         begin
    56         begin
    56         Gear^.NextGear:= GearsList;
    57         Gear^.NextGear:= GearsList;
    57         if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear;
    58         if Gear^.NextGear <> nil then
       
    59             Gear^.NextGear^.PrevGear:= Gear;
    58         GearsList:= Gear;
    60         GearsList:= Gear;
    59         end;
    61         end;
    60 end;
    62 end;
    61 
    63 
    62 procedure RemoveGearFromList(Gear: PGear);
    64 procedure RemoveGearFromList(Gear: PGear);
    63 begin
    65 begin
    64 if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear^.PrevGear;
    66 if Gear^.NextGear <> nil then
       
    67     Gear^.NextGear^.PrevGear:= Gear^.PrevGear;
    65 if Gear^.PrevGear <> nil then
    68 if Gear^.PrevGear <> nil then
    66     Gear^.PrevGear^.NextGear:= Gear^.NextGear
    69     Gear^.PrevGear^.NextGear:= Gear^.NextGear
    67 else
    70 else
    68     GearsList:= Gear^.NextGear
    71     GearsList:= Gear^.NextGear
    69 end;
    72 end;
    94 gear^.ImpactSound:= sndNone;
    97 gear^.ImpactSound:= sndNone;
    95 gear^.nImpactSounds:= 0;
    98 gear^.nImpactSounds:= 0;
    96 gear^.Density:= _1;
    99 gear^.Density:= _1;
    97 // Define ammo association, if any.
   100 // Define ammo association, if any.
    98 gear^.AmmoType:= GearKindAmmoTypeMap[Kind];
   101 gear^.AmmoType:= GearKindAmmoTypeMap[Kind];
    99 if Ammoz[Gear^.AmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0 then gear^.Z:= cHHZ+1
   102 if Ammoz[Gear^.AmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0 then
       
   103     gear^.Z:= cHHZ+1
   100 else gear^.Z:= cUsualZ;
   104 else gear^.Z:= cUsualZ;
   101 
   105 
   102 if CurrentHedgehog <> nil then
   106 if CurrentHedgehog <> nil then
   103     begin
   107     begin
   104     gear^.Hedgehog:= CurrentHedgehog;
   108     gear^.Hedgehog:= CurrentHedgehog;
   115                 gear^.Radius:= 5;
   119                 gear^.Radius:= 5;
   116                 gear^.Elasticity:= _0_8;
   120                 gear^.Elasticity:= _0_8;
   117                 gear^.Friction:= _0_8;
   121                 gear^.Friction:= _0_8;
   118                 gear^.Density:= _1_5;
   122                 gear^.Density:= _1_5;
   119                 gear^.RenderTimer:= true;
   123                 gear^.RenderTimer:= true;
   120                 if gear^.Timer = 0 then gear^.Timer:= 3000
   124                 if gear^.Timer = 0 then
       
   125                     gear^.Timer:= 3000
   121                 end;
   126                 end;
   122   gtWatermelon: begin
   127   gtWatermelon: begin
   123                 gear^.ImpactSound:= sndMelonImpact;
   128                 gear^.ImpactSound:= sndMelonImpact;
   124                 gear^.nImpactSounds:= 1;
   129                 gear^.nImpactSounds:= 1;
   125                 gear^.AdvBounce:= 1;
   130                 gear^.AdvBounce:= 1;
   126                 gear^.Radius:= 6;
   131                 gear^.Radius:= 6;
   127                 gear^.Elasticity:= _0_8;
   132                 gear^.Elasticity:= _0_8;
   128                 gear^.Friction:= _0_995;
   133                 gear^.Friction:= _0_995;
   129                 gear^.Density:= _2;
   134                 gear^.Density:= _2;
   130                 gear^.RenderTimer:= true;
   135                 gear^.RenderTimer:= true;
   131                 if gear^.Timer = 0 then gear^.Timer:= 3000
   136                 if gear^.Timer = 0 then
       
   137                     gear^.Timer:= 3000
   132                 end;
   138                 end;
   133   gtMelonPiece: begin
   139   gtMelonPiece: begin
   134                 gear^.Density:= _2;
   140                 gear^.Density:= _2;
   135                 end;
   141                 end;
   136     gtHedgehog: begin
   142     gtHedgehog: begin
   168                         begin
   174                         begin
   169                         dx.isNegative:= GetRandom(2) = 0;
   175                         dx.isNegative:= GetRandom(2) = 0;
   170                         dx.QWordValue:= GetRandom(100000000);
   176                         dx.QWordValue:= GetRandom(100000000);
   171                         dy.isNegative:= false;
   177                         dy.isNegative:= false;
   172                         dy.QWordValue:= GetRandom(70000000);
   178                         dy.QWordValue:= GetRandom(70000000);
   173                         if GetRandom(2) = 0 then dx := -dx
   179                         if GetRandom(2) = 0 then
       
   180                             dx := -dx
   174                         end;
   181                         end;
   175                     State:= State or gstInvisible;
   182                     State:= State or gstInvisible;
   176                     Health:= random(vobFrameTicks);
   183                     Health:= random(vobFrameTicks);
   177                     Timer:= random(vobFramesCount);
   184                     Timer:= random(vobFramesCount);
   178                     Angle:= (random(2) * 2 - 1) * (1 + random(10000)) * vobVelocity
   185                     Angle:= (random(2) * 2 - 1) * (1 + random(10000)) * vobVelocity
   325                 gear^.Health:= 2048;
   332                 gear^.Health:= 2048;
   326                 gear^.Radius:= 7;
   333                 gear^.Radius:= 7;
   327                 gear^.Z:= cOnHHZ;
   334                 gear^.Z:= cOnHHZ;
   328                 gear^.RenderTimer:= true;
   335                 gear^.RenderTimer:= true;
   329                 gear^.DirAngle:= -90 * hwSign(Gear^.dX);
   336                 gear^.DirAngle:= -90 * hwSign(Gear^.dX);
   330                 if not dX.isNegative then gear^.Angle:= 1 else gear^.Angle:= 3
   337                 if not dX.isNegative then
       
   338                     gear^.Angle:= 1
       
   339                 else
       
   340                     gear^.Angle:= 3
   331                 end;
   341                 end;
   332  gtHellishBomb: begin
   342  gtHellishBomb: begin
   333                 gear^.ImpactSound:= sndHellishImpact1;
   343                 gear^.ImpactSound:= sndHellishImpact1;
   334                 gear^.nImpactSounds:= 4;
   344                 gear^.nImpactSounds:= 4;
   335                 gear^.AdvBounce:= 1;
   345                 gear^.AdvBounce:= 1;
   339                 gear^.Density:= _1_5;
   349                 gear^.Density:= _1_5;
   340                 gear^.RenderTimer:= true;
   350                 gear^.RenderTimer:= true;
   341                 gear^.Timer:= 5000
   351                 gear^.Timer:= 5000
   342                 end;
   352                 end;
   343        gtDrill: begin
   353        gtDrill: begin
   344                 if gear^.Timer = 0 then gear^.Timer:= 5000;
   354                 if gear^.Timer = 0 then
       
   355                     gear^.Timer:= 5000;
   345                 // Tag for drill strike. if 1 then first impact occured already
   356                 // Tag for drill strike. if 1 then first impact occured already
   346                 gear^.Tag := 0;
   357                 gear^.Tag := 0;
   347                 gear^.Radius:= 4;
   358                 gear^.Radius:= 4;
   348                 gear^.Density:= _1;
   359                 gear^.Density:= _1;
   349                 end;
   360                 end;
   383          gtEgg: begin
   394          gtEgg: begin
   384                 gear^.Radius:= 4;
   395                 gear^.Radius:= 4;
   385                 gear^.Elasticity:= _0_6;
   396                 gear^.Elasticity:= _0_6;
   386                 gear^.Friction:= _0_96;
   397                 gear^.Friction:= _0_96;
   387                 gear^.Density:= _1;
   398                 gear^.Density:= _1;
   388                 if gear^.Timer = 0 then gear^.Timer:= 3000
   399                 if gear^.Timer = 0 then
       
   400                     gear^.Timer:= 3000
   389                 end;
   401                 end;
   390       gtPortal: begin
   402       gtPortal: begin
   391                 gear^.ImpactSound:= sndMelonImpact;
   403                 gear^.ImpactSound:= sndMelonImpact;
   392                 gear^.nImpactSounds:= 1;
   404                 gear^.nImpactSounds:= 1;
   393                 gear^.AdvBounce:= 0;
   405                 gear^.AdvBounce:= 0;
   486         begin
   498         begin
   487         if (hwRound(Gear^.Y) >= cWaterLine) then
   499         if (hwRound(Gear^.Y) >= cWaterLine) then
   488             begin
   500             begin
   489             t:= max(Gear^.Damage, Gear^.Health);
   501             t:= max(Gear^.Damage, Gear^.Health);
   490             Gear^.Damage:= t;
   502             Gear^.Damage:= t;
   491             if ((not SuddenDeathDmg and (cWaterOpacity < $FF)) or (SuddenDeathDmg and (cWaterOpacity < $FF))) and (hwRound(Gear^.Y) < cWaterLine + 256) then
   503             if ((not SuddenDeathDmg and (cWaterOpacity < $FF)) or (SuddenDeathDmg and (cWaterOpacity < $FF)))
       
   504             and (hwRound(Gear^.Y) < cWaterLine + 256) then
   492                 spawnHealthTagForHH(Gear, t);
   505                 spawnHealthTagForHH(Gear, t);
   493             end;
   506             end;
   494 
   507 
   495         team:= Gear^.Hedgehog^.Team;
   508         team:= Gear^.Hedgehog^.Team;
   496         if CurrentHedgehog^.Gear = Gear then
   509         if CurrentHedgehog^.Gear = Gear then
   497             begin
   510             begin
   498             AttackBar:= 0;
   511             AttackBar:= 0;
   499             FreeActionsList; // to avoid ThinkThread on drawned gear
   512             FreeActionsList; // to avoid ThinkThread on drawned gear
   500             if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) and (CurrentHedgehog^.MultiShootAttacks > 0) then OnUsedAmmo(CurrentHedgehog^);
   513             if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0)
       
   514             and (CurrentHedgehog^.MultiShootAttacks > 0) then
       
   515                 OnUsedAmmo(CurrentHedgehog^);
   501             end;
   516             end;
   502 
   517 
   503         Gear^.Hedgehog^.Gear:= nil;
   518         Gear^.Hedgehog^.Gear:= nil;
   504         if Gear^.Hedgehog^.King then
   519         if Gear^.Hedgehog^.King then
   505             begin
   520             begin
   506             // are there any other kings left? Just doing nil check.  Presumably a mortally wounded king will get reaped soon enough
   521             // are there any other kings left? Just doing nil check.  Presumably a mortally wounded king will get reaped soon enough
   507             k:= false;
   522             k:= false;
   508             for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
   523             for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
   509                 if (team^.Clan^.Teams[i]^.Hedgehogs[0].Gear <> nil) then k:= true;
   524                 if (team^.Clan^.Teams[i]^.Hedgehogs[0].Gear <> nil) then
       
   525                     k:= true;
   510             if not k then
   526             if not k then
   511                 for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
   527                 for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
   512                     begin
   528                     begin
   513                     team^.Clan^.Teams[i]^.hasGone:= true;
   529                     team^.Clan^.Teams[i]^.hasGone:= true;
   514                     TeamGoneEffect(team^.Clan^.Teams[i]^)
   530                     TeamGoneEffect(team^.Clan^.Teams[i]^)
   522         else
   538         else
   523             uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true);
   539             uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true);
   524 
   540 
   525         inc(KilledHHs);
   541         inc(KilledHHs);
   526         RecountTeamHealth(team);
   542         RecountTeamHealth(team);
   527         if (CurrentHedgehog <> nil) and CurrentHedgehog^.Effects[heResurrectable] and (not Gear^.Hedgehog^.Effects[heResurrectable]) then
   543         if (CurrentHedgehog <> nil) and CurrentHedgehog^.Effects[heResurrectable] and
       
   544         (not Gear^.Hedgehog^.Effects[heResurrectable]) then
   528             with CurrentHedgehog^ do 
   545             with CurrentHedgehog^ do 
   529                 begin
   546                 begin
   530                 inc(Team^.stats.AIKills);
   547                 inc(Team^.stats.AIKills);
   531                 FreeTexture(Team^.AIKillsTex);
   548                 FreeTexture(Team^.AIKillsTex);
   532                 Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16);
   549                 Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16);
   533                 end
   550                 end
   534         end;
   551         end;
   535 with Gear^ do
   552 with Gear^ do
   536     AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
   553     AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
   537 
   554 
   538 if CurAmmoGear = Gear then CurAmmoGear:= nil;
   555 if CurAmmoGear = Gear then
   539 if FollowGear = Gear then FollowGear:= nil;
   556     CurAmmoGear:= nil;
   540 if lastGearByUID = Gear then lastGearByUID := nil;
   557 if FollowGear = Gear then
       
   558     FollowGear:= nil;
       
   559 if lastGearByUID = Gear then
       
   560     lastGearByUID := nil;
   541 RemoveGearFromList(Gear);
   561 RemoveGearFromList(Gear);
   542 Dispose(Gear)
   562 Dispose(Gear)
   543 end;
   563 end;
   544 
   564 
   545 end.
   565 end.