Manta Run Assists  (Read 44877 times)

Piglet

  • 1337
  • *
  • Posts: 3248
  • Country: gb
Re: Manta Run Assists
« Reply #30 on: March 16, 2024, 18:40 »
If your passenger gets knocked off, you don't have the flag as driver  O:-)

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)

Unaben

Re: Manta Run Assists
« Reply #31 on: March 16, 2024, 18:54 »
So technically you can get more than 15 points for the same flag run with the changes, which was my whole point of that beeing kinda unfair.

If your passenger gets knocked off, you don't have the flag as driver  O:-)

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)
« Last Edit: March 16, 2024, 18:58 by Unaben »

Piglet

  • 1337
  • *
  • Posts: 3248
  • Country: gb
Re: Manta Run Assists
« Reply #32 on: March 18, 2024, 09:35 »
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...

Unaben

Re: Manta Run Assists
« Reply #33 on: March 18, 2024, 11:32 »
It would be a lot easier of you open source it and accept pull requests, since it's kinda unexpected to make changes on a code that you don't know/see without the ability to test it yourself at all.
It this case my suggestion would be a simple maximizing that a singe flag score can't exceed 15 points.

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...

Piglet

  • 1337
  • *
  • Posts: 3248
  • Country: gb
Re: Manta Run Assists
« Reply #34 on: March 18, 2024, 14:23 »
The code is here...on the second post of this thread....

Unaben

Re: Manta Run Assists
« Reply #35 on: March 18, 2024, 16:00 »
Cool, here are my suggested changes:
Code: [Select]
//============================================================================
// $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....
« Last Edit: March 18, 2024, 16:02 by Unaben »

Piglet

  • 1337
  • *
  • Posts: 3248
  • Country: gb
Re: Manta Run Assists
« Reply #36 on: March 18, 2024, 19:30 »
Thank you.

Yes. That makes perfect sense.

One small correction:

Code: [Select]
LastHolderPRI = CTFFlag(Owner).Holder.PlayerReplicationInfo;
The Holder is the pawn that's holding the flag. We need its PRI.