hedgewars/uGears.pas
changeset 4787 e353f2211cea
parent 4784 d8eafc8dba38
child 4790 4cb3f7890fbd
equal deleted inserted replaced
4747:095398eba689 4787:e353f2211cea
   593 with Gear^ do AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
   593 with Gear^ do AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
   594 {$ENDIF}
   594 {$ENDIF}
   595 
   595 
   596 if CurAmmoGear = Gear then CurAmmoGear:= nil;
   596 if CurAmmoGear = Gear then CurAmmoGear:= nil;
   597 if FollowGear = Gear then FollowGear:= nil;
   597 if FollowGear = Gear then FollowGear:= nil;
       
   598 if lastGearByUID = Gear then lastGearByUID := nil;
   598 RemoveGearFromList(Gear);
   599 RemoveGearFromList(Gear);
   599 Dispose(Gear)
   600 Dispose(Gear)
   600 end;
   601 end;
   601 
   602 
   602 function CheckNoDamage: boolean; // returns TRUE in case of no damaged hhs
   603 function CheckNoDamage: boolean; // returns TRUE in case of no damaged hhs
   793                 begin
   794                 begin
   794                 if (TotalRounds = cSuddenDTurns) and not SuddenDeathDmg and not isInMultiShoot then
   795                 if (TotalRounds = cSuddenDTurns) and not SuddenDeathDmg and not isInMultiShoot then
   795                     begin
   796                     begin
   796                     SuddenDeathDmg:= true;
   797                     SuddenDeathDmg:= true;
   797                     AddCaption(trmsg[sidSuddenDeath], cWhiteColor, capgrpGameState);
   798                     AddCaption(trmsg[sidSuddenDeath], cWhiteColor, capgrpGameState);
   798                     playSound(sndSuddenDeath)
   799                     playSound(sndSuddenDeath);
       
   800                     MusicFN:= SDMusic;
       
   801                     ChangeMusic
   799                     end
   802                     end
   800                 else if (TotalRounds < cSuddenDTurns) and not isInMultiShoot then
   803                 else if (TotalRounds < cSuddenDTurns) and not isInMultiShoot then
   801                     begin
   804                     begin
   802                     i:= cSuddenDTurns - TotalRounds;
   805                     i:= cSuddenDTurns - TotalRounds;
   803                     s:= inttostr(i);
   806                     s:= inttostr(i);
  1774 
  1777 
  1775 function GearByUID(uid : Longword) : PGear;
  1778 function GearByUID(uid : Longword) : PGear;
  1776 var gear: PGear;
  1779 var gear: PGear;
  1777 begin
  1780 begin
  1778 GearByUID:= nil;
  1781 GearByUID:= nil;
       
  1782 if uid = 0 then exit;
       
  1783 if (lastGearByUID <> nil) and (lastGearByUID^.uid = uid) then
       
  1784     begin
       
  1785     GearByUID:= lastGearByUID;
       
  1786     exit
       
  1787     end;
  1779 gear:= GearsList;
  1788 gear:= GearsList;
  1780 while gear <> nil do
  1789 while gear <> nil do
  1781     begin
  1790     begin
  1782     if gear^.uid = uid then
  1791     if gear^.uid = uid then
  1783         begin
  1792         begin
  1784             GearByUID:= gear;
  1793         lastGearByUID:= gear;
  1785             exit
  1794         GearByUID:= gear;
       
  1795         exit
  1786         end;
  1796         end;
  1787     gear:= gear^.NextGear
  1797     gear:= gear^.NextGear
  1788     end
  1798     end
  1789 end;
  1799 end;
  1790 
  1800 
  1828     *)
  1838     *)
  1829 
  1839 
  1830     if (x < 4) and (TeamsArray[t] <> nil) then
  1840     if (x < 4) and (TeamsArray[t] <> nil) then
  1831         begin
  1841         begin
  1832             // if team matches current hedgehog team, default to current hedgehog
  1842             // if team matches current hedgehog team, default to current hedgehog
  1833             if (i = 0) and (CurrentHedgehog^.Team = TeamsArray[t]) then hh:= CurrentHedgehog
  1843             if (i = 0) and (CurrentHedgehog <> nil) and (CurrentHedgehog^.Team = TeamsArray[t]) then hh:= CurrentHedgehog
  1834             else 
  1844             else 
  1835                 begin
  1845                 begin
  1836             // otherwise use the first living hog or the hog amongs the remaining ones indicated by i
  1846             // otherwise use the first living hog or the hog amongs the remaining ones indicated by i
  1837                 j:= 0;
  1847                 j:= 0;
  1838                 c:= 0;
  1848                 c:= 0;
  1845                             hh:= @TeamsArray[t]^.Hedgehogs[j]
  1855                             hh:= @TeamsArray[t]^.Hedgehogs[j]
  1846                         end;
  1856                         end;
  1847                     inc(j)
  1857                     inc(j)
  1848                     end
  1858                     end
  1849                 end;
  1859                 end;
  1850         if hh <> nil then Gear:= AddVisualGear(0, 0, vgtSpeechBubble);
  1860         if hh <> nil then 
  1851         if Gear <> nil then
       
  1852             begin
  1861             begin
  1853             Gear^.Hedgehog:= hh;
  1862             Gear:= AddVisualGear(0, 0, vgtSpeechBubble);
  1854             Gear^.Text:= text;
  1863             if Gear <> nil then
  1855             Gear^.FrameTicks:= x
  1864                 begin
       
  1865                 Gear^.Hedgehog:= hh;
       
  1866                 Gear^.Text:= text;
       
  1867                 Gear^.FrameTicks:= x
       
  1868                 end
  1856             end
  1869             end
  1857         //else ParseCommand('say ' + text, true)
  1870         //else ParseCommand('say ' + text, true)
  1858         end
  1871         end
  1859     else if (x >= 4) then
  1872     else if (x >= 4) then
  1860         begin
  1873         begin