hedgewars/uCommandHandlers.pas
changeset 6580 6155187bf599
parent 6453 11c578d30bd3
child 6700 e04da46ee43c
equal deleted inserted replaced
6579:fc52f7c22c9b 6580:6155187bf599
    29 uses uCommands, uTypes, uVariables, uIO, uDebug, uConsts, uScript, uUtils, SDLh, uRandom, uCaptions;
    29 uses uCommands, uTypes, uVariables, uIO, uDebug, uConsts, uScript, uUtils, SDLh, uRandom, uCaptions;
    30 
    30 
    31 procedure chGenCmd(var s: shortstring);
    31 procedure chGenCmd(var s: shortstring);
    32 begin
    32 begin
    33 case s[1] of
    33 case s[1] of
    34      'R': if ReadyTimeLeft > 1 then 
    34     'R': if ReadyTimeLeft > 1 then 
    35           begin
    35         begin
    36           ReadyTimeLeft:= 1;
    36         ReadyTimeLeft:= 1;
    37           if not CurrentTeam^.ExtDriven then SendIPC('c'+s);
    37         if not CurrentTeam^.ExtDriven then
    38           end
    38             SendIPC('c'+s);
       
    39         end
    39     end
    40     end
    40 end;
    41 end;
    41 
    42 
    42 procedure chQuit(var s: shortstring);
    43 procedure chQuit(var s: shortstring);
    43 const prevGState: TGameState = gsConfirm;
    44 const prevGState: TGameState = gsConfirm;
    46     if (GameState = gsGame) or (GameState = gsChat) then
    47     if (GameState = gsGame) or (GameState = gsChat) then
    47         begin
    48         begin
    48         prevGState:= GameState;
    49         prevGState:= GameState;
    49         GameState:= gsConfirm;
    50         GameState:= gsConfirm;
    50         SDL_ShowCursor(1)
    51         SDL_ShowCursor(1)
    51         end else
    52         end
       
    53     else
    52         if GameState = gsConfirm then
    54         if GameState = gsConfirm then
    53             begin
    55             begin
    54             GameState:= prevGState;
    56             GameState:= prevGState;
    55             SDL_ShowCursor(ord(isPaused))
    57             SDL_ShowCursor(ord(isPaused))
    56             end
    58             end
    86 var i, c: LongInt;
    88 var i, c: LongInt;
    87 begin
    89 begin
    88     if isDeveloperMode then
    90     if isDeveloperMode then
    89         begin
    91         begin
    90         val(s, i, c);
    92         val(s, i, c);
    91         if (c <> 0) or (i = 0) then exit;
    93         if (c <> 0) or (i = 0) then
       
    94             exit;
    92         TryDo(i <= cNetProtoVersion, 'Protocol version mismatch: engine is too old (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true);
    95         TryDo(i <= cNetProtoVersion, 'Protocol version mismatch: engine is too old (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true);
    93         TryDo(i >= cNetProtoVersion, 'Protocol version mismatch: engine is too new (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true);
    96         TryDo(i >= cNetProtoVersion, 'Protocol version mismatch: engine is too new (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true);
    94     end
    97     end
    95 end;
    98 end;
    96 
    99 
    97 procedure chTeamLocal(var s: shortstring);
   100 procedure chTeamLocal(var s: shortstring);
    98 begin
   101 begin
    99 s:= s; // avoid compiler hint
   102 s:= s; // avoid compiler hint
   100 if not isDeveloperMode then exit;
   103 if not isDeveloperMode then
   101 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/rdriven"', true);
   104     exit;
       
   105 if CurrentTeam = nil then
       
   106     OutError(errmsgIncorrectUse + ' "/rdriven"', true);
   102 CurrentTeam^.ExtDriven:= true
   107 CurrentTeam^.ExtDriven:= true
   103 end;
   108 end;
   104 
   109 
   105 procedure chGrave(var s: shortstring);
   110 procedure chGrave(var s: shortstring);
   106 begin
   111 begin
   107 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true);
   112 if CurrentTeam = nil then
   108 if s[1]='"' then Delete(s, 1, 1);
   113     OutError(errmsgIncorrectUse + ' "/grave"', true);
   109 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
   114 if s[1]='"' then
       
   115     Delete(s, 1, 1);
       
   116 if s[byte(s[0])]='"' then
       
   117     Delete(s, byte(s[0]), 1);
   110 CurrentTeam^.GraveName:= s
   118 CurrentTeam^.GraveName:= s
   111 end;
   119 end;
   112 
   120 
   113 procedure chFort(var s: shortstring);
   121 procedure chFort(var s: shortstring);
   114 begin
   122 begin
   115 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/fort"', true);
   123 if CurrentTeam = nil then
   116 if s[1]='"' then Delete(s, 1, 1);
   124     OutError(errmsgIncorrectUse + ' "/fort"', true);
   117 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
   125 if s[1]='"' then
       
   126     Delete(s, 1, 1);
       
   127 if s[byte(s[0])]='"' then
       
   128     Delete(s, byte(s[0]), 1);
   118 CurrentTeam^.FortName:= s
   129 CurrentTeam^.FortName:= s
   119 end;
   130 end;
   120 
   131 
   121 procedure chFlag(var s: shortstring);
   132 procedure chFlag(var s: shortstring);
   122 begin
   133 begin
   123 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/flag"', true);
   134 if CurrentTeam = nil then
   124 if s[1]='"' then Delete(s, 1, 1);
   135     OutError(errmsgIncorrectUse + ' "/flag"', true);
   125 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
   136 if s[1]='"' then
       
   137     Delete(s, 1, 1);
       
   138 if s[byte(s[0])]='"' then
       
   139     Delete(s, byte(s[0]), 1);
   126 CurrentTeam^.flag:= s
   140 CurrentTeam^.flag:= s
   127 end;
   141 end;
   128 
   142 
   129 procedure chScript(var s: shortstring);
   143 procedure chScript(var s: shortstring);
   130 begin
   144 begin
   131 if s[1]='"' then Delete(s, 1, 1);
   145 if s[1]='"' then
   132 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
   146     Delete(s, 1, 1);
       
   147 if s[byte(s[0])]='"' then
       
   148     Delete(s, byte(s[0]), 1);
   133 cScriptName:= s;
   149 cScriptName:= s;
   134 ScriptLoad(s)
   150 ScriptLoad(s)
   135 end;
   151 end;
   136 
   152 
   137 procedure chSetHat(var s: shortstring);
   153 procedure chSetHat(var s: shortstring);
   138 begin
   154 begin
   139 if (not isDeveloperMode) or (CurrentTeam = nil) then exit;
   155 if (not isDeveloperMode) or (CurrentTeam = nil) then exit;
   140 with CurrentTeam^ do
   156 with CurrentTeam^ do
   141     begin
   157     begin
   142     if not CurrentHedgehog^.King then
   158     if not CurrentHedgehog^.King then
   143     if (s = '') or
   159     if (s = '')
   144         (((GameFlags and gfKing) <> 0) and (s = 'crown')) or
   160     or (((GameFlags and gfKing) <> 0) and (s = 'crown'))
   145         ((Length(s) > 39) and (Copy(s,1,8) = 'Reserved') and (Copy(s,9,32) <> PlayerHash)) then
   161     or ((Length(s) > 39) and (Copy(s,1,8) = 'Reserved') and (Copy(s,9,32) <> PlayerHash)) then
   146         CurrentHedgehog^.Hat:= 'NoHat'
   162         CurrentHedgehog^.Hat:= 'NoHat'
   147     else
   163     else
   148         CurrentHedgehog^.Hat:= s
   164         CurrentHedgehog^.Hat:= s
   149     end;
   165     end;
   150 end;
   166 end;
   198 end;
   214 end;
   199 
   215 
   200 procedure chLeft_p(var s: shortstring);
   216 procedure chLeft_p(var s: shortstring);
   201 begin
   217 begin
   202 s:= s; // avoid compiler hint
   218 s:= s; // avoid compiler hint
   203 if CheckNoTeamOrHH or isPaused then exit;
   219 if CheckNoTeamOrHH or isPaused then
   204 if not CurrentTeam^.ExtDriven then SendIPC('L');
   220     exit;
       
   221 if not CurrentTeam^.ExtDriven then
       
   222     SendIPC('L');
   205 bShowFinger:= false;
   223 bShowFinger:= false;
   206 with CurrentHedgehog^.Gear^ do
   224 with CurrentHedgehog^.Gear^ do
   207     Message:= Message or (gmLeft and InputMask);
   225     Message:= Message or (gmLeft and InputMask);
   208     ScriptCall('onLeft');
   226     ScriptCall('onLeft');
   209 end;
   227 end;
   210 
   228 
   211 procedure chLeft_m(var s: shortstring);
   229 procedure chLeft_m(var s: shortstring);
   212 begin
   230 begin
   213 s:= s; // avoid compiler hint
   231 s:= s; // avoid compiler hint
   214 if CheckNoTeamOrHH then exit;
   232 if CheckNoTeamOrHH then
   215 if not CurrentTeam^.ExtDriven then SendIPC('l');
   233     exit;
       
   234 if not CurrentTeam^.ExtDriven then
       
   235     SendIPC('l');
   216 with CurrentHedgehog^.Gear^ do
   236 with CurrentHedgehog^.Gear^ do
   217     Message:= Message and (not (gmLeft and InputMask));
   237     Message:= Message and (not (gmLeft and InputMask));
   218     ScriptCall('onLeftUp');
   238     ScriptCall('onLeftUp');
   219 end;
   239 end;
   220 
   240 
   221 procedure chRight_p(var s: shortstring);
   241 procedure chRight_p(var s: shortstring);
   222 begin
   242 begin
   223 s:= s; // avoid compiler hint
   243 s:= s; // avoid compiler hint
   224 if CheckNoTeamOrHH or isPaused then exit;
   244 if CheckNoTeamOrHH or isPaused then
   225 if not CurrentTeam^.ExtDriven then SendIPC('R');
   245     exit;
       
   246 if not CurrentTeam^.ExtDriven then
       
   247     SendIPC('R');
   226 bShowFinger:= false;
   248 bShowFinger:= false;
   227 with CurrentHedgehog^.Gear^ do
   249 with CurrentHedgehog^.Gear^ do
   228     Message:= Message or (gmRight and InputMask);
   250     Message:= Message or (gmRight and InputMask);
   229     ScriptCall('onRight');
   251     ScriptCall('onRight');
   230 end;
   252 end;
   231 
   253 
   232 procedure chRight_m(var s: shortstring);
   254 procedure chRight_m(var s: shortstring);
   233 begin
   255 begin
   234 s:= s; // avoid compiler hint
   256 s:= s; // avoid compiler hint
   235 if CheckNoTeamOrHH then exit;
   257 if CheckNoTeamOrHH then
   236 if not CurrentTeam^.ExtDriven then SendIPC('r');
   258     exit;
       
   259 if not CurrentTeam^.ExtDriven then
       
   260     SendIPC('r');
   237 with CurrentHedgehog^.Gear^ do
   261 with CurrentHedgehog^.Gear^ do
   238     Message:= Message and (not (gmRight and InputMask));
   262     Message:= Message and (not (gmRight and InputMask));
   239     ScriptCall('onRightUp');
   263     ScriptCall('onRightUp');
   240 end;
   264 end;
   241 
   265 
   242 procedure chUp_p(var s: shortstring);
   266 procedure chUp_p(var s: shortstring);
   243 begin
   267 begin
   244 s:= s; // avoid compiler hint
   268 s:= s; // avoid compiler hint
   245 if CheckNoTeamOrHH or isPaused then exit;
   269 if CheckNoTeamOrHH or isPaused then
   246 if not CurrentTeam^.ExtDriven then SendIPC('U');
   270     exit;
       
   271 if not CurrentTeam^.ExtDriven then
       
   272     SendIPC('U');
   247 bShowFinger:= false;
   273 bShowFinger:= false;
   248 with CurrentHedgehog^.Gear^ do
   274 with CurrentHedgehog^.Gear^ do
   249     Message:= Message or (gmUp and InputMask);
   275     Message:= Message or (gmUp and InputMask);
   250     ScriptCall('onUp');
   276     ScriptCall('onUp');
   251 end;
   277 end;
   252 
   278 
   253 procedure chUp_m(var s: shortstring);
   279 procedure chUp_m(var s: shortstring);
   254 begin
   280 begin
   255 s:= s; // avoid compiler hint
   281 s:= s; // avoid compiler hint
   256 if CheckNoTeamOrHH then exit;
   282 if CheckNoTeamOrHH then
   257 if not CurrentTeam^.ExtDriven then SendIPC('u');
   283     exit;
       
   284 if not CurrentTeam^.ExtDriven then
       
   285     SendIPC('u');
   258 with CurrentHedgehog^.Gear^ do
   286 with CurrentHedgehog^.Gear^ do
   259     Message:= Message and (not (gmUp and InputMask));
   287     Message:= Message and (not (gmUp and InputMask));
   260     ScriptCall('onUpUp');
   288     ScriptCall('onUpUp');
   261 end;
   289 end;
   262 
   290 
   263 procedure chDown_p(var s: shortstring);
   291 procedure chDown_p(var s: shortstring);
   264 begin
   292 begin
   265 s:= s; // avoid compiler hint
   293 s:= s; // avoid compiler hint
   266 if CheckNoTeamOrHH or isPaused then exit;
   294 if CheckNoTeamOrHH or isPaused then
   267 if not CurrentTeam^.ExtDriven then SendIPC('D');
   295     exit;
       
   296 if not CurrentTeam^.ExtDriven then
       
   297     SendIPC('D');
   268 bShowFinger:= false;
   298 bShowFinger:= false;
   269 with CurrentHedgehog^.Gear^ do
   299 with CurrentHedgehog^.Gear^ do
   270     Message:= Message or (gmDown and InputMask);
   300     Message:= Message or (gmDown and InputMask);
   271     ScriptCall('onDown');
   301     ScriptCall('onDown');
   272 end;
   302 end;
   273 
   303 
   274 procedure chDown_m(var s: shortstring);
   304 procedure chDown_m(var s: shortstring);
   275 begin
   305 begin
   276 s:= s; // avoid compiler hint
   306 s:= s; // avoid compiler hint
   277 if CheckNoTeamOrHH then exit;
   307 if CheckNoTeamOrHH then
   278 if not CurrentTeam^.ExtDriven then SendIPC('d');
   308     exit;
       
   309 if not CurrentTeam^.ExtDriven then
       
   310     SendIPC('d');
   279 with CurrentHedgehog^.Gear^ do
   311 with CurrentHedgehog^.Gear^ do
   280     Message:= Message and (not (gmDown and InputMask));
   312     Message:= Message and (not (gmDown and InputMask));
   281     ScriptCall('onDownUp');
   313     ScriptCall('onDownUp');
   282 end;
   314 end;
   283 
   315 
   284 procedure chPrecise_p(var s: shortstring);
   316 procedure chPrecise_p(var s: shortstring);
   285 begin
   317 begin
   286 s:= s; // avoid compiler hint
   318 s:= s; // avoid compiler hint
   287 if CheckNoTeamOrHH or isPaused then exit;
   319 if CheckNoTeamOrHH or isPaused then
   288 if not CurrentTeam^.ExtDriven then SendIPC('Z');
   320     exit;
       
   321 if not CurrentTeam^.ExtDriven then
       
   322     SendIPC('Z');
   289 bShowFinger:= false;
   323 bShowFinger:= false;
   290 with CurrentHedgehog^.Gear^ do
   324 with CurrentHedgehog^.Gear^ do
   291     Message:= Message or (gmPrecise and InputMask);
   325     Message:= Message or (gmPrecise and InputMask);
   292     ScriptCall('onPrecise');
   326     ScriptCall('onPrecise');
   293 end;
   327 end;
   294 
   328 
   295 procedure chPrecise_m(var s: shortstring);
   329 procedure chPrecise_m(var s: shortstring);
   296 begin
   330 begin
   297 s:= s; // avoid compiler hint
   331 s:= s; // avoid compiler hint
   298 if CheckNoTeamOrHH then exit;
   332 if CheckNoTeamOrHH then
   299 if not CurrentTeam^.ExtDriven then SendIPC('z');
   333     exit;
       
   334 if not CurrentTeam^.ExtDriven then
       
   335     SendIPC('z');
   300 with CurrentHedgehog^.Gear^ do
   336 with CurrentHedgehog^.Gear^ do
   301     Message:= Message and (not (gmPrecise and InputMask));
   337     Message:= Message and (not (gmPrecise and InputMask));
   302     ScriptCall('onPreciseUp');
   338     ScriptCall('onPreciseUp');
   303 end;
   339 end;
   304 
   340 
   305 procedure chLJump(var s: shortstring);
   341 procedure chLJump(var s: shortstring);
   306 begin
   342 begin
   307 s:= s; // avoid compiler hint
   343 s:= s; // avoid compiler hint
   308 if CheckNoTeamOrHH or isPaused then exit;
   344 if CheckNoTeamOrHH or isPaused then
   309 if not CurrentTeam^.ExtDriven then SendIPC('j');
   345     exit;
       
   346 if not CurrentTeam^.ExtDriven then
       
   347     SendIPC('j');
   310 bShowFinger:= false;
   348 bShowFinger:= false;
   311 with CurrentHedgehog^.Gear^ do
   349 with CurrentHedgehog^.Gear^ do
   312     Message:= Message or (gmLJump and InputMask);
   350     Message:= Message or (gmLJump and InputMask);
   313     ScriptCall('onLJump');
   351     ScriptCall('onLJump');
   314 end;
   352 end;
   315 
   353 
   316 procedure chHJump(var s: shortstring);
   354 procedure chHJump(var s: shortstring);
   317 begin
   355 begin
   318 s:= s; // avoid compiler hint
   356 s:= s; // avoid compiler hint
   319 if CheckNoTeamOrHH or isPaused then exit;
   357 if CheckNoTeamOrHH or isPaused then
   320 if not CurrentTeam^.ExtDriven then SendIPC('J');
   358     exit;
       
   359 if not CurrentTeam^.ExtDriven then
       
   360     SendIPC('J');
   321 bShowFinger:= false;
   361 bShowFinger:= false;
   322 with CurrentHedgehog^.Gear^ do
   362 with CurrentHedgehog^.Gear^ do
   323     Message:= Message or (gmHJump and InputMask);
   363     Message:= Message or (gmHJump and InputMask);
   324     ScriptCall('onHJump');
   364     ScriptCall('onHJump');
   325 end;
   365 end;
   326 
   366 
   327 procedure chAttack_p(var s: shortstring);
   367 procedure chAttack_p(var s: shortstring);
   328 begin
   368 begin
   329 s:= s; // avoid compiler hint
   369 s:= s; // avoid compiler hint
   330 if CheckNoTeamOrHH or isPaused then exit;
   370 if CheckNoTeamOrHH or isPaused then
       
   371     exit;
   331 bShowFinger:= false;
   372 bShowFinger:= false;
   332 with CurrentHedgehog^.Gear^ do
   373 with CurrentHedgehog^.Gear^ do
   333     begin
   374     begin
   334     AddFileLog('/+attack: hedgehog''s Gear^.State = '+inttostr(State));
   375     AddFileLog('/+attack: hedgehog''s Gear^.State = '+inttostr(State));
   335     if ((State and gstHHDriven) <> 0) then
   376     if ((State and gstHHDriven) <> 0) then
   336         begin
   377         begin
   337         FollowGear:= CurrentHedgehog^.Gear;
   378         FollowGear:= CurrentHedgehog^.Gear;
   338         if not CurrentTeam^.ExtDriven then SendIPC('A');
   379         if not CurrentTeam^.ExtDriven then
       
   380             SendIPC('A');
   339         Message:= Message or (gmAttack and InputMask);
   381         Message:= Message or (gmAttack and InputMask);
   340         ScriptCall('onAttack');
   382         ScriptCall('onAttack');
   341         end
   383         end
   342     end
   384     end
   343 end;
   385 end;
   344 
   386 
   345 procedure chAttack_m(var s: shortstring);
   387 procedure chAttack_m(var s: shortstring);
   346 begin
   388 begin
   347 s:= s; // avoid compiler hint
   389 s:= s; // avoid compiler hint
   348 if CheckNoTeamOrHH then exit;
   390 if CheckNoTeamOrHH then
       
   391     exit;
   349 with CurrentHedgehog^.Gear^ do
   392 with CurrentHedgehog^.Gear^ do
   350     begin
   393     begin
   351     if not CurrentTeam^.ExtDriven and
   394     if not CurrentTeam^.ExtDriven and
   352         ((Message and gmAttack) <> 0) then SendIPC('a');
   395         ((Message and gmAttack) <> 0) then
       
   396             SendIPC('a');
   353     Message:= Message and (not (gmAttack and InputMask));
   397     Message:= Message and (not (gmAttack and InputMask));
   354     ScriptCall('onAttackUp');
   398     ScriptCall('onAttackUp');
   355     end
   399     end
   356 end;
   400 end;
   357 
   401 
   358 procedure chSwitch(var s: shortstring);
   402 procedure chSwitch(var s: shortstring);
   359 begin
   403 begin
   360 s:= s; // avoid compiler hint
   404 s:= s; // avoid compiler hint
   361 if CheckNoTeamOrHH or isPaused then exit;
   405 if CheckNoTeamOrHH or isPaused then
   362 if not CurrentTeam^.ExtDriven then SendIPC('S');
   406     exit;
       
   407 if not CurrentTeam^.ExtDriven then
       
   408     SendIPC('S');
   363 bShowFinger:= false;
   409 bShowFinger:= false;
   364 with CurrentHedgehog^.Gear^ do
   410 with CurrentHedgehog^.Gear^ do
   365     Message:= Message or (gmSwitch and InputMask);
   411     Message:= Message or (gmSwitch and InputMask);
   366     ScriptCall('onSwitch');
   412     ScriptCall('onSwitch');
   367 end;
   413 end;
   369 procedure chNextTurn(var s: shortstring);
   415 procedure chNextTurn(var s: shortstring);
   370 begin
   416 begin
   371     s:= s; // avoid compiler hint
   417     s:= s; // avoid compiler hint
   372     TryDo(AllInactive, '/nextturn called when not all gears are inactive', true);
   418     TryDo(AllInactive, '/nextturn called when not all gears are inactive', true);
   373 
   419 
   374     if not CurrentTeam^.ExtDriven then SendIPC('N');
   420     if not CurrentTeam^.ExtDriven then
       
   421         SendIPC('N');
   375     AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks));
   422     AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks));
   376 end;
   423 end;
   377 
   424 
   378 procedure chTimer(var s: shortstring);
   425 procedure chTimer(var s: shortstring);
   379 begin
   426 begin
   380 if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or CheckNoTeamOrHH then exit;
   427 if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or CheckNoTeamOrHH then
   381 
   428     exit;
   382 if not CurrentTeam^.ExtDriven then SendIPC(s);
   429 
       
   430 if not CurrentTeam^.ExtDriven then
       
   431     SendIPC(s);
   383 bShowFinger:= false;
   432 bShowFinger:= false;
   384 with CurrentHedgehog^.Gear^ do
   433 with CurrentHedgehog^.Gear^ do
   385     begin
   434     begin
   386     Message:= Message or (gmTimer and InputMask);
   435     Message:= Message or (gmTimer and InputMask);
   387     MsgParam:= byte(s[1]) - ord('0');
   436     MsgParam:= byte(s[1]) - ord('0');
   390 end;
   439 end;
   391 
   440 
   392 procedure chSlot(var s: shortstring);
   441 procedure chSlot(var s: shortstring);
   393 var slot: LongWord;
   442 var slot: LongWord;
   394 begin
   443 begin
   395 if (s[0] <> #1) or CheckNoTeamOrHH then exit;
   444 if (s[0] <> #1) or CheckNoTeamOrHH then
       
   445     exit;
   396 slot:= byte(s[1]) - 49;
   446 slot:= byte(s[1]) - 49;
   397 if slot > cMaxSlotIndex then exit;
   447 if slot > cMaxSlotIndex then
   398 if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79));
   448     exit;
       
   449 if not CurrentTeam^.ExtDriven then
       
   450     SendIPC(char(byte(s[1]) + 79));
   399 bShowFinger:= false;
   451 bShowFinger:= false;
   400 with CurrentHedgehog^.Gear^ do
   452 with CurrentHedgehog^.Gear^ do
   401     begin
   453     begin
   402     Message:= Message or (gmSlot and InputMask);
   454     Message:= Message or (gmSlot and InputMask);
   403     MsgParam:= slot; 
   455     MsgParam:= slot; 
   405     end
   457     end
   406 end;
   458 end;
   407 
   459 
   408 procedure chSetWeapon(var s: shortstring);
   460 procedure chSetWeapon(var s: shortstring);
   409 begin
   461 begin
   410     if (s[0] <> #1) or CheckNoTeamOrHH then exit;
   462     if (s[0] <> #1) or CheckNoTeamOrHH then
   411 
   463         exit;
   412     if TAmmoType(s[1]) > High(TAmmoType) then exit;
   464 
   413 
   465     if TAmmoType(s[1]) > High(TAmmoType) then
   414     if not CurrentTeam^.ExtDriven then SendIPC('w' + s);
   466         exit;
       
   467 
       
   468     if not CurrentTeam^.ExtDriven then
       
   469         SendIPC('w' + s);
   415 
   470 
   416     with CurrentHedgehog^.Gear^ do
   471     with CurrentHedgehog^.Gear^ do
   417     begin
   472         begin
   418         Message:= Message or (gmWeapon and InputMask);
   473         Message:= Message or (gmWeapon and InputMask);
   419         MsgParam:= byte(s[1]);
   474         MsgParam:= byte(s[1]);
   420     ScriptCall('onSetWeapon');
   475         ScriptCall('onSetWeapon');
   421     end;
   476         end;
   422 end;
   477 end;
   423 
   478 
   424 procedure chTaunt(var s: shortstring);
   479 procedure chTaunt(var s: shortstring);
   425 begin
   480 begin
   426 if (s[0] <> #1) or CheckNoTeamOrHH then exit;
   481 if (s[0] <> #1) or CheckNoTeamOrHH then
   427 
   482     exit;
   428 if TWave(s[1]) > High(TWave) then exit;
   483 
   429 
   484 if TWave(s[1]) > High(TWave) then
   430 if not CurrentTeam^.ExtDriven then SendIPC('t' + s);
   485     exit;
       
   486 
       
   487 if not CurrentTeam^.ExtDriven then
       
   488     SendIPC('t' + s);
   431 
   489 
   432 with CurrentHedgehog^.Gear^ do
   490 with CurrentHedgehog^.Gear^ do
   433     begin
   491     begin
   434     Message:= Message or (gmAnimate and InputMask);
   492     Message:= Message or (gmAnimate and InputMask);
   435     MsgParam:= byte(s[1]) ; 
   493     MsgParam:= byte(s[1]) ; 
   470 end;
   528 end;
   471 
   529 
   472 procedure chSetTheme(var s: shortstring);
   530 procedure chSetTheme(var s: shortstring);
   473 begin
   531 begin
   474 if isDeveloperMode then
   532 if isDeveloperMode then
   475 begin
   533     begin
   476 UserPathz[ptCurrTheme]:= UserPathz[ptThemes] + '/' + s;
   534     UserPathz[ptCurrTheme]:= UserPathz[ptThemes] + '/' + s;
   477 Pathz[ptCurrTheme]:= Pathz[ptThemes] + '/' + s;
   535     Pathz[ptCurrTheme]:= Pathz[ptThemes] + '/' + s;
   478 Theme:= s;
   536     Theme:= s;
   479 InitStepsFlags:= InitStepsFlags or cifTheme
   537     InitStepsFlags:= InitStepsFlags or cifTheme
   480 end
   538     end
   481 end;
   539 end;
   482 
   540 
   483 procedure chSetSeed(var s: shortstring);
   541 procedure chSetSeed(var s: shortstring);
   484 begin
   542 begin
   485 if isDeveloperMode then
   543 if isDeveloperMode then
   486 begin
   544     begin
   487 SetRandomSeed(s);
   545     SetRandomSeed(s);
   488 cSeed:= s;
   546     cSeed:= s;
   489 InitStepsFlags:= InitStepsFlags or cifRandomize
   547     InitStepsFlags:= InitStepsFlags or cifRandomize
   490 end
   548     end
   491 end;
   549     end;
   492 
   550 
   493 procedure chAmmoMenu(var s: shortstring);
   551 procedure chAmmoMenu(var s: shortstring);
   494 begin
   552 begin
   495 s:= s; // avoid compiler hint
   553 s:= s; // avoid compiler hint
   496 if CheckNoTeamOrHH then
   554 if CheckNoTeamOrHH then
   500     with CurrentTeam^ do
   558     with CurrentTeam^ do
   501         with Hedgehogs[CurrHedgehog] do
   559         with Hedgehogs[CurrHedgehog] do
   502             begin
   560             begin
   503             bSelected:= false;
   561             bSelected:= false;
   504 
   562 
   505             if bShowAmmoMenu then bShowAmmoMenu:= false
   563             if bShowAmmoMenu then
   506             else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or
   564                 bShowAmmoMenu:= false
   507                     ((MultiShootAttacks > 0) and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) = 0)) or
   565             else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0)
   508                     ((Gear^.State and gstHHDriven) = 0) then begin end else bShowAmmoMenu:= true
   566             or ((MultiShootAttacks > 0) and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) = 0))
       
   567             or ((Gear^.State and gstHHDriven) = 0) then
       
   568                 begin
       
   569                 end
       
   570             else
       
   571                 bShowAmmoMenu:= true
   509             end;
   572             end;
   510     end
   573     end
   511 end;
   574 end;
   512 
   575 
   513 procedure chVol_p(var s: shortstring);
   576 procedure chVol_p(var s: shortstring);
   523 end;
   586 end;
   524 
   587 
   525 procedure chFindhh(var s: shortstring);
   588 procedure chFindhh(var s: shortstring);
   526 begin
   589 begin
   527 s:= s; // avoid compiler hint
   590 s:= s; // avoid compiler hint
   528 if CheckNoTeamOrHH or isPaused then exit;
   591 if CheckNoTeamOrHH or isPaused then
       
   592     exit;
   529 
   593 
   530 if FollowGear <> nil then
   594 if FollowGear <> nil then
   531     begin
   595     begin
   532     AddCaption('Auto Camera Off', $CCCCCC, capgrpVolume);
   596     AddCaption('Auto Camera Off', $CCCCCC, capgrpVolume);
   533     autoCameraOn:= false
   597     autoCameraOn:= false
   534     end
   598     end
   535     else begin
   599     else
       
   600         begin
   536     AddCaption('Auto Camera On', $CCCCCC, capgrpVolume);
   601     AddCaption('Auto Camera On', $CCCCCC, capgrpVolume);
   537     bShowFinger:= true;
   602     bShowFinger:= true;
   538     if not CurrentHedgehog^.Unplaced then FollowGear:= CurrentHedgehog^.Gear;
   603     if not CurrentHedgehog^.Unplaced then
       
   604         FollowGear:= CurrentHedgehog^.Gear;
   539     autoCameraOn:= true
   605     autoCameraOn:= true
   540     end
   606     end
   541 end;
   607 end;
   542 
   608 
   543 procedure chPause(var s: shortstring);
   609 procedure chPause(var s: shortstring);
   553 end;
   619 end;
   554 
   620 
   555 procedure chRotateMask(var s: shortstring);
   621 procedure chRotateMask(var s: shortstring);
   556 begin
   622 begin
   557 s:= s; // avoid compiler hint
   623 s:= s; // avoid compiler hint
   558 if ((GameFlags and gfInvulnerable) = 0) then cTagsMask:= cTagsMasks[cTagsMask] else cTagsMask:= cTagsMasksNoHealth[cTagsMask];
   624 if ((GameFlags and gfInvulnerable) = 0) then
       
   625     cTagsMask:= cTagsMasks[cTagsMask]
       
   626 else
       
   627     cTagsMask:= cTagsMasksNoHealth[cTagsMask];
   559 end;
   628 end;
   560 
   629 
   561 procedure chSpeedup_p(var s: shortstring);
   630 procedure chSpeedup_p(var s: shortstring);
   562 begin
   631 begin
   563 s:= s; // avoid compiler hint
   632 s:= s; // avoid compiler hint