hedgewars/CCHandlers.inc
changeset 95 1ef5e2c41115
parent 83 207c85fbef51
child 102 c45643d3fd78
equal deleted inserted replaced
94:c6eec0bdb630 95:1ef5e2c41115
   217      begin
   217      begin
   218      {$IFDEF DEBUGFILE}AddFileLog('/+attack: Gear.State = '+inttostr(State));{$ENDIF}
   218      {$IFDEF DEBUGFILE}AddFileLog('/+attack: Gear.State = '+inttostr(State));{$ENDIF}
   219      if ((State and gstHHDriven)<>0)and((State and (gstAttacked or gstHHChooseTarget or gstMoving)) = 0) then
   219      if ((State and gstHHDriven)<>0)and((State and (gstAttacked or gstHHChooseTarget or gstMoving)) = 0) then
   220         begin
   220         begin
   221         FollowGear:= CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear;
   221         FollowGear:= CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear;
   222         if (State and (gstAttacked or gstHHChooseTarget) = 0)and(CurAmmoGear = nil) then
       
   223            State:= State or gstAttacking;
       
   224         if not CurrentTeam.ExtDriven then SendIPC('A');
   222         if not CurrentTeam.ExtDriven then SendIPC('A');
   225         Message:= Message or gm_Attack
   223         Message:= Message or gm_Attack
   226         end
   224         end
   227      end
   225      end
   228 end;
   226 end;
   229 
   227 
   230 procedure chAttack_m(var s: shortstring);
   228 procedure chAttack_m(var s: shortstring);
   231 begin
   229 begin
   232 if CheckNoTeamOrHH then exit;
   230 if CheckNoTeamOrHH then exit;
   233 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^,
   231 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
   234      CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
       
   235      begin
   232      begin
   236       Message:= Message and not gm_Attack;
   233      if not CurrentTeam.ExtDriven and
   237       if not CurrentTeam.ExtDriven then SendIPC('a')
   234         ((Message and gm_Attack) <> 0) then SendIPC('a');
       
   235      Message:= Message and not gm_Attack
   238      end
   236      end
   239 end;
   237 end;
   240 
   238 
   241 procedure chSwitch(var s: shortstring);
   239 procedure chSwitch(var s: shortstring);
   242 begin
   240 begin
   277 
   275 
   278 procedure chSlot(var s: shortstring);
   276 procedure chSlot(var s: shortstring);
   279 var slot: LongWord;
   277 var slot: LongWord;
   280     caSlot, caAmmo: PLongword;
   278     caSlot, caAmmo: PLongword;
   281 begin
   279 begin
   282 if (s[0] <> #1) or (CurrentTeam = nil) then exit;
   280 if (s[0] <> #1) or CheckNoTeamOrHH then exit;
   283 slot:= byte(s[1]) - 49;
   281 slot:= byte(s[1]) - 49;
   284 if slot > cMaxSlotIndex then exit;
   282 if slot > cMaxSlotIndex then exit;
   285 if not CurrentTeam.ExtDriven then SendIPC(char(byte(s[1]) + 79));
   283 if not CurrentTeam.ExtDriven then SendIPC(char(byte(s[1]) + 79));
   286 with CurrentTeam^ do
   284 with CurrentTeam^ do
   287      begin
   285      begin
   319            SDL_GetMouseState(@TargetPoint.X, @TargetPoint.Y);
   317            SDL_GetMouseState(@TargetPoint.X, @TargetPoint.Y);
   320            dec(TargetPoint.X, WorldDx);
   318            dec(TargetPoint.X, WorldDx);
   321            dec(TargetPoint.Y, WorldDy);
   319            dec(TargetPoint.Y, WorldDy);
   322            s[0]:= #9;
   320            s[0]:= #9;
   323            s[1]:= 'p';
   321            s[1]:= 'p';
   324            PInteger(@s[2])^:= TargetPoint.X;
   322            PSmallInt(@s[2])^:= TargetPoint.X;
   325            PInteger(@s[6])^:= TargetPoint.Y;
   323            PSmallInt(@s[4])^:= TargetPoint.Y;
   326            SendIPC(s)
   324            SendIPC(s)
   327            end;
   325            end;
   328         State:= State and not gstHHChooseTarget;
   326         State:= State and not gstHHChooseTarget;
   329         end else if CurrentTeam.ExtDriven then OutError('got /put while not being in choose target mode', true)
   327         end else if CurrentTeam.ExtDriven then OutError('got /put while not being in choose target mode', false)
   330 end;
   328 end;
   331 
   329 
   332 procedure chCapture(var s: shortstring);
   330 procedure chCapture(var s: shortstring);
   333 begin
   331 begin
   334 flagMakeCapture:= true
   332 flagMakeCapture:= true