Download

Can not find the function ServerStartFire

Hi,

I study the project ShooterGame, but can not find the function ServerStartFire in engine souce code.
Can anyone tell me about the location of the code?
Thanks!

parts of code:

UFUNCTION(reliable, server, WithValidation)
void ServerStartFire();

UFUNCTION(reliable, server, WithValidation)
void ServerStopFire();

UFUNCTION(reliable, server, WithValidation)
void ServerStartReload();

UFUNCTION(reliable, server, WithValidation)
void ServerStopReload();

check the tutorial in my description. Maybe, i say maybe it can help you.

Thanks for reply, I guess that some functions about network, for example ServerStartFire, is black box in unreal engine 4 source code.

I can find parts of code in UT2004Scripts, shown as follow:

//// server only ////
event ServerStartFire(byte Mode)
{
if ( (Instigator != None) && (Instigator.Weapon != self) )
{
if ( Instigator.Weapon == None )
Instigator.ServerChangedWeapon(None,self);
else
Instigator.Weapon.SynchronizeWeapon(self);
return;
}

if ( (FireMode[Mode].NextFireTime <= Level.TimeSeconds + FireMode[Mode].PreFireTime)
	&& StartFire(Mode) )
{
    FireMode[Mode].ServerStartFireTime = Level.TimeSeconds;
    FireMode[Mode].bServerDelayStartFire = false;
}
else if ( FireMode[Mode].AllowFire() )
{
    FireMode[Mode].bServerDelayStartFire = true;
}
else
	ClientForceAmmoUpdate(Mode, AmmoAmount(Mode));

}

I believe those functions are specific to ShooterGame and not the UE4. You will probably need to make a Weapon class and then add them yourself.

I check build file, show below.

public override void SetupBinaries(
    TargetInfo Target,
    ref List<UEBuildBinaryConfiguration> OutBuildBinaryConfigurations,
    ref List<string> OutExtraModuleNames
    )
{
    OutExtraModuleNames.Add("ShooterGame");
}

and check online document, show below.

ExtraModuleNames (List<String>)
List of additional modules to be compiled into the target.

It means that some functions, for example ServerStartFire, are belong to the List of additional modules.
Is it right?

ServerStartFire is a function of ShooterGame’s weapon, not engine source code.

And no you can’t append ShooterGame as a module to your own code.

Thanks for reply.
Since ServerStartFire is a function of ShooterGame’s weapon, not engine source code, and I can not find this part of code in ShooterGame project source code,
it means that it is not released at ShooterGame project source code.

It’s in AShooterWeapon.h and AShooterWeapon.cpp

Trust me, anything you can see is definitely there.

I only find those:

ShooterWeapon.cpp (private\weapons): ServerStartFire();
ShooterWeapon.h (public\weapons): void ServerStartFire();

(1) can not find those files: AShooterWeapon.h and AShooterWeapon.cpp
(2) class AShooterWeapon call the function ServerStartFire();
(3) can not find any definiation about the function ServerStartFire();

Line 292. Try using Ctrl + F in Visual Studio.

I use Source Insight to trace code, and it should work right.

Trace code forder:
D:\UnrealEngineProjects\ShooterGame\Source
D:\UnrealEngineProjects\UnrealEngine-4.10.4-release\Engine\Source\Runtime

The ServerStartFire is definitely in the ShooterGame source code, you’re likely missing it as it’s a network function which uses ServerStartFire_Implementation and ServerStartFire_Validate.

I got it.
I think it as normal C++ call function.
Thanks for replies.

Code:
UFUNCTION(reliable, server, WithValidation) <== declare as network function
void ServerStartFire();

Code:
void AShooterWeapon::StartFire()
{
if (Role < ROLE_Authority)
{
ServerStartFire(); <== uses ServerStartFire_Implementation and ServerStartFire_Validate
}

if (!bWantsToFire)
{
	bWantsToFire = true;
	DetermineWeaponState();
}

}