hedgewars/uTeams.pas
branchwebgl
changeset 9950 2759212a27de
parent 9521 8054d9d775fd
parent 9790 0b4b9fda5bd4
child 10015 4feced261c68
--- a/hedgewars/uTeams.pas	Fri Oct 11 17:43:13 2013 +0200
+++ b/hedgewars/uTeams.pas	Sat Jan 04 23:55:54 2014 +0400
@@ -41,13 +41,14 @@
 procedure TeamGoneEffect(var Team: TTeam);
 procedure SwitchCurrentHedgehog(newHog: PHedgehog);
 
+var MaxTeamHealth: LongInt;
+
 implementation
 uses uLocale, uAmmos, uChat, uVariables, uUtils, uIO, uCaptions, uCommands, uDebug,
     uGearsUtils, uGearsList, uVisualGearsList, uTextures
     {$IFDEF USE_TOUCH_INTERFACE}, uTouch{$ENDIF};
 
-var MaxTeamHealth: LongInt;
-    GameOver: boolean;
+var GameOver: boolean;
     NextClan: boolean;
 
 function CheckForWin: boolean;
@@ -480,17 +481,11 @@
         else if Hedgehogs[i].GearHidden <> nil then
             inc(TeamHealth, Hedgehogs[i].GearHidden^.Health);
 
-    if not hasGone then
-        NewTeamHealthBarWidth:= TeamHealth
-        else
-        NewTeamHealthBarWidth:= 0;
-
-    if NewTeamHealthBarWidth > MaxTeamHealth then
+    if TeamHealth > MaxTeamHealth then
         begin
-        MaxTeamHealth:= NewTeamHealthBarWidth;
+        MaxTeamHealth:= TeamHealth;
         RecountAllTeamsHealth;
-        end else if NewTeamHealthBarWidth > 0 then
-            NewTeamHealthBarWidth:= (NewTeamHealthBarWidth * cTeamHealthWidth) div MaxTeamHealth
+        end
     end;
 
 RecountClanHealth(team^.Clan);
@@ -528,7 +523,7 @@
 
             if Gear <> nil then
                 begin
-                Gear^.Invulnerable:= false;
+                Gear^.Hedgehog^.Effects[heInvulnerable]:= 0;
                 Gear^.Damage:= Gear^.Health;
                 Gear^.State:= (Gear^.State or gstHHGone) and (not gstHHDriven)
                 end
@@ -547,11 +542,11 @@
     SplitBySpace(id, s);
     SwitchCurrentHedgehog(@Hedgehogs[HedgehogsNumber]);
     CurrentHedgehog^.BotLevel:= StrToInt(id);
+    CurrentHedgehog^.Team:= CurrentTeam;
     Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0);
     SplitBySpace(s, id);
     Gear^.Health:= StrToInt(s);
     TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true);
-    Gear^.Hedgehog^.Team:= CurrentTeam;
     if (GameFlags and gfSharedAmmo) <> 0 then
         CurrentHedgehog^.AmmoStore:= Clan^.ClanIndex
     else if (GameFlags and gfPerHogAmmo) <> 0 then
@@ -688,6 +683,62 @@
 end;
 
 
+procedure chSetHat(var s: shortstring);
+begin
+if (not isDeveloperMode) or (CurrentTeam = nil) then exit;
+with CurrentTeam^ do
+    begin
+    if not CurrentHedgehog^.King then
+    if (s = '')
+    or (((GameFlags and gfKing) <> 0) and (s = 'crown'))
+    or ((Length(s) > 39) and (Copy(s,1,8) = 'Reserved') and (Copy(s,9,32) <> PlayerHash)) then
+        CurrentHedgehog^.Hat:= 'NoHat'
+    else
+        CurrentHedgehog^.Hat:= s
+    end;
+end;
+
+procedure chGrave(var s: shortstring);
+begin
+    if CurrentTeam = nil then
+        OutError(errmsgIncorrectUse + ' "/grave"', true);
+    if s[1]='"' then
+        Delete(s, 1, 1);
+    if s[byte(s[0])]='"' then
+        Delete(s, byte(s[0]), 1);
+    CurrentTeam^.GraveName:= s
+end;
+
+procedure chFort(var s: shortstring);
+begin
+    if CurrentTeam = nil then
+        OutError(errmsgIncorrectUse + ' "/fort"', true);
+    if s[1]='"' then
+        Delete(s, 1, 1);
+    if s[byte(s[0])]='"' then
+        Delete(s, byte(s[0]), 1);
+    CurrentTeam^.FortName:= s
+end;
+
+procedure chFlag(var s: shortstring);
+begin
+    if CurrentTeam = nil then
+        OutError(errmsgIncorrectUse + ' "/flag"', true);
+    if s[1]='"' then
+        Delete(s, 1, 1);
+    if s[byte(s[0])]='"' then
+        Delete(s, byte(s[0]), 1);
+    CurrentTeam^.flag:= s
+end;
+
+procedure chOwner(var s: shortstring);
+begin
+    if CurrentTeam = nil then
+        OutError(errmsgIncorrectUse + ' "/owner"', true);
+
+    CurrentTeam^.Owner:= s
+end;
+
 procedure initModule;
 begin
 RegisterVariable('addhh', @chAddHH, false);
@@ -696,6 +747,11 @@
 RegisterVariable('bind', @chBind, true );
 RegisterVariable('teamgone', @chTeamGone, true );
 RegisterVariable('finish', @chFinish, true ); // all teams gone
+RegisterVariable('fort'    , @chFort         , false);
+RegisterVariable('grave'   , @chGrave        , false);
+RegisterVariable('hat'     , @chSetHat       , false);
+RegisterVariable('flag'    , @chFlag         , false);
+RegisterVariable('owner'   , @chOwner        , false);
 
 CurrentTeam:= nil;
 PreviousTeam:= nil;
@@ -722,26 +778,27 @@
                 begin
                 if GearHidden <> nil then
                     Dispose(GearHidden);
-                    
+
                 FreeTexture(NameTagTex);
                 FreeTexture(HealthTagTex);
                 FreeTexture(HatTex);
                 end;
-                
+
         with TeamsArray[i]^ do
             begin
             FreeTexture(NameTagTex);
-            FreeTexture(CrosshairTex);
             FreeTexture(GraveTex);
-            FreeTexture(HealthTex);
             FreeTexture(AIKillsTex);
             FreeTexture(FlagTex);
             end;
-        
+
         Dispose(TeamsArray[i]);
     end;
-for i:= 0 to Pred(ClansCount) do
-    Dispose(ClansArray[i]);
+    for i:= 0 to Pred(ClansCount) do
+        begin
+        FreeTexture(ClansArray[i]^.HealthTex);
+        Dispose(ClansArray[i]);
+        end
     end;
 TeamsCount:= 0;
 ClansCount:= 0;