ObserveFlag Update

This commit is contained in:
ChocoTaco1 2021-02-26 15:40:53 -05:00
parent 2256d517ed
commit 38969b6bf3
3 changed files with 51 additions and 63 deletions

View file

@ -421,12 +421,13 @@ function CTFGame::playerTouchEnemyFlag(%game, %player, %flag)
%flag.carrier = %player; //this %flag is carried by %player %flag.carrier = %player; //this %flag is carried by %player
// attach the camera to the flag.carrier // attach the camera to the flag.carrier
for(%i = 0; %i < ClientGroup.getCount(); %i++) for(%i = 0; %i < $Observers; %i++)
{ {
%cl = ClientGroup.getObject(%i); %cl = $ObserverArray[%i];
if(%cl.team <= 0 && %cl.observingFlag && %cl.flagObsTeam == %flag.team) if(%cl.observingFlag)
observeFlag(%cl, %player.client, 2, %flag.team); observeFlag(%cl, %player.client, 2, %flag.team);
} }
%player.mountImage(FlagImage, $FlagSlot, true, %game.getTeamSkin(%flag.team)); %player.mountImage(FlagImage, $FlagSlot, true, %game.getTeamSkin(%flag.team));
%game.playerGotFlagTarget(%player); %game.playerGotFlagTarget(%player);
@ -568,13 +569,14 @@ function CTFGame::playerDroppedFlag(%game, %player)
%flag.carrier = ""; //flag isn't held anymore %flag.carrier = ""; //flag isn't held anymore
$flagStatus[%flag.team] = "<In the Field>"; $flagStatus[%flag.team] = "<In the Field>";
// attach the camera again to the flag // attach the camera to the flag
for(%i = 0; %i < ClientGroup.getCount(); %i++) for(%i = 0; %i < $Observers; %i++)
{ {
%cl = ClientGroup.getObject(%i); %cl = $ObserverArray[%i];
if(%cl.team <= 0 && %cl.observingFlag && %cl.flagObsTeam == %flag.team) if(%cl.observingFlag)
observeFlag(%cl, $TeamFlag[%flag.team], 1, %flag.team); observeFlag(%cl, $TeamFlag[%flag.team], 1, %flag.team);
} }
%player.unMountImage($FlagSlot); %player.unMountImage($FlagSlot);
%flag.hide(false); //Does the throwItem function handle this? %flag.hide(false); //Does the throwItem function handle this?
@ -601,16 +603,12 @@ function CTFGame::flagCap(%game, %player)
%flag = %player.holdingFlag; %flag = %player.holdingFlag;
%flag.carrier = ""; %flag.carrier = "";
// when a player cap the flag, continue observing the player // when a player cap the flag, attach to flag again
for(%i = 0; %i < ClientGroup.getCount(); %i++) for(%i = 0; %i < $Observers; %i++)
{ {
%cl = ClientGroup.getObject(%i); %cl = $ObserverArray[%i];
if(%cl.team <= 0 && %cl.observingFlag && %cl.flagObsTeam == %flag.team) if(%cl.observingFlag)
{ observeFlag(%cl, $TeamFlag[%flag.team], 1, %flag.team);
%cl.observingFlag = false;
%cl.flagObserved = "";
%cl.flagObsTeam = "";
}
} }
%held = %game.formatTime(getSimTime() - %game.flagHeldTime[%flag], false); // z0dd - ZOD, 8/15/02. How long did player hold flag? %held = %game.formatTime(getSimTime() - %game.flagHeldTime[%flag], false); // z0dd - ZOD, 8/15/02. How long did player hold flag?
@ -760,20 +758,12 @@ function CTFGame::flagReturn(%game, %flag, %player)
%otherTeam = 1; %otherTeam = 1;
%teamName = %game.getTeamName(%flag.team); %teamName = %game.getTeamName(%flag.team);
// when the flag return, stop observing the flag, and go in observerFly mode // when the flag return, attach to flag again
for(%i = 0; %i < ClientGroup.getCount(); %i++) for(%i = 0; %i < $Observers; %i++)
{ {
%cl = ClientGroup.getObject(%i); %cl = $ObserverArray[%i];
if(%cl.team <= 0 && %cl.observingFlag && %cl.flagObsTeam == %flag.team) if(%cl.observingFlag)
{ observeFlag(%cl, $TeamFlag[%flag.team], 1, %flag.team);
%cl.camera.mode = "observerFly";
%cl.camera.setFlyMode();
updateObserverFlyHud(%cl);
%cl.observingFlag = false;
%cl.flagObserved = "";
%cl.flagObsTeam = "";
}
} }
if (%player !$= "") if (%player !$= "")

View file

@ -658,12 +658,13 @@ function SCtFGame::playerTouchEnemyFlag(%game, %player, %flag)
%flag.carrier = %player; //this %flag is carried by %player %flag.carrier = %player; //this %flag is carried by %player
// attach the camera to the flag.carrier // attach the camera to the flag.carrier
for(%i = 0; %i < ClientGroup.getCount(); %i++) for(%i = 0; %i < $Observers; %i++)
{ {
%cl = ClientGroup.getObject(%i); %cl = $ObserverArray[%i];
if(%cl.team <= 0 && %cl.observingFlag && %cl.flagObsTeam == %flag.team) if(%cl.observingFlag)
observeFlag(%cl, %player.client, 2, %flag.team); observeFlag(%cl, %player.client, 2, %flag.team);
} }
%player.mountImage(FlagImage, $FlagSlot, true, %game.getTeamSkin(%flag.team)); %player.mountImage(FlagImage, $FlagSlot, true, %game.getTeamSkin(%flag.team));
%game.playerGotFlagTarget(%player); %game.playerGotFlagTarget(%player);
@ -793,13 +794,14 @@ function SCtFGame::playerDroppedFlag(%game, %player)
%flag.carrier = ""; //flag isn't held anymore %flag.carrier = ""; //flag isn't held anymore
$flagStatus[%flag.team] = "<In the Field>"; $flagStatus[%flag.team] = "<In the Field>";
// attach the camera again to the flag // attach the camera to the flag
for(%i = 0; %i < ClientGroup.getCount(); %i++) for(%i = 0; %i < $Observers; %i++)
{ {
%cl = ClientGroup.getObject(%i); %cl = $ObserverArray[%i];
if(%cl.team <= 0 && %cl.observingFlag && %cl.flagObsTeam == %flag.team) if(%cl.observingFlag)
observeFlag(%cl, $TeamFlag[%flag.team], 1, %flag.team); observeFlag(%cl, $TeamFlag[%flag.team], 1, %flag.team);
} }
%player.unMountImage($FlagSlot); %player.unMountImage($FlagSlot);
%flag.hide(false); //Does the throwItem function handle this? %flag.hide(false); //Does the throwItem function handle this?
@ -826,16 +828,12 @@ function SCtFGame::flagCap(%game, %player)
%flag = %player.holdingFlag; %flag = %player.holdingFlag;
%flag.carrier = ""; %flag.carrier = "";
// when a player cap the flag, continue observing the player // when a player cap the flag, attach to flag again
for(%i = 0; %i < ClientGroup.getCount(); %i++) for(%i = 0; %i < $Observers; %i++)
{ {
%cl = ClientGroup.getObject(%i); %cl = $ObserverArray[%i];
if(%cl.team <= 0 && %cl.observingFlag && %cl.flagObsTeam == %flag.team) if(%cl.observingFlag)
{ observeFlag(%cl, $TeamFlag[%flag.team], 1, %flag.team);
%cl.observingFlag = false;
%cl.flagObserved = "";
%cl.flagObsTeam = "";
}
} }
%held = %game.formatTime(getSimTime() - %game.flagHeldTime[%flag], false); // z0dd - ZOD, 8/15/02. How long did player hold flag? %held = %game.formatTime(getSimTime() - %game.flagHeldTime[%flag], false); // z0dd - ZOD, 8/15/02. How long did player hold flag?
@ -979,20 +977,12 @@ function SCtFGame::flagReturn(%game, %flag, %player)
%otherTeam = 1; %otherTeam = 1;
%teamName = %game.getTeamName(%flag.team); %teamName = %game.getTeamName(%flag.team);
// when the flag return, stop observing the flag, and go in observerFly mode // when the flag return, attach to flag again
for(%i = 0; %i < ClientGroup.getCount(); %i++) for(%i = 0; %i < $Observers; %i++)
{ {
%cl = ClientGroup.getObject(%i); %cl = $ObserverArray[%i];
if(%cl.team <= 0 && %cl.observingFlag && %cl.flagObsTeam == %flag.team) if(%cl.observingFlag)
{ observeFlag(%cl, $TeamFlag[%flag.team], 1, %flag.team);
%cl.camera.mode = "observerFly";
%cl.camera.setFlyMode();
updateObserverFlyHud(%cl);
%cl.observingFlag = false;
%cl.flagObserved = "";
%cl.flagObsTeam = "";
}
} }
if (%player !$= "") if (%player !$= "")

View file

@ -52,7 +52,15 @@ function GetTeamCounts(%game)
//Variables //Variables
$TotalTeamPlayerCount = $TeamRank[1, count] + $TeamRank[2, count]; $TotalTeamPlayerCount = $TeamRank[1, count] + $TeamRank[2, count];
$AllPlayerCount = $HostGamePlayerCount; $AllPlayerCount = $HostGamePlayerCount;
$Observers = $HostGamePlayerCount - ($TeamRank[1, count] + $TeamRank[2, count]);
//Observers
$Observers = 0;
for(%i = 0; %i < ClientGroup.getCount(); %i++)
{
%cl = ClientGroup.getObject(%i);
if(%cl.team $= 0)
$ObserverArray[$Observers++] = %cl;
}
//echo("$PlayerCount[0] " @ $HostGamePlayerCount - ($TeamRank[1, count] + $TeamRank[2, count])); //echo("$PlayerCount[0] " @ $HostGamePlayerCount - ($TeamRank[1, count] + $TeamRank[2, count]));
//echo("$PlayerCount[1] " @ $TeamRank[1, count]); //echo("$PlayerCount[1] " @ $TeamRank[1, count]);