If your passenger gets knocked off, you don't have the flag as driver
Quote from: Right on March 14, 2024, 23:33If your passenger gets knocked off, you don't have the flag as driver The code counts the time the flag runner was on the manta and also the time for the entire flag run. It gives each driver a proportion of the 15 points for the time they were assisting: 15 / (driver assist time / flag run time)
Well, as I always say (when the code is provided)...if someone wants to spend the time and effort making it better I'll consider any submissions.The strange thing is....I can't remember anyone other than @Holyspam ever taking me up on the offer. Guess what? His code is running...
//============================================================================// $Id: Mia_FlagrunInfo.uc by Jrubzjeknf//============================================================================class Mia_FlagrunInfo extends ReplicationInfo;//============================================================================// Variables//============================================================================var TeamInfo EnemyTeamInfo;var float EnemyTeamScore;var float TimeCarryingFlag;var float FlagTakenTime;var int ScoreMethod;var int MaxScore;var int MaxAdren;var PlayerReplicationInfo LastHolderPRI;struct VehicleDriverPoints{ var Controller Driver; var float TimeDriven;};var array<VehicleDriverPoints> VehicleDriverPointsArray;//============================================================================// PostBeginPlay//// Initiates flag monitoring.//============================================================================function PostBeginPlay(){ Super.PostBeginPlay(); SetTimer(1, true);}//============================================================================// Timer//// Checks if the flag carrier is sitting on a Vehicle. Every second he's sitting// on one, the Vehicle driver gets an assist second. This will be used for// giving the Vehicle driver points and adrenaline for the Vehicle run.//============================================================================function Timer(){ local pawn Driver; local Controller C; if(Owner != None) { if(Owner.IsInState('Held')) { if(CTFFlag(Owner).Holder != None) { LastHolderPRI = PlayerReplicationInfo(CTFFlag(Owner).Holder); } } if(FlagTakenTime != CTFFlag(Owner).TakenTime) //the flag has just been taken, check it the flag has been captured between seconds. { CheckCapture(); FlagTakenTime = CTFFlag(Owner).TakenTime; } if(!Owner.IsInState('Home')) //The flag is being carried or has been dropped. { TimeCarryingFlag += 1; if(CTFFlag(Owner).Holder != None && CTFFlag(Owner).Holder.Base != None && Vehicle(CTFFlag(Owner).Holder.Base) != None && Vehicle(CTFFlag(Owner).Holder.Base).Driver != None) //The flag carrier is sitting on an occupied Vehicle. { Driver = Vehicle(CTFFlag(Owner).Holder.Base).Driver; if(Driver.GetTeamNum() == CTFFlag(Owner).Holder.GetTeamNum() && Driver != CTFFlag(Owner).Holder){ //The Vehicle driver is friendly (and not self!). if (Driver.DrivenVehicle != None && Driver.DrivenVehicle.Controller != None){ C = Driver.DrivenVehicle.Controller; } else{ C = Driver.Controller; } UpdateTimeDrivenFor(C); //Give the driver seconds. } } } else if(TimeCarryingFlag != 0) //The flag is home, but has been carried. Check if the flag has been captured. CheckCapture(); }}//============================================================================// CheckCapture//// Check is the flag has been captured.//============================================================================function CheckCapture(){ local int i; local float RelativeTimeDriven; local float Points; local float Adren; if(EnemyTeamScore != EnemyTeamInfo.Score) { EnemyTeamScore = EnemyTeamInfo.Score; for(i=0; i<VehicleDriverPointsArray.Length; i++) if(VehicleDriverPointsArray[i].Driver != None) { if(LastHolderPRI == None || LastHolderPRI.PlayerID != VehicleDriverPointsArray[i].Driver.PlayerReplicationInfo.PlayerID) { if (ScoreMethod == 1){ RelativeTimeDriven = VehicleDriverPointsArray[i].TimeDriven/TimeCarryingFlag; Points = RelativeTimeDriven*MaxScore; Adren = RelativeTimeDriven*MaxAdren; } else{ Points = min(VehicleDriverPointsArray[i].TimeDriven, MaxScore); Adren = min(VehicleDriverPointsArray[i].TimeDriven*2, MaxAdren); } if(PlayerController(VehicleDriverPointsArray[i].Driver) != None) PlayerController(VehicleDriverPointsArray[i].Driver).ClientMessage("Flag Run Assist! Points:"@string(int(Points * 100) / 100)$", Adrenaline:"@string(int(Adren * 100) / 100)); VehicleDriverPointsArray[i].Driver.PlayerReplicationInfo.Score += Points; //Flag carrier gets MaxScore points on flawless cap. VehicleDriverPointsArray[i].Driver.Adrenaline += Adren; //Flag carriers get MaxAdren adrenaline. } } } TimeCarryingFlag = 0; LastHolderPRI = None; VehicleDriverPointsArray.Length = 0;}//============================================================================// UpdateTimeDrivenFor: give current driver seconds.// GetIndexOf: gets array index of current driver.// AddToArray: add current driver to array.//============================================================================function UpdateTimeDrivenFor(Controller Driver){ local int i; i = GetIndexOf(Driver); if(i != -1) VehicleDriverPointsArray[i].TimeDriven += 1; else AddToArray(Driver);}function int GetIndexOf(Controller C){ local int i; for(i=0; i<VehicleDriverPointsArray.Length; i++) if(VehicleDriverPointsArray[i].Driver == C) return i; return -1;}function AddToArray(Controller C){ local int i; i = VehicleDriverPointsArray.Length; VehicleDriverPointsArray.Length = i + 1; //VehicleDriverPointsArray.Length++; would make it crash 0_o VehicleDriverPointsArray[i].Driver = C; VehicleDriverPointsArray[i].TimeDriven = 1;}defaultproperties{}
The code is here...on the second post of this thread....
LastHolderPRI = CTFFlag(Owner).Holder.PlayerReplicationInfo;