UE2 - UT2kX Gametype/Mutator Compatibilities

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

Parapeplum

New Member
Jun 5, 2013
4
0
0
Hi

Im developping a new gametype for UT2004 and I would need some help with unrealscript.

My gametype is roundbased and have two team, Hunter and hunted.
when a hunted get killed he repawns as hunter with a specific weapon.

At the moment, I have some trouble about compatibilities with inventory mutator.
(it works with standard pickup system)

I tried to completly discard the hunter inventory and give him the weapon in my gameinfo instance
but the player spawns with nothing(when arena is used).
so I wrote a mutator to clear the inventor, since each mutator must call function of the next mutator
in the list (modifyplayer() is the relevant one in this case) but it doesn't anything too.
Of course, I added this mutator to the game.

So my question is: Is it possible to override a inventory set by a mutator (via defaultweapon or giveto()
or other function )?


Thanks in advance.
 

meowcat

take a chance
Jun 7, 2001
803
3
18
here are a few of my thoughts on this...

The tricky part is that the position of your mutator in mutator linked list can vary depending on which mutators are selected so its hard to "wipe out" weapons (especially if there are mutators in the list after yours). I've removed default weapons from the pawn by setting their RequiredEquipment string array to empty strings. Here is some sample code which would go in your mutator's 'CheckReplacement' function (this is slightly modified from my YARM mutator's gun swapping code):
Code:
.....
	if(xPawn(Other)!=None
    && bNoClassInventory && !bNoWeaponPickups){
       xPawn(Other).bNoDefaultInventory = true; // this setting appears to ignored, DeathMatch.uc still calls AddDefaultInventory from an Accept Inventory function, not sure where that is called from
       // blank out the values
       for ( i=15; i>=0; i-- )
			if ( xPawn(Other).RequiredEquipment[i] != "" )
				xPawn(Other).RequiredEquipment[i]="";
       // optional new default weapon to add by accessing an array of possible weapons that were in my mutator
       if(WeapSlot0!=EMPTYSLOT) xPawn(Other).RequiredEquipment[0]=Weapon1ClassNames[WeapSlot0].path; // keeps the log file spam down in the bot class
       return true;
    }
....

In order to accomplish what you want you may have to do multiple checks in your mutator (the arena mutators appear to override/toss out anything that is not the selected weapon -OR- odes not have bNoInstagibReplace set to true so that would probably kill off your hunter weapon...).

One "hacky" way to go might be to create a 'dummy' inventory item which is given to the Hunter as it spawns (via 'ModifyPlayer'). The dummy inventory item would then, after pausing a couple of 'ticks'/frames after spawning, iterate through the Hunter's inventory, destroying its other weapons and then giving it the designated hunter weapon.
 

Parapeplum

New Member
Jun 5, 2013
4
0
0
thanks!
The tricky part is that the position of your mutator in mutator linked list can vary depending on which mutators are selected so its hard to "wipe out" weapons (especially if there are mutators in the list after yours).

I thought about it , to be efficient this mutator should be right after the one we want to
override the effect, even we can be fully certain of what happens.

I've removed default weapons from the pawn by setting their RequiredEquipment string array to empty strings. Here is some sample code which would go in your mutator's 'CheckReplacement' function (this is slightly modified from my YARM mutator's gun swapping code):

I'll try this. I thought arena only affects the defaultweapon because
"DefaultWeapon = ArenaWeaponClass; " in MutArena.uc

One "hacky" way to go might be to create a 'dummy' inventory item which is given to the Hunter as it spawns (via 'ModifyPlayer'). The dummy inventory item would then, after pausing a couple of 'ticks'/frames after spawning, iterate through the Hunter's inventory, destroying its other weapons
that's almost what I have done(I directly give him his weapon but clear all the other that aren't this particular one) less waiting a few moment before.

edit:
I looked to the wiki page for "checkreplacement" but it wasnt very useful in my case infortunately.
So I added your bit of code in my mutator, the only result I have is a game crash after launching a game with the message:" impossible to respawn player".

my mutator code:
Code:
function ModifyPlayer(Pawn Other)
{
	Super.ModifyPlayer(Other);

	// if is hunter we override the inventory
	if ( BWH_PRI(Other.PlayerReplicationInfo).bisHunter == true)
			EquipHunter(Other);
}

function EquipHunter(Pawn HunterPawn)
{
...
//create an inventory item (it autoadd this item in the inventory linked-list)
	if (HunterPawn != none)
		HunterPawn.CreateInventory("BallisticV25.EKS43Katana");
}
function bool CheckReplacement( Actor Other, out byte bSuperRelevant )
{
...
	bSuperRelevant = 0;
        if(xPawn(Other)!=None)
	{	
		xPawn(Other).bNoDefaultInventory = true; 
		// blank out the values
		for ( i=15; i>=0; i-- )
		{
			if ( xPawn(Other).RequiredEquipment[i] != "" )
				xPawn(Other).RequiredEquipment[i]="";
		}
 		return true;
        }
	return false;
}
should I take care of something else?

edit2: found what was going wrong

Code:
if()
{
  ...
 return true;
}
return false;

should be
Code:
if()
{
  ...
 return true;
}
else
  return true
return false;
return true for all other kind of actor (like spawning points)
 
Last edited: