hedgewars/uScript.pas
changeset 13597 f7cbf7d8298d
parent 13595 0adc82afb784
child 13604 73b096e1d895
equal deleted inserted replaced
13596:7699987d9f70 13597:f7cbf7d8298d
  1789             begin
  1789             begin
  1790             gear^.Health:= Trunc(lua_tonumber(L, 2));
  1790             gear^.Health:= Trunc(lua_tonumber(L, 2));
  1791 
  1791 
  1792             if (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
  1792             if (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
  1793                 begin
  1793                 begin
       
  1794                 if gear^.Health > cMaxHogHealth then
       
  1795                     gear^.Health:= cMaxHogHealth;
       
  1796                 if gear^.Health < 0 then
       
  1797                     gear^.Health:= 0;
  1794                 RenderHealth(gear^.Hedgehog^);
  1798                 RenderHealth(gear^.Hedgehog^);
  1795                 RecountTeamHealth(gear^.Hedgehog^.Team)
  1799                 RecountTeamHealth(gear^.Hedgehog^.Team)
  1796                 end;
  1800                 end;
  1797             // Why did this do a "setalltoactive" ?
  1801             // Why did this do a "setalltoactive" ?
  1798             //SetAllToActive;
  1802             //SetAllToActive;
  1811         begin
  1815         begin
  1812         gear:= GearByUID(Trunc(lua_tonumber(L, 1)));
  1816         gear:= GearByUID(Trunc(lua_tonumber(L, 1)));
  1813         healthBoost:= Trunc(lua_tonumber(L, 2));
  1817         healthBoost:= Trunc(lua_tonumber(L, 2));
  1814         if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) and (healthBoost >= 1) then
  1818         if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) and (healthBoost >= 1) then
  1815             begin
  1819             begin
  1816             gear^.Health:= gear^.Health + healthBoost;
  1820             inc(gear^.Health, healthBoost);
       
  1821             // Prevent overflow
       
  1822             if (gear^.Health < 0) or (gear^.Health > cMaxHogHealth) then
       
  1823                 gear^.Health:= cMaxHogHealth;
  1817 
  1824 
  1818             RenderHealth(gear^.Hedgehog^);
  1825             RenderHealth(gear^.Hedgehog^);
  1819             RecountTeamHealth(gear^.Hedgehog^.Team);
  1826             RecountTeamHealth(gear^.Hedgehog^.Team);
  1820             if n = 4 then
  1827             if n = 4 then
  1821                 HHHeal(gear^.Hedgehog, healthBoost, lua_toboolean(L, 3), Trunc(lua_tonumber(L, 4)))
  1828                 HHHeal(gear^.Hedgehog, healthBoost, lua_toboolean(L, 3), Trunc(lua_tonumber(L, 4)))
  3919 // other
  3926 // other
  3920 ScriptSetInteger('AMMO_INFINITE', AMMO_INFINITE);
  3927 ScriptSetInteger('AMMO_INFINITE', AMMO_INFINITE);
  3921 ScriptSetInteger('JETPACK_FUEL_INFINITE', JETPACK_FUEL_INFINITE);
  3928 ScriptSetInteger('JETPACK_FUEL_INFINITE', JETPACK_FUEL_INFINITE);
  3922 ScriptSetInteger('BIRDY_ENERGY_INFINITE', BIRDY_ENERGY_INFINITE);
  3929 ScriptSetInteger('BIRDY_ENERGY_INFINITE', BIRDY_ENERGY_INFINITE);
  3923 ScriptSetInteger('NoPointX', NoPointX);
  3930 ScriptSetInteger('NoPointX', NoPointX);
       
  3931 ScriptSetInteger('cMaxHogHealth', cMaxHogHealth);
  3924 
  3932 
  3925 // register gear types
  3933 // register gear types
  3926 for at:= Low(TGearType) to High(TGearType) do
  3934 for at:= Low(TGearType) to High(TGearType) do
  3927     ScriptSetInteger(EnumToStr(at), ord(at));
  3935     ScriptSetInteger(EnumToStr(at), ord(at));
  3928 
  3936