hedgewars/uIO.pas
changeset 4414 cb90b7f82cd5
parent 4409 a752e543d7b4
child 4467 adedeec8f18f
--- a/hedgewars/uIO.pas	Mon Nov 22 21:43:31 2010 +0300
+++ b/hedgewars/uIO.pas	Mon Nov 22 21:49:57 2010 +0300
@@ -41,6 +41,7 @@
 procedure InitIPC;
 procedure CloseIPC;
 procedure NetGetNextCmd;
+procedure doPut(putX, putY: LongInt; fromAI: boolean);
 
 implementation
 uses uConsole, uConsts, uVariables, uCommands, uUtils, uDebug;
@@ -366,6 +367,50 @@
     SendIPC('E' + s);
 end;
 
+procedure doPut(putX, putY: LongInt; fromAI: boolean);
+begin
+if CheckNoTeamOrHH or isPaused then exit;
+if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
+bShowFinger:= false;
+if not CurrentTeam^.ExtDriven and bShowAmmoMenu then
+    begin
+    bSelected:= true;
+    exit
+    end;
+
+with CurrentHedgehog^.Gear^,
+    CurrentHedgehog^ do
+    if (State and gstHHChooseTarget) <> 0 then
+        begin
+        isCursorVisible:= false;
+        if not CurrentTeam^.ExtDriven then
+            begin
+            if fromAI then
+                begin
+                TargetPoint.X:= putX;
+                TargetPoint.Y:= putY
+                end else
+                begin
+                TargetPoint.X:= CursorPoint.X - WorldDx;
+                TargetPoint.Y:= cScreenHeight - CursorPoint.Y - WorldDy;
+                end;
+            SendIPCXY('p', TargetPoint.X, TargetPoint.Y);
+            end
+        else
+            begin
+            TargetPoint.X:= putX;
+            TargetPoint.Y:= putY
+            end;
+        {$IFDEF DEBUGFILE}AddFilelog('put: ' + inttostr(TargetPoint.X) + ', ' + inttostr(TargetPoint.Y));{$ENDIF}
+        State:= State and not gstHHChooseTarget;
+        if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AttackingPut) <> 0 then
+            Message:= Message or gmAttack;
+        end
+    else
+        if CurrentTeam^.ExtDriven then
+            OutError('got /put while not being in choose target mode', false)
+end;
+
 procedure initModule;
 begin
     RegisterVariable('fatal', vtCommand, @chFatalError, true );