[MiA_FlagrunAssist.mutFlagrunAssist]ScoreMethod=1MaxScore=15MaxAdren=25
//============================================================================// $Id: mutFlagrunAssist.uc by Jrubzjeknf//============================================================================class mutFlagrunAssist extends Mutator config(MiA_FlagRunAssist);var CTFFlag RedFlag, BlueFlag;var Mia_FlagrunInfo RedInfo, BlueInfo;var config int ScoreMethod, MaxScore, MaxAdren;//============================================================================// PostBeginPlay//// Because the flags don't exist yet when this function is called, a timer is// started to find them on level startup instead.//============================================================================function PostBeginPlay(){ Super.PostBeginPlay(); SetTimer(1, true);}//============================================================================// Timer//// Finds flags, saves their reference and spawns a Mia_FlagrunInfo for them.//============================================================================function Timer(){ local CTFFlag F; if(Level.Game.GameReplicationInfo.bMatchHasBegun) //Match started! { foreach AllActors(class'CTFFlag', F) //Find flags. { if ( F.TeamNum == 1 ) BlueFlag = F; else RedFlag = F; } if(RedFlag != None && BlueFlag != None) //Spawn Infos and set variables in those. { RedInfo = Spawn(class'Mia_FlagrunInfo', RedFlag); BlueInfo = Spawn(class'Mia_FlagrunInfo', BlueFlag); RedInfo.EnemyTeamInfo = BlueFlag.Team; BlueInfo.EnemyTeamInfo = RedFlag.Team; RedInfo.EnemyTeamScore = BlueFlag.Team.Score; BlueInfo.EnemyTeamScore = RedFlag.Team.Score; RedInfo.ScoreMethod = ScoreMethod; RedInfo.MaxScore = MaxScore; RedInfo.MaxAdren = MaxAdren; BlueInfo.ScoreMethod = ScoreMethod; BlueInfo.MaxScore = MaxScore; BlueInfo.MaxAdren = MaxAdren; SetTimer(0, false); } }}static function FillPlayInfo(PlayInfo PlayInfo){ local byte Weight; // weight must be a byte (max value 127?) Weight=1; Super.FillPlayInfo(PlayInfo); PlayInfo.AddSetting(Default.FriendlyName, "ScoreMethod", "Select one", 0, Weight++, "Select", "0;Points every second carrying;1;Points in proportion to time carrying"); PlayInfo.AddSetting(Default.FriendlyName, "MaxScore", "Max Score for helping", 0, Weight++, "Text", "2;0:99"); PlayInfo.AddSetting(Default.FriendlyName, "MaxAdren", "Max Adren for helping", 0, Weight++, "Text", "2;0:99");}static function string GetDescriptionText(string PropName){ switch (PropName) { case "ScoreMethod": return "Method of points calculation"; case "MaxScore": return "Max score possible"; case "MaxAdren": return "Max Adrenaline possible"; } return Super.GetDescriptionText(PropName); }//============================================================================// Default Properties//============================================================================defaultproperties{ GroupName="FlagrunAssist" FriendlyName="Flagrun Assist" Description="Flag run driver points." ScoreMethod=1 MaxScore=15 MaxAdren=25}
//============================================================================// $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;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(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 (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; 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{}
Have you got that many comments in the code piglet? I'm impressed, I've just realised where I've been going wrong in most of my coding
This is just losely connected but I don't thing flag returns should give flat X points, they should give more points the closer the flag is about to get captured, which could be calculated based on the flag carrier's time/distance etc.
Piglet when you say dummy on the wing ... a real wing sitter is a very highly skilled player who knows how to not fall off the wing when it is shot at
Like we all know, the only way for sup to get laid is when hell is there as his wingman
We will have to create a demo tutorial to show 'friends' how to be a good wingman
Quote from: hellfire on February 29, 2024, 11:16Like we all know, the only way for sup to get laid is when hell is there as his wingman Yes, thanks hellThis is a great example of how not to sit on the manta wing