hedgewars/uGearsList.pas
branchqmlfrontend
changeset 11071 3851ce4f2061
parent 11046 47a8c19ecb60
child 11173 1b386b9e1be0
equal deleted inserted replaced
11050:9b7c8c5a94e0 11071:3851ce4f2061
     1 (*
     1 (*
     2  * Hedgewars, a free turn based strategy game
     2  * Hedgewars, a free turn based strategy game
     3  * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
     3  * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
     4  *
     4  *
     5  * This program is free software; you can redistribute it and/or modify
     5  * This program is free software; you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License as published by
     6  * it under the terms of the GNU General Public License as published by
     7  * the Free Software Foundation; version 2 of the License
     7  * the Free Software Foundation; version 2 of the License
     8  *
     8  *
   153 
   153 
   154 if Gear^.NextGear <> nil then
   154 if Gear^.NextGear <> nil then
   155     Gear^.NextGear^.PrevGear:= Gear^.PrevGear;
   155     Gear^.NextGear^.PrevGear:= Gear^.PrevGear;
   156 if Gear^.PrevGear <> nil then
   156 if Gear^.PrevGear <> nil then
   157     Gear^.PrevGear^.NextGear:= Gear^.NextGear
   157     Gear^.PrevGear^.NextGear:= Gear^.NextGear
   158 else 
   158 else
   159     GearsList:= Gear^.NextGear;
   159     GearsList:= Gear^.NextGear;
   160 
   160 
   161 Gear^.NextGear:= nil;
   161 Gear^.NextGear:= nil;
   162 Gear^.PrevGear:= nil
   162 Gear^.PrevGear:= nil
   163 end;
   163 end;
   236                     gear^.Timer:= 3000
   236                     gear^.Timer:= 3000
   237                 end;
   237                 end;
   238   gtMelonPiece: begin
   238   gtMelonPiece: begin
   239                 gear^.AdvBounce:= 1;
   239                 gear^.AdvBounce:= 1;
   240                 gear^.Density:= _2;
   240                 gear^.Density:= _2;
       
   241                 gear^.Elasticity:= _0_8;
       
   242                 gear^.Friction:= _0_995;
   241                 gear^.Radius:= 4
   243                 gear^.Radius:= 4
   242                 end;
   244                 end;
   243     gtHedgehog: begin
   245     gtHedgehog: begin
   244                 gear^.AdvBounce:= 1;
   246                 gear^.AdvBounce:= 1;
   245                 gear^.Radius:= cHHRadius;
   247                 gear^.Radius:= cHHRadius;
   667 procedure DeleteGear(Gear: PGear);
   669 procedure DeleteGear(Gear: PGear);
   668 var team: PTeam;
   670 var team: PTeam;
   669     t,i: Longword;
   671     t,i: Longword;
   670     k: boolean;
   672     k: boolean;
   671     cakeData: PCakeData;
   673     cakeData: PCakeData;
       
   674     iterator: PGear;
   672 begin
   675 begin
   673 
   676 
   674 ScriptCall('onGearDelete', gear^.uid);
   677 ScriptCall('onGearDelete', gear^.uid);
   675 
   678 
   676 DeleteCI(Gear);
   679 DeleteCI(Gear);
   677 
   680 
   678 FreeAndNilTexture(Gear^.Tex);
   681 FreeAndNilTexture(Gear^.Tex);
       
   682 
       
   683 // remove potential links to this gear
       
   684 // currently relevant to: gears linked by hammer
       
   685 if (Gear^.Kind = gtHedgehog) or (Gear^.Kind = gtMine) or (Gear^.Kind = gtExplosives) then
       
   686     begin
       
   687     // check all gears for stuff to port through
       
   688     iterator := nil;
       
   689     while true do
       
   690         begin
       
   691 
       
   692         // iterate through GearsList
       
   693         if iterator = nil then
       
   694             iterator := GearsList
       
   695         else
       
   696             iterator := iterator^.NextGear;
       
   697 
       
   698         // end of list?
       
   699         if iterator = nil then
       
   700             break;
       
   701 
       
   702         if iterator^.LinkedGear = Gear then
       
   703             iterator^.LinkedGear:= nil;
       
   704         end;
       
   705 
       
   706     end;
   679 
   707 
   680 // make sure that portals have their link removed before deletion
   708 // make sure that portals have their link removed before deletion
   681 if (Gear^.Kind = gtPortal) then
   709 if (Gear^.Kind = gtPortal) then
   682     begin
   710     begin
   683     if (Gear^.LinkedGear <> nil) then
   711     if (Gear^.LinkedGear <> nil) then
   731             for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
   759             for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
   732                 if (team^.Clan^.Teams[i]^.Hedgehogs[0].Gear <> nil) then
   760                 if (team^.Clan^.Teams[i]^.Hedgehogs[0].Gear <> nil) then
   733                     k:= true;
   761                     k:= true;
   734             if not k then
   762             if not k then
   735                 for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
   763                 for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
   736                     begin
   764                     with team^.Clan^.Teams[i]^ do
   737                     team^.Clan^.Teams[i]^.hasGone:= true;
   765                         for t:= 0 to cMaxHHIndex do
   738                     TeamGoneEffect(team^.Clan^.Teams[i]^)
   766                             if Hedgehogs[t].Gear <> nil then
   739                     end
   767                                 Hedgehogs[t].Gear^.Health:= 0
       
   768                             else if (Hedgehogs[t].GearHidden <> nil) then
       
   769                                 Hedgehogs[t].GearHidden^.Health:= 0  // hog is still hidden. if tardis should return though, lua, eh...
   740             end;
   770             end;
   741 
   771 
   742         // should be not CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog
   772         // should be not CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog
   743         // same stand for CheckHHDamage
   773         // same stand for CheckHHDamage
   744         if (Gear^.LastDamage <> nil) and (CurrentHedgehog <> nil) then
   774         if (Gear^.LastDamage <> nil) and (CurrentHedgehog <> nil) then