hedgewars/uTeams.pas
changeset 2762 2fbc8d35eb52
parent 2758 033aa644578f
child 2763 f21d3ca74ef2
equal deleted inserted replaced
2761:1467c7298b10 2762:2fbc8d35eb52
    18 
    18 
    19 {$INCLUDE "options.inc"}
    19 {$INCLUDE "options.inc"}
    20 
    20 
    21 unit uTeams;
    21 unit uTeams;
    22 interface
    22 interface
    23 uses SDLh, uConsts, uKeys, uGears, uRandom, uFloat, uStats, uVisualGears,
    23 uses SDLh, uConsts, uKeys, uGears, uRandom, uFloat, uStats, uVisualGears, uCollisions,
    24 {$IFDEF GLES11}
    24 {$IFDEF GLES11}
    25 	gles11,
    25 	gles11,
    26 {$ELSE}
    26 {$ELSE}
    27 	GL,
    27 	GL,
    28 {$ENDIF}
    28 {$ENDIF}
    51 			BotLevel  : LongWord; // 0 - Human player
    51 			BotLevel  : LongWord; // 0 - Human player
    52 			HatVisibility: GLfloat;
    52 			HatVisibility: GLfloat;
    53 			stats: TStatistics;
    53 			stats: TStatistics;
    54 			Hat: String;
    54 			Hat: String;
    55             King: boolean;  // Flag for a bunch of hedgehog attributes
    55             King: boolean;  // Flag for a bunch of hedgehog attributes
       
    56             Unplaced: boolean;  // Flag for hog placing mode
    56 			end;
    57 			end;
    57 
    58 
    58 	TTeam = record
    59 	TTeam = record
    59 			Clan: PClan;
    60 			Clan: PClan;
    60 			TeamName: string[MAXNAMELEN];
    61 			TeamName: string[MAXNAMELEN];
   166 var c: LongWord;
   167 var c: LongWord;
   167     PrevHH, PrevTeam: LongWord;
   168     PrevHH, PrevTeam: LongWord;
   168 begin
   169 begin
   169 TargetPoint.X:= NoPointX;
   170 TargetPoint.X:= NoPointX;
   170 TryDo(CurrentTeam <> nil, 'nil Team', true);
   171 TryDo(CurrentTeam <> nil, 'nil Team', true);
       
   172 with CurrentHedgehog^ do
       
   173     if (PreviousTeam <> nil) and PlacingHogs and Unplaced then
       
   174         begin
       
   175         Unplaced:= false;
       
   176 	    if Gear <> nil then 
       
   177            begin
       
   178            Gear^.CollisionIndex:= -1;
       
   179            FindPlace(Gear, false, 0, LAND_WIDTH);
       
   180            if Gear <> nil then AddGearCI(Gear)
       
   181            end
       
   182 		end;
       
   183 
   171 PreviousTeam:= CurrentTeam;
   184 PreviousTeam:= CurrentTeam;
   172 
   185 
   173 with CurrentHedgehog^ do
   186 with CurrentHedgehog^ do
       
   187     begin
   174 	if Gear <> nil then
   188 	if Gear <> nil then
   175 		begin
   189 		begin
   176 		MultiShootAttacks:= 0;
   190 		MultiShootAttacks:= 0;
   177 		Gear^.Message:= 0;
   191 		Gear^.Message:= 0;
   178 		Gear^.Z:= cHHZ;
   192 		Gear^.Z:= cHHZ;
   179 		RemoveGearFromList(Gear);
   193 		RemoveGearFromList(Gear);
   180 		InsertGearToList(Gear)
   194 		InsertGearToList(Gear)
   181 		end;
   195 		end
       
   196     end;
   182 
   197 
   183 c:= CurrentTeam^.Clan^.ClanIndex;
   198 c:= CurrentTeam^.Clan^.ClanIndex;
   184 repeat
   199 repeat
   185 	inc(c);
   200 	inc(c);
   186 	if c = ClansCount then
   201 	if c = ClansCount then
   187 		begin
   202 		begin
   188 		inc(TotalRounds);
   203         if not PlacingHogs then inc(TotalRounds);
   189 		c:= 0
   204 		c:= 0
   190 		end;
   205 		end;
   191 
   206 
   192 	with ClansArray[c]^ do
   207 	with ClansArray[c]^ do
   193 		begin
   208 		begin
   209 CurrentHedgehog:= @(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog])
   224 CurrentHedgehog:= @(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog])
   210 end;
   225 end;
   211 
   226 
   212 procedure AfterSwitchHedgehog;
   227 procedure AfterSwitchHedgehog;
   213 var g: PGear;
   228 var g: PGear;
   214 begin
   229     i, t: LongInt;
       
   230 begin
       
   231 if PlacingHogs then
       
   232    begin
       
   233    PlacingHogs:= false;
       
   234    for t:= 0 to Pred(TeamsCount) do
       
   235       for i:= 0 to cMaxHHIndex do
       
   236           if (TeamsArray[t]^.Hedgehogs[i].Gear <> nil) and (TeamsArray[t]^.Hedgehogs[i].Unplaced) then 
       
   237              PlacingHogs:= true;
       
   238 
       
   239    if not PlacingHogs then // Reset  various things I mucked with
       
   240       begin
       
   241       for i:= 0 to ClansCount do
       
   242          if ClansArray[i] <> nil then ClansArray[i]^.TurnNumber:= 0;
       
   243       ResetWeapons
       
   244       end
       
   245    end;
       
   246 
   215 inc(CurrentTeam^.Clan^.TurnNumber);
   247 inc(CurrentTeam^.Clan^.TurnNumber);
   216 
   248 
   217 SwitchNotHeldAmmo(CurrentHedgehog^);
   249 SwitchNotHeldAmmo(CurrentHedgehog^);
   218 
   250 
   219 with CurrentHedgehog^ do
   251 with CurrentHedgehog^ do
   246 if (CurrentTeam^.ExtDriven or (CurrentHedgehog^.BotLevel > 0)) then
   278 if (CurrentTeam^.ExtDriven or (CurrentHedgehog^.BotLevel > 0)) then
   247 	PlaySound(sndIllGetYou, CurrentTeam^.voicepack)
   279 	PlaySound(sndIllGetYou, CurrentTeam^.voicepack)
   248 else
   280 else
   249 	PlaySound(sndYesSir, CurrentTeam^.voicepack);
   281 	PlaySound(sndYesSir, CurrentTeam^.voicepack);
   250 
   282 
   251 TurnTimeLeft:= cHedgehogTurnTime
   283 if PlacingHogs then
       
   284    begin
       
   285    if CurrentHedgehog^.Unplaced then TurnTimeLeft:= 10000
       
   286    else TurnTimeLeft:= 0
       
   287    end
       
   288 else TurnTimeLeft:= cHedgehogTurnTime
   252 end;
   289 end;
   253 
   290 
   254 function AddTeam(TeamColor: Longword): PTeam;
   291 function AddTeam(TeamColor: Longword): PTeam;
   255 var team: PTeam;
   292 var team: PTeam;
   256     c: LongInt;
   293     c: LongInt;