hedgewars/uCommands.pas
changeset 4413 46caab3a8f84
parent 4406 beb4de0af990
child 4414 cb90b7f82cd5
equal deleted inserted replaced
4412:c9a78ba03679 4413:46caab3a8f84
    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);
    16 procedure doPut(putX, putY: LongInt; fromAI: boolean);
    17 
    17 
    18 implementation
    18 implementation
    19 uses Types, uConsts, uIO, uMobile,
    19 uses Types, uConsts, uIO, uVariables, uConsole, uUtils, uDebug;
    20      uRandom, SDLh, uScript, uTypes,
       
    21      uVariables, uConsole, uUtils, uDebug;
       
    22 
    20 
    23 type  PVariable = ^TVariable;
    21 type  PVariable = ^TVariable;
    24       TVariable = record
    22       TVariable = record
    25                      Next: PVariable;
    23                      Next: PVariable;
    26                      Name: string[15];
    24                      Name: string[15];
   114 if (Message and gmUp) <> 0 then ParseCommand('/-up', true) else
   112 if (Message and gmUp) <> 0 then ParseCommand('/-up', true) else
   115 if (Message and gmDown) <> 0 then ParseCommand('/-down', true) else
   113 if (Message and gmDown) <> 0 then ParseCommand('/-down', true) else
   116 if (Message and gmAttack) <> 0 then ParseCommand('/-attack', true)
   114 if (Message and gmAttack) <> 0 then ParseCommand('/-attack', true)
   117 end;
   115 end;
   118 
   116 
   119 {$INCLUDE "CCHandlers.inc"}
   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;
   120 
   161 
   121 procedure initModule;
   162 procedure initModule;
   122 begin
   163 begin
   123     Variables:= nil;
   164     Variables:= nil;
   124     isDeveloperMode:= true;
   165     isDeveloperMode:= true;
   125 
       
   126     // NOTE: please, keep most frequently used commands on bottom
       
   127     RegisterVariable('flag'    , vtCommand, @chFlag         , false);
       
   128     RegisterVariable('script'  , vtCommand, @chScript       , false);
       
   129     RegisterVariable('proto'   , vtCommand, @chCheckProto   , true );
       
   130     RegisterVariable('spectate', vtBoolean, @fastUntilLag   , false);
       
   131     RegisterVariable('capture' , vtCommand, @chCapture      , true );
       
   132     RegisterVariable('rotmask' , vtCommand, @chRotateMask   , true );
       
   133     RegisterVariable('rdriven' , vtCommand, @chTeamLocal    , false);
       
   134     RegisterVariable('map'     , vtCommand, @chSetMap       , false);
       
   135     RegisterVariable('theme'   , vtCommand, @chSetTheme     , false);
       
   136     RegisterVariable('seed'    , vtCommand, @chSetSeed      , false);
       
   137     RegisterVariable('template_filter', vtLongInt, @cTemplateFilter, false);
       
   138     RegisterVariable('mapgen'  , vtLongInt, @cMapGen        , false);
       
   139     RegisterVariable('maze_size',vtLongInt, @cMazeSize      , false);
       
   140     RegisterVariable('delay'   , vtLongInt, @cInactDelay    , false);
       
   141     RegisterVariable('ready'   , vtLongInt, @cReadyDelay    , false);
       
   142     RegisterVariable('casefreq', vtLongInt, @cCaseFactor    , false);
       
   143     RegisterVariable('healthprob', vtLongInt, @cHealthCaseProb, false);
       
   144     RegisterVariable('hcaseamount', vtLongInt, @cHealthCaseAmount, false);
       
   145     RegisterVariable('sd_turns', vtLongInt, @cSuddenDTurns  , false);
       
   146     RegisterVariable('waterrise', vtLongInt, @cWaterRise    , false);
       
   147     RegisterVariable('healthdec', vtLongInt, @cHealthDecrease, false);
       
   148     RegisterVariable('damagepct',vtLongInt, @cDamagePercent , false);
       
   149     RegisterVariable('ropepct' , vtLongInt, @cRopePercent   , false);
       
   150     RegisterVariable('minedudpct',vtLongInt,@cMineDudPercent, false);
       
   151     RegisterVariable('minesnum', vtLongInt, @cLandMines     , false);
       
   152     RegisterVariable('explosives',vtLongInt,@cExplosives    , false);
       
   153     RegisterVariable('gmflags' , vtLongInt, @GameFlags      , false);
       
   154     RegisterVariable('trflags' , vtLongInt, @TrainingFlags  , false);
       
   155     RegisterVariable('turntime', vtLongInt, @cHedgehogTurnTime, false);
       
   156     RegisterVariable('minestime',vtLongInt, @cMinesTime     , false);
       
   157     RegisterVariable('fort'    , vtCommand, @chFort         , false);
       
   158     RegisterVariable('grave'   , vtCommand, @chGrave        , false);
       
   159     RegisterVariable('hat'     , vtCommand, @chSetHat       , false);
       
   160     RegisterVariable('quit'    , vtCommand, @chQuit         , true );
       
   161     RegisterVariable('confirm' , vtCommand, @chConfirm      , true );
       
   162     RegisterVariable('+speedup', vtCommand, @chSpeedup_p    , true );
       
   163     RegisterVariable('-speedup', vtCommand, @chSpeedup_m    , true );
       
   164     RegisterVariable('zoomin'  , vtCommand, @chZoomIn       , true );
       
   165     RegisterVariable('zoomout' , vtCommand, @chZoomOut      , true );
       
   166     RegisterVariable('zoomreset',vtCommand, @chZoomReset    , true );
       
   167     RegisterVariable('ammomenu', vtCommand, @chAmmoMenu     , true);
       
   168     RegisterVariable('+precise', vtCommand, @chPrecise_p    , false);
       
   169     RegisterVariable('-precise', vtCommand, @chPrecise_m    , false);
       
   170     RegisterVariable('+left'   , vtCommand, @chLeft_p       , false);
       
   171     RegisterVariable('-left'   , vtCommand, @chLeft_m       , false);
       
   172     RegisterVariable('+right'  , vtCommand, @chRight_p      , false);
       
   173     RegisterVariable('-right'  , vtCommand, @chRight_m      , false);
       
   174     RegisterVariable('+up'     , vtCommand, @chUp_p         , false);
       
   175     RegisterVariable('-up'     , vtCommand, @chUp_m         , false);
       
   176     RegisterVariable('+down'   , vtCommand, @chDown_p       , false);
       
   177     RegisterVariable('-down'   , vtCommand, @chDown_m       , false);
       
   178     RegisterVariable('+attack' , vtCommand, @chAttack_p     , false);
       
   179     RegisterVariable('-attack' , vtCommand, @chAttack_m     , false);
       
   180     RegisterVariable('switch'  , vtCommand, @chSwitch       , false);
       
   181     RegisterVariable('nextturn', vtCommand, @chNextTurn     , false);
       
   182     RegisterVariable('timer'   , vtCommand, @chTimer        , false);
       
   183     RegisterVariable('taunt'   , vtCommand, @chTaunt        , false);
       
   184     RegisterVariable('setweap' , vtCommand, @chSetWeapon    , false);
       
   185     RegisterVariable('slot'    , vtCommand, @chSlot         , false);
       
   186     RegisterVariable('put'     , vtCommand, @chPut          , false);
       
   187     RegisterVariable('ljump'   , vtCommand, @chLJump        , false);
       
   188     RegisterVariable('hjump'   , vtCommand, @chHJump        , false);
       
   189     RegisterVariable('+volup'  , vtCommand, @chVol_p        , true );
       
   190     RegisterVariable('-volup'  , vtCommand, @chVol_m        , true );
       
   191     RegisterVariable('+voldown', vtCommand, @chVol_m        , true );
       
   192     RegisterVariable('-voldown', vtCommand, @chVol_p        , true );
       
   193     RegisterVariable('findhh'  , vtCommand, @chFindhh       , true );
       
   194     RegisterVariable('pause'   , vtCommand, @chPause        , true );
       
   195     RegisterVariable('+cur_u'  , vtCommand, @chCurU_p       , true );
       
   196     RegisterVariable('-cur_u'  , vtCommand, @chCurU_m       , true );
       
   197     RegisterVariable('+cur_d'  , vtCommand, @chCurD_p       , true );
       
   198     RegisterVariable('-cur_d'  , vtCommand, @chCurD_m       , true );
       
   199     RegisterVariable('+cur_l'  , vtCommand, @chCurL_p       , true );
       
   200     RegisterVariable('-cur_l'  , vtCommand, @chCurL_m       , true );
       
   201     RegisterVariable('+cur_r'  , vtCommand, @chCurR_p       , true );
       
   202     RegisterVariable('-cur_r'  , vtCommand, @chCurR_m       , true );
       
   203 end;
   166 end;
   204 
   167 
   205 procedure freeModule;
   168 procedure freeModule;
   206 var t, tt: PVariable;
   169 var t, tt: PVariable;
   207 begin
   170 begin