hedgewars/uTeams.pas
changeset 7288 5d0704f23a2a
parent 7270 93e92e82d5c8
child 7278 000e4543f204
child 7426 55b49cc1f33a
equal deleted inserted replaced
7188:580cd247511e 7288:5d0704f23a2a
    33 function  TeamSize(p: PTeam): Longword;
    33 function  TeamSize(p: PTeam): Longword;
    34 procedure RecountTeamHealth(team: PTeam);
    34 procedure RecountTeamHealth(team: PTeam);
    35 procedure RestoreTeamsFromSave;
    35 procedure RestoreTeamsFromSave;
    36 function  CheckForWin: boolean;
    36 function  CheckForWin: boolean;
    37 procedure TeamGoneEffect(var Team: TTeam);
    37 procedure TeamGoneEffect(var Team: TTeam);
       
    38 procedure SwitchCurrentHedgehog(newHog: PHedgehog);
    38 
    39 
    39 implementation
    40 implementation
    40 uses uLocale, uAmmos, uChat, uVariables, uUtils, uIO, uCaptions, uCommands, uDebug, uScript,
    41 uses uLocale, uAmmos, uChat, uVariables, uUtils, uIO, uCaptions, uCommands, uDebug, uScript,
    41     uGearsUtils, uGearsList{$IFDEF SDL13}, uTouch{$ENDIF};
    42     uGearsUtils, uGearsList{$IFDEF SDL13}, uTouch{$ENDIF};
    42 
    43 
   182                 end
   183                 end
   183         until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) or (PrevTeam = CurrTeam) or ((CurrTeam = TagTeamIndex) and ((GameFlags and gfTagTeam) <> 0));
   184         until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) or (PrevTeam = CurrTeam) or ((CurrTeam = TagTeamIndex) and ((GameFlags and gfTagTeam) <> 0));
   184         end
   185         end
   185 until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil);
   186 until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil);
   186 
   187 
   187 CurrentHedgehog:= @(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]);
   188 SwitchCurrentHedgehog(@(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]));
   188 {$IFDEF USE_TOUCH_INTERFACE}
   189 {$IFDEF USE_TOUCH_INTERFACE}
   189 if (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoCrosshair) = 0 then
   190 if (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoCrosshair) = 0 then
   190     begin
   191     begin
   191     if not(arrowUp.show) then
   192     if not(arrowUp.show) then
   192         begin
   193         begin
   486 if (not isDeveloperMode) or (CurrentTeam = nil) then
   487 if (not isDeveloperMode) or (CurrentTeam = nil) then
   487     exit;
   488     exit;
   488 with CurrentTeam^ do
   489 with CurrentTeam^ do
   489     begin
   490     begin
   490     SplitBySpace(id, s);
   491     SplitBySpace(id, s);
   491     CurrentHedgehog:= @Hedgehogs[HedgehogsNumber];
   492     SwitchCurrentHedgehog(@Hedgehogs[HedgehogsNumber]);
   492     val(id, CurrentHedgehog^.BotLevel, c);
   493     val(id, CurrentHedgehog^.BotLevel, c);
   493     Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0);
   494     Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0);
   494     SplitBySpace(s, id);
   495     SplitBySpace(s, id);
   495     val(s, Gear^.Health, c);
   496     val(s, Gear^.Health, c);
   496     TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true);
   497     TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true);
   550 val(y, t, c);
   551 val(y, t, c);
   551 CurrentHedgehog^.Gear^.Y:= int2hwFloat(t)
   552 CurrentHedgehog^.Gear^.Y:= int2hwFloat(t)
   552 end;
   553 end;
   553 
   554 
   554 procedure chBind(var id: shortstring);
   555 procedure chBind(var id: shortstring);
   555 var s: shortstring;
   556 var KeyName, Modifier, tmp: shortstring;
   556     b: LongInt;
   557     b: LongInt;
   557 begin
   558 begin
   558 s:= '';
   559 KeyName:= '';
       
   560 Modifier:= '';
       
   561 
   559 if CurrentTeam = nil then
   562 if CurrentTeam = nil then
   560     exit;
   563     exit;
   561 SplitBySpace(id, s);
   564 
   562 if s[1]='"' then
   565 if(Pos('mod:', id) <> 0)then
   563     Delete(s, 1, 1);
   566     begin
   564 if s[byte(s[0])]='"' then
   567     tmp:= '';
   565     Delete(s, byte(s[0]), 1);
   568     SplitBySpace(id, tmp);
   566 b:= KeyNameToCode(id);
   569     Modifier:= id;
       
   570     id:= tmp;
       
   571     end;
       
   572 
       
   573 SplitBySpace(id, KeyName);
       
   574 if KeyName[1]='"' then
       
   575     Delete(KeyName, 1, 1);
       
   576 if KeyName[byte(KeyName[0])]='"' then
       
   577     Delete(KeyName, byte(KeyName[0]), 1);
       
   578 b:= KeyNameToCode(id, Modifier);
   567 if b = 0 then
   579 if b = 0 then
   568     OutError(errmsgUnknownVariable + ' "' + id + '"', false)
   580     OutError(errmsgUnknownVariable + ' "' + id + '"', false)
   569 else
   581 else
   570     CurrentTeam^.Binds[b]:= s
   582     CurrentTeam^.Binds[b]:= KeyName;
   571 end;
   583 end;
   572 
   584 
   573 procedure chTeamGone(var s:shortstring);
   585 procedure chTeamGone(var s:shortstring);
   574 var t: LongInt;
   586 var t: LongInt;
   575 begin
   587 begin
   604     end;
   616     end;
   605 
   617 
   606 AddChatString('** Good-bye!');
   618 AddChatString('** Good-bye!');
   607 RecountAllTeamsHealth();
   619 RecountAllTeamsHealth();
   608 end;
   620 end;
       
   621 
       
   622 procedure SwitchCurrentHedgehog(newHog: PHedgehog);
       
   623 var oldCI, newCI: boolean;
       
   624     oldHH: PHedgehog;
       
   625 begin
       
   626     oldCI:= (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.Gear^.CollisionIndex >= 0);
       
   627     newCI:= (newHog^.Gear <> nil) and (newHog^.Gear^.CollisionIndex >= 0);
       
   628     if oldCI then DeleteCI(CurrentHedgehog^.Gear);
       
   629     if newCI then DeleteCI(newHog^.Gear);
       
   630     oldHH:= CurrentHedgehog;
       
   631     CurrentHedgehog:= newHog;
       
   632     if oldCI then AddGearCI(oldHH^.Gear);
       
   633     if newCI then AddGearCI(newHog^.Gear)
       
   634 end;
       
   635 
   609 
   636 
   610 procedure initModule;
   637 procedure initModule;
   611 begin
   638 begin
   612 RegisterVariable('addhh', @chAddHH, false);
   639 RegisterVariable('addhh', @chAddHH, false);
   613 RegisterVariable('addteam', @chAddTeam, false);
   640 RegisterVariable('addteam', @chAddTeam, false);