hedgewars/uTeams.pas
changeset 8370 0c79946e96f8
parent 8351 f895be37b607
child 8444 75db7bb8dce8
child 8560 134a098235fa
equal deleted inserted replaced
8369:31033e521653 8370:0c79946e96f8
    38 function  CheckForWin: boolean;
    38 function  CheckForWin: boolean;
    39 procedure TeamGoneEffect(var Team: TTeam);
    39 procedure TeamGoneEffect(var Team: TTeam);
    40 procedure SwitchCurrentHedgehog(newHog: PHedgehog);
    40 procedure SwitchCurrentHedgehog(newHog: PHedgehog);
    41 
    41 
    42 implementation
    42 implementation
    43 uses uLocale, uAmmos, uChat, uVariables, uUtils, uIO, uCaptions, uCommands, uDebug, uScript,
    43 uses uLocale, uAmmos, uChat, uVariables, uUtils, uIO, uCaptions, uCommands, uDebug,
    44     uGearsUtils, uGearsList
    44     uGearsUtils, uGearsList
    45     {$IFDEF USE_TOUCH_INTERFACE}, uTouch{$ENDIF};
    45     {$IFDEF USE_TOUCH_INTERFACE}, uTouch{$ENDIF};
    46 
    46 
    47 var MaxTeamHealth: LongInt;
    47 var MaxTeamHealth: LongInt;
    48     GameOver: boolean;
    48     GameOver: boolean;
   501 end;
   501 end;
   502 
   502 
   503 procedure chAddHH(var id: shortstring);
   503 procedure chAddHH(var id: shortstring);
   504 var s: shortstring;
   504 var s: shortstring;
   505     Gear: PGear;
   505     Gear: PGear;
   506     c: LongInt;
       
   507 begin
   506 begin
   508 s:= '';
   507 s:= '';
   509 if (not isDeveloperMode) or (CurrentTeam = nil) then
   508 if (not isDeveloperMode) or (CurrentTeam = nil) then
   510     exit;
   509     exit;
   511 with CurrentTeam^ do
   510 with CurrentTeam^ do
   512     begin
   511     begin
   513     SplitBySpace(id, s);
   512     SplitBySpace(id, s);
   514     SwitchCurrentHedgehog(@Hedgehogs[HedgehogsNumber]);
   513     SwitchCurrentHedgehog(@Hedgehogs[HedgehogsNumber]);
   515     val(id, CurrentHedgehog^.BotLevel, c);
   514     CurrentHedgehog^.BotLevel:= StrToInt(id);
   516     Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0);
   515     Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0);
   517     SplitBySpace(s, id);
   516     SplitBySpace(s, id);
   518     val(s, Gear^.Health, c);
   517     Gear^.Health:= StrToInt(s);
   519     TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true);
   518     TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true);
   520     Gear^.Hedgehog^.Team:= CurrentTeam;
   519     Gear^.Hedgehog^.Team:= CurrentTeam;
   521     if (GameFlags and gfSharedAmmo) <> 0 then
   520     if (GameFlags and gfSharedAmmo) <> 0 then
   522         CurrentHedgehog^.AmmoStore:= Clan^.ClanIndex
   521         CurrentHedgehog^.AmmoStore:= Clan^.ClanIndex
   523     else if (GameFlags and gfPerHogAmmo) <> 0 then
   522     else if (GameFlags and gfPerHogAmmo) <> 0 then
   534     end
   533     end
   535 end;
   534 end;
   536 
   535 
   537 procedure chAddTeam(var s: shortstring);
   536 procedure chAddTeam(var s: shortstring);
   538 var Color: Longword;
   537 var Color: Longword;
   539     c: LongInt;
       
   540     ts, cs: shortstring;
   538     ts, cs: shortstring;
   541 begin
   539 begin
   542 cs:= '';
   540 cs:= '';
   543 ts:= '';
   541 ts:= '';
   544 if isDeveloperMode then
   542 if isDeveloperMode then
   545     begin
   543     begin
   546     SplitBySpace(s, cs);
   544     SplitBySpace(s, cs);
   547     SplitBySpace(cs, ts);
   545     SplitBySpace(cs, ts);
   548     val(cs, Color, c);
   546     Color:= StrToInt(cs);
   549     TryDo(Color <> 0, 'Error: black team color', true);
   547     TryDo(Color <> 0, 'Error: black team color', true);
   550 
   548 
   551     // color is always little endian so the mask must be constant also in big endian archs
   549     // color is always little endian so the mask must be constant also in big endian archs
   552     Color:= Color or $FF000000;
   550     Color:= Color or $FF000000;
   553     AddTeam(Color);
   551     AddTeam(Color);
   560     end
   558     end
   561 end;
   559 end;
   562 
   560 
   563 procedure chSetHHCoords(var x: shortstring);
   561 procedure chSetHHCoords(var x: shortstring);
   564 var y: shortstring;
   562 var y: shortstring;
   565     t, c: Longint;
   563     t: Longint;
   566 begin
   564 begin
   567 y:= '';
   565     y:= '';
   568 if (not isDeveloperMode) or (CurrentHedgehog = nil) or (CurrentHedgehog^.Gear = nil) then
   566     if (not isDeveloperMode) or (CurrentHedgehog = nil) or (CurrentHedgehog^.Gear = nil) then
   569     exit;
   567         exit;
   570 SplitBySpace(x, y);
   568     SplitBySpace(x, y);
   571 val(x, t, c);
   569     t:= StrToInt(x);
   572 CurrentHedgehog^.Gear^.X:= int2hwFloat(t);
   570     CurrentHedgehog^.Gear^.X:= int2hwFloat(t);
   573 val(y, t, c);
   571     t:= StrToInt(y);
   574 CurrentHedgehog^.Gear^.Y:= int2hwFloat(t)
   572     CurrentHedgehog^.Gear^.Y:= int2hwFloat(t)
   575 end;
   573 end;
   576 
   574 
   577 procedure chBind(var id: shortstring);
   575 procedure chBind(var id: shortstring);
   578 var KeyName, Modifier, tmp: shortstring;
   576 var KeyName, Modifier, tmp: shortstring;
   579     b: LongInt;
   577     b: LongInt;