hedgewars/CCHandlers.inc
changeset 783 4f59db6f147d
parent 764 7513452b1d51
child 784 b203147d91b5
equal deleted inserted replaced
782:e2d2b84aa776 783:4f59db6f147d
   292         end
   292         end
   293 end;
   293 end;
   294 
   294 
   295 procedure chSlot(var s: shortstring);
   295 procedure chSlot(var s: shortstring);
   296 var slot: LongWord;
   296 var slot: LongWord;
   297     caSlot, caAmmo: PLongword;
       
   298 begin
   297 begin
   299 if (s[0] <> #1) or CheckNoTeamOrHH then exit;
   298 if (s[0] <> #1) or CheckNoTeamOrHH then exit;
   300 bShowFinger:= false;
   299 bShowFinger:= false;
   301 slot:= byte(s[1]) - 49;
   300 slot:= byte(s[1]) - 49;
   302 if slot > cMaxSlotIndex then exit;
   301 if slot > cMaxSlotIndex then exit;
   303 if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79));
   302 if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79));
   304 with CurrentTeam^ do
   303 with CurrentHedgehog^.Gear^ do
   305      begin
   304      begin
   306      with Hedgehogs[CurrHedgehog] do
   305      Message:= Message or gm_Slot;
   307           begin
   306      MsgParam:= slot
   308           if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0)
   307      end
   309              or ((Gear^.State and gstHHDriven) = 0) then exit;
   308 end;
   310           Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump);
   309 
   311           if CurAmmoGear = nil then begin caSlot:= @CurSlot; caAmmo:= @CurAmmo end
   310 procedure chSetWeapon(var s: shortstring);
   312                                else begin caSlot:= @AltSlot; caAmmo:= @AltAmmo end;
   311 begin
   313           if caSlot^ = slot then
   312 if (s[0] <> #1) or CheckNoTeamOrHH then exit;
   314              begin
   313 if not CurrentTeam^.ExtDriven then SendIPC('w' + char(byte(s[1]) + 79));
   315              inc(caAmmo^);
   314 with CurrentHedgehog^.Gear^ do
   316              if (caAmmo^ > cMaxSlotAmmoIndex) or (Ammo^[slot, caAmmo^].Count = 0) then caAmmo^:= 0
   315      begin
   317              end else
   316      Message:= Message or gm_Weapon;
   318              if Ammo^[slot, 0].Count > 0 then
   317      MsgParam:= byte(s[1]) - ord('a')
   319                 begin
       
   320                 caSlot^:= slot;
       
   321                 caAmmo^:= 0;
       
   322                 end;
       
   323           end;
       
   324      ApplyAmmoChanges(Hedgehogs[CurrHedgehog])
       
   325      end
   318      end
   326 end;
   319 end;
   327 
   320 
   328 procedure doPut(putX, putY: LongInt; fromAI: boolean);
   321 procedure doPut(putX, putY: LongInt; fromAI: boolean);
   329 begin
   322 begin