hedgewars/uAmmos.pas
changeset 7374 514138949c76
parent 7341 d70478d265ec
child 7426 55b49cc1f33a
equal deleted inserted replaced
7304:8b3575750cd2 7374:514138949c76
    30 procedure SetAmmoProbability(var s: shortstring);
    30 procedure SetAmmoProbability(var s: shortstring);
    31 procedure SetAmmoDelay(var s: shortstring);
    31 procedure SetAmmoDelay(var s: shortstring);
    32 procedure SetAmmoReinforcement(var s: shortstring);
    32 procedure SetAmmoReinforcement(var s: shortstring);
    33 procedure AssignStores;
    33 procedure AssignStores;
    34 procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType);
    34 procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType);
       
    35 procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType; amt: LongWord);
    35 procedure SetAmmo(var Hedgehog: THedgehog; ammo: TAmmoType; cnt: LongWord);
    36 procedure SetAmmo(var Hedgehog: THedgehog; ammo: TAmmoType; cnt: LongWord);
    36 function  HHHasAmmo(var Hedgehog: THedgehog; Ammo: TAmmoType): LongWord;
    37 function  HHHasAmmo(var Hedgehog: THedgehog; Ammo: TAmmoType): LongWord;
    37 procedure PackAmmo(Ammo: PHHAmmo; Slot: LongInt);
    38 procedure PackAmmo(Ammo: PHHAmmo; Slot: LongInt);
    38 procedure OnUsedAmmo(var Hedgehog: THedgehog);
    39 procedure OnUsedAmmo(var Hedgehog: THedgehog);
    39 procedure ApplyAngleBounds(var Hedgehog: THedgehog; AmmoType: TAmmoType);
    40 procedure ApplyAngleBounds(var Hedgehog: THedgehog; AmmoType: TAmmoType);
   186                     Hedgehogs[i].CurAmmoType:= amNothing
   187                     Hedgehogs[i].CurAmmoType:= amNothing
   187                 end
   188                 end
   188         end
   189         end
   189 end;
   190 end;
   190 
   191 
   191 procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType);
   192 procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType; amt: LongWord);
   192 var cnt: LongWord;
   193 var cnt: LongWord;
   193     a: PAmmo;
   194     a: PAmmo;
   194 begin
   195 begin
   195 a:= GetAmmoEntry(Hedgehog, ammo);
   196 a:= GetAmmoEntry(Hedgehog, ammo);
   196 if (a^.AmmoType <> amNothing) then
   197 if (a^.AmmoType <> amNothing) then
   197     cnt:= a^.Count
   198     cnt:= a^.Count
   198 else
   199 else
   199     cnt:= 0;
   200     cnt:= 0;
   200 if (cnt <> AMMO_INFINITE) then
   201 if (cnt <> AMMO_INFINITE) then
   201     begin
   202     begin
   202     inc(cnt, Ammoz[ammo].NumberInCase);
   203     inc(cnt, amt);
   203     SetAmmo(Hedgehog, ammo, cnt)
   204     SetAmmo(Hedgehog, ammo, cnt)
   204     end
   205     end
       
   206 end;
       
   207 
       
   208 procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType);
       
   209 begin
       
   210     AddAmmo(Hedgehog, ammo, Ammoz[ammo].NumberInCase);
   205 end;
   211 end;
   206 
   212 
   207 procedure SetAmmo(var Hedgehog: THedgehog; ammo: TAmmoType; cnt: LongWord);
   213 procedure SetAmmo(var Hedgehog: THedgehog; ammo: TAmmoType; cnt: LongWord);
   208 var ammos: TAmmoCounts;
   214 var ammos: TAmmoCounts;
   209     slot, ami: LongInt;
   215     slot, ami: LongInt;
   295     end;
   301     end;
   296 end;
   302 end;
   297 
   303 
   298 procedure ApplyAngleBounds(var Hedgehog: THedgehog; AmmoType: TAmmoType);
   304 procedure ApplyAngleBounds(var Hedgehog: THedgehog; AmmoType: TAmmoType);
   299 begin
   305 begin
   300 with Hedgehog do
   306 if Hedgehog.Gear <> nil then
   301     begin
   307     with Hedgehog do
   302     CurMinAngle:= Ammoz[AmmoType].minAngle;
   308         begin
   303     if Ammoz[AmmoType].maxAngle <> 0 then
   309         CurMinAngle:= Ammoz[AmmoType].minAngle;
   304         CurMaxAngle:= Ammoz[AmmoType].maxAngle
   310         if Ammoz[AmmoType].maxAngle <> 0 then
   305     else
   311             CurMaxAngle:= Ammoz[AmmoType].maxAngle
   306         CurMaxAngle:= cMaxAngle;
   312         else
   307 
   313             CurMaxAngle:= cMaxAngle;
   308     with Hedgehog.Gear^ do
   314 
   309         begin
   315         with Hedgehog.Gear^ do
   310         if Angle < CurMinAngle then
   316             begin
   311             Angle:= CurMinAngle;
   317             if Angle < CurMinAngle then
   312         if Angle > CurMaxAngle then
   318                 Angle:= CurMinAngle;
   313             Angle:= CurMaxAngle;
   319             if Angle > CurMaxAngle then
       
   320                 Angle:= CurMaxAngle;
       
   321             end
   314         end
   322         end
   315     end
       
   316 end;
   323 end;
   317 
   324 
   318 procedure SwitchToFirstLegalAmmo(var Hedgehog: THedgehog);
   325 procedure SwitchToFirstLegalAmmo(var Hedgehog: THedgehog);
   319 var slot, ammoidx: LongWord;
   326 var slot, ammoidx: LongWord;
   320 begin
   327 begin
   372         if (Propz and ammoprop_Timerable) <> 0 then
   379         if (Propz and ammoprop_Timerable) <> 0 then
   373             s:= s + ', ' + IntToStr(Timer div 1000) + ' ' + trammo[sidSeconds];
   380             s:= s + ', ' + IntToStr(Timer div 1000) + ' ' + trammo[sidSeconds];
   374         AddCaption(s, Team^.Clan^.Color, capgrpAmmoinfo);
   381         AddCaption(s, Team^.Clan^.Color, capgrpAmmoinfo);
   375         if (Propz and ammoprop_NeedTarget) <> 0 then
   382         if (Propz and ammoprop_NeedTarget) <> 0 then
   376             begin
   383             begin
   377             Gear^.State:= Gear^.State or      gstHHChooseTarget;
   384             if Gear <> nil then Gear^.State:= Gear^.State or      gstHHChooseTarget;
   378             isCursorVisible:= true
   385             isCursorVisible:= true
   379             end
   386             end
   380         else
   387         else
   381             begin
   388             begin
   382             Gear^.State:= Gear^.State and not gstHHChooseTarget;
   389             if Gear <> nil then Gear^.State:= Gear^.State and not gstHHChooseTarget;
   383             isCursorVisible:= false
   390             isCursorVisible:= false
   384             end;
   391             end;
   385         end
   392         end
   386     end;
   393     end;
   387 end;
   394 end;