hedgewars/CCHandlers.inc
changeset 605 2651c3fe4567
parent 604 2f1165467a66
child 606 9d800fdfd3bd
equal deleted inserted replaced
604:2f1165467a66 605:2651c3fe4567
    46    end
    46    end
    47 end;
    47 end;
    48 
    48 
    49 procedure chAddTeam(var s: shortstring);
    49 procedure chAddTeam(var s: shortstring);
    50 var Color: Longword;
    50 var Color: Longword;
       
    51     ts: shortstring;
    51 begin
    52 begin
    52 if isDeveloperMode then
    53 if isDeveloperMode then
    53    begin
    54    begin
    54    ParseCommand('ammstore 93919294221912103323', true);
    55    ParseCommand('ammstore 93919294221912103323', true);
       
    56    SplitBySpace(s, ts);
    55    val(s, Color);
    57    val(s, Color);
    56    TryDo(Color <> 0, 'Error: black team color', true);
    58    TryDo(Color <> 0, 'Error: black team color', true);
    57 
    59 
    58    AddTeam(Color);
    60    AddTeam(Color);
    59 
    61    CurrentTeam^.TeamName:= ts;
    60    if GameType in [gmtDemo, gmtSave] then CurrentTeam^.ExtDriven:= true
    62    if GameType in [gmtDemo, gmtSave] then CurrentTeam^.ExtDriven:= true
    61    end
    63    end
    62 end;
    64 end;
    63 
    65 
    64 procedure chTeamLocal(var s: shortstring);
    66 procedure chTeamLocal(var s: shortstring);
    65 begin
    67 begin
    66 if not isDeveloperMode then exit;
    68 if not isDeveloperMode then exit;
    67 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/rdriven"', true);
    69 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/rdriven"', true);
    68 CurrentTeam^.ExtDriven:= true
    70 CurrentTeam^.ExtDriven:= true
    69 end;
       
    70 
       
    71 procedure chName(var id: shortstring);
       
    72 var s: shortstring;
       
    73 begin
       
    74 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/name"', true);
       
    75 SplitBySpace(id, s);
       
    76 if s[1]='"' then Delete(s, 1, 1);
       
    77 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
       
    78 if id = 'team' then CurrentTeam^.TeamName:= s
       
    79 else if (id[1] = 'h') and (id[2] = 'h')
       
    80      and (id[3] >= '0') and (id[3] <= chr(ord('0')+cMaxHHIndex)) then
       
    81    CurrentTeam^.Hedgehogs[byte(id[3])-48].Name:= s
       
    82 else OutError(errmsgUnknownVariable + ' "' + id + '"', false)
       
    83 end;
    71 end;
    84 
    72 
    85 procedure chGrave(var s: shortstring);
    73 procedure chGrave(var s: shortstring);
    86 begin
    74 begin
    87 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true);
    75 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true);
   107      begin
    95      begin
   108      SplitBySpace(id, s);
    96      SplitBySpace(id, s);
   109      CurrentHedgehog:= @Hedgehogs[HedgehogsNumber];
    97      CurrentHedgehog:= @Hedgehogs[HedgehogsNumber];
   110      val(id, CurrentHedgehog^.BotLevel);
    98      val(id, CurrentHedgehog^.BotLevel);
   111      Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0);
    99      Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0);
       
   100      SplitBySpace(s, id);
   112      val(s, Gear^.Health);
   101      val(s, Gear^.Health);
   113      TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true);
   102      TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true);
   114      PHedgehog(Gear^.Hedgehog)^.Team:= CurrentTeam;
   103      PHedgehog(Gear^.Hedgehog)^.Team:= CurrentTeam;
   115      Hedgehogs[HedgehogsNumber].AmmoStore:= TeamsCount - 1;
   104      Hedgehogs[HedgehogsNumber].AmmoStore:= TeamsCount - 1;
   116      Hedgehogs[HedgehogsNumber].Gear:= Gear;
   105      Hedgehogs[HedgehogsNumber].Gear:= Gear;
       
   106      Hedgehogs[HedgehogsNumber].Name:= id;
   117      inc(HedgehogsNumber)
   107      inc(HedgehogsNumber)
   118      end
   108      end
   119 end;
   109 end;
   120 
   110 
   121 procedure chSetHHCoords(var x: shortstring);
   111 procedure chSetHHCoords(var x: shortstring);