hedgewars/uCommands.pas
changeset 4414 cb90b7f82cd5
parent 4413 46caab3a8f84
child 4555 85150dfb5959
equal deleted inserted replaced
4413:46caab3a8f84 4414:cb90b7f82cd5
    11 procedure initModule;
    11 procedure initModule;
    12 procedure freeModule;
    12 procedure freeModule;
    13 procedure RegisterVariable(Name: shortstring; VType: TVariableType; p: pointer; Trusted: boolean);
    13 procedure RegisterVariable(Name: shortstring; VType: TVariableType; p: pointer; Trusted: boolean);
    14 procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean);
    14 procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean);
    15 procedure StopMessages(Message: Longword);
    15 procedure StopMessages(Message: Longword);
    16 procedure doPut(putX, putY: LongInt; fromAI: boolean);
       
    17 
    16 
    18 implementation
    17 implementation
    19 uses Types, uConsts, uIO, uVariables, uConsole, uUtils, uDebug;
    18 uses Types, uConsts, uVariables, uConsole, uUtils, uDebug;
    20 
    19 
    21 type  PVariable = ^TVariable;
    20 type  PVariable = ^TVariable;
    22       TVariable = record
    21       TVariable = record
    23                      Next: PVariable;
    22                      Next: PVariable;
    24                      Name: string[15];
    23                      Name: string[15];
   112 if (Message and gmUp) <> 0 then ParseCommand('/-up', true) else
   111 if (Message and gmUp) <> 0 then ParseCommand('/-up', true) else
   113 if (Message and gmDown) <> 0 then ParseCommand('/-down', true) else
   112 if (Message and gmDown) <> 0 then ParseCommand('/-down', true) else
   114 if (Message and gmAttack) <> 0 then ParseCommand('/-attack', true)
   113 if (Message and gmAttack) <> 0 then ParseCommand('/-attack', true)
   115 end;
   114 end;
   116 
   115 
   117 
       
   118 procedure doPut(putX, putY: LongInt; fromAI: boolean);
       
   119 begin
       
   120 if CheckNoTeamOrHH or isPaused then exit;
       
   121 if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
       
   122 bShowFinger:= false;
       
   123 if not CurrentTeam^.ExtDriven and bShowAmmoMenu then
       
   124     begin
       
   125     bSelected:= true;
       
   126     exit
       
   127     end;
       
   128 
       
   129 with CurrentHedgehog^.Gear^,
       
   130     CurrentHedgehog^ do
       
   131     if (State and gstHHChooseTarget) <> 0 then
       
   132         begin
       
   133         isCursorVisible:= false;
       
   134         if not CurrentTeam^.ExtDriven then
       
   135             begin
       
   136             if fromAI then
       
   137                 begin
       
   138                 TargetPoint.X:= putX;
       
   139                 TargetPoint.Y:= putY
       
   140                 end else
       
   141                 begin
       
   142                 TargetPoint.X:= CursorPoint.X - WorldDx;
       
   143                 TargetPoint.Y:= cScreenHeight - CursorPoint.Y - WorldDy;
       
   144                 end;
       
   145             SendIPCXY('p', TargetPoint.X, TargetPoint.Y);
       
   146             end
       
   147         else
       
   148             begin
       
   149             TargetPoint.X:= putX;
       
   150             TargetPoint.Y:= putY
       
   151             end;
       
   152         {$IFDEF DEBUGFILE}AddFilelog('put: ' + inttostr(TargetPoint.X) + ', ' + inttostr(TargetPoint.Y));{$ENDIF}
       
   153         State:= State and not gstHHChooseTarget;
       
   154         if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AttackingPut) <> 0 then
       
   155             Message:= Message or gmAttack;
       
   156         end
       
   157     else
       
   158         if CurrentTeam^.ExtDriven then
       
   159             OutError('got /put while not being in choose target mode', false)
       
   160 end;
       
   161 
       
   162 procedure initModule;
   116 procedure initModule;
   163 begin
   117 begin
   164     Variables:= nil;
   118     Variables:= nil;
   165     isDeveloperMode:= true;
   119     isDeveloperMode:= true;
   166 end;
   120 end;