UE2 - UT2kX PlayerController - how stopfiring is handled?

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Shadow_knight

Carpe diem!
Jan 29, 2008
51
0
6
Prague
PlayerController - how stopfiring / stopfire is handled?

Hi!

I am writing a player observer mod that will export info from the game (through TCP/IP) about what the player is doing. I am now stuck with exporting information about player firing. I was able to get info when the player fires (function exec Fire), but so far I was unable to figure out where in the code is handled when the player stops firing - e.g. when the player releases the firing button.

I found function StopFiring() in Controller class, but it seems this function never gets called for human players (PlayerController class).

Any ideas?

thx,
sk
 
Last edited:

Shadow_knight

Carpe diem!
Jan 29, 2008
51
0
6
Prague
Thanks for the info Wormbo.

If anyone is interested I've solved this problem as follows (code from xPlayer class child):

Code:
var bool bIsFiring;
var bool bIsAltFiring;

replication
{
    reliable if( Role==ROLE_Authority )
		bIsFiring, bIsAltFiring;
    reliable if( Role<ROLE_Authority )
		NotifyFire, NotifyAltFire, NotifyStopFire;
}

//this function is added GB function, that should be called on server when the player fires his weapon
function NotifyFire(optional float f)
{
	//log("NotifyFire");
}

//this function is added GB function, that should be called on server when the player fires his weapon
function NotifyAltFire(optional float f)
{
	//log("NotifyFire");
}

//this hook makes every default call of Fire function replicated on server
//used to export player fire calls
exec function Fire( optional float F )
{
	bIsFiring = true; //this boolean is used to get the stopFire call
	NotifyFire(F);
	super.Fire(F);
}

//this hook makes every default call of AltFire function replicated on server
//used to export player fire calls
exec function AltFire( optional float F )
{
	bIsAltFiring = true; //this boolean is used to get the stopFire call
	NotifyAltFire(F);
	super.AltFire(F);
}

//function that will be called when player stops firing
function NotifyStopFire(bool bAltFire)
{
	log("NotifyStopFire");
}

// a little hack so we get notified when the player stops shooting
event PlayerTick( float DeltaTime )
{
	super.PlayerTick(DeltaTime);

	if (bIsFiring && bFire == 0)
	{
		bIsFiring = false;
		NotifyStopFire(false);
    }
    if (bIsAltFiring && bAltFire == 0)
    {
		bIsAltFiring = false;
		NotifyStopFire(true);
    }
}

It seems that PlayerTick function is called on client, because NotifyStopFire function wasn't called without declaration in replication statement.