NoWeaponWithFlag (NWWF) Fix for bots question

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

MyNameIsViolet

New Member
Jul 21, 2010
1
0
0
Hey all... I've just gotten back into UT again and I'm trying to polish up a custom game mode I usually play with some friends. The problem is, one of the mutators involved is NoWeaponWithFlag (NWWF) by Crokx. It's pretty basic: you grab the flag, your weapon lowers and you're unable to fire. It works fairly well... if you're a human player. BOTS, however, completely ignore it and can fire all they want. The obvious solution is "only play with humans" but that's just not possible for the 8-16 player games that this mode requires.

It also has an odd glitch online. Any human player who isn't hosting the game, when they collect the flag, their weapon will lower, then snap back to raised, lower, raise, etc until they release the flag. They're still unable to fire as intended, but it just looks odd.

The code for this mutator is as follows:

Code:
class NWWF expands Mutator;


var Pawn P;


function Tick(float deltaTime)
{
	Super.Tick(deltaTime);

	for(P = Level.PawnList; P != None; P = P.NextPawn)
	{
		if(P.PlayerReplicationInfo.HasFlag != None)
		{
			P.Weapon.SelectSound = None;
			P.Weapon.bOwnsCrossHair = True;
			P.Weapon.PutDown();
			P.PendingWeapon = None;

			if(P.Weapon.IsA('Translocator')
			|| P.Weapon.IsA('ImpactHammer')
			|| P.Weapon.IsA('WarHeadLauncher'))
			{
				P.Weapon.DrawType = DT_None;
			}
		}

		else
		P.Weapon.SelectSound = P.Weapon.Default.SelectSound;
		P.Weapon.bOwnsCrossHair = P.Weapon.Default.bOwnsCrossHair;

		if(P.Weapon.IsA('Translocator')
		|| P.Weapon.IsA('ImpactHammer')
		|| P.Weapon.IsA('WarHeadLauncher'))
		{
			P.Weapon.DrawType = P.Weapon.Default.DrawType;
		}
	}
}

A friend and I noticed there are no brackets around that 'else' statement - I modified it to add them and it didn't seem to fix the issue.

I don't know too much about coding, and I'm basically looking for someone to fix it for me (or pointing out a working replacement mutator that does the same thing). Telling me what's wrong with it probably won't enable me to fix it (though it might help my friend fix it, he knows considerably more than I).

Thanks a bunch in advance. I've had this problem for years, and never managed to get it fixed =x

PS: Anyone know of a mutator or setting that shows the remaining game time in CTF matches that have a time limit? I've seen them online before, but can't for the life of me find any results on google or in the game settings. All my searches only give me 2K4/UT3 results. A timer is the only thing I need from it (preferably with some sort of configuration for where it shows up, but I can't be too picky for an 11 year old game hehe).

PS again: (And an UnrealEd JumpPad tutorial? Only finding those for 2K3/4/UT3 also)
 

GreatEmerald

Khnumhotep
Jan 20, 2008
4,042
1
0
Lithuania
Hmm, Tick, that's a pretty expensive function, and having a for loop in it might make the game considerably slower... But anyway, yes, you need those brackets; plus, you need some kind of a check to see if the weapon was already lowered, that's the whole problem of yours. This function is executed every few milliseconds, and it goes through the whole pawn list all over again each time, and each time it lowers the weapon of the carrier, hence the bug.
For one, I'd advise you to turn off Tick when you don't need it, that is, check if the flag was taken, and only then enable this function. But that's just optimisation. To solve your bug, you'll have to add an additional check to see if the weapon has been lowered or not. You could do it with "if (P.Weapon.bOwnsCrossHair)" or something similar (if you can find a better variable that shows if the weapon is lowered, even better).