UE3 - UT3 Check Replacement Weapon replacing problem

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

spectre1989

New Member
Feb 7, 2008
3
0
0
Check Replacement Weapon replacing problem [SOLVED]

Hi all,

I've been following this tutorial and I'm going out of my mind! The tutorial is excellent, I think I'm just being dumb.

Rightio, the tutorial is to create a mutator which replaces the enforcer with a "better" one. I'm on vista, so I'm doing all of this within "C:\users\Joe\Documents\My Games\Unreal Tournament 3\UTGame". The folder structure inside the "unpublished\src" folder is "FirstProperMutator" and then "classes", AFAIK this is correct.

So the source files within the classes folder are:

FirstProperMutator.uc
Code:
class FirstProperMutator extends UTMutator;

// === VARIABLES ===

// Set Defaults

DefaultProperties
{
}

// === FUNCTIONS ===

/*
Name: initMutator
Parameters: string, string
Purpose: Called when the mutator is "turned on", any setting up done here
*/

function initMutator(string Options, out string ErrorMessage) {

	if(UTGame(WorldInfo.Game) != None) {	// Make sure there is a valid game
	
		UTGame(WorldInfo.Game).DefaultInventory[0] = class'FirstProperMutator.UTWeap_EnforcerPlusOne';
		
	}
	
	loginternal( "Inited First proper mutator" );
	
	Super.initMutator(Options, ErrorMessage);
	
}

/*
Name: CheckReplacement
Parameters: Actor
Purpose: Allows you to replace any object in the game with another, awesomes!
*/

function bool CheckReplacement(Actor Other) {

	if(Other.IsA('UTWeap_Enforcer') && !Other.IsA('UTWeap_EnforcerPlusOne') ) {
	
		loginternal( "Replaced an enforcer" );
		ReplaceWith(Other, "UTWeap_EnforcerPlusOne");
	
	}
	
	return true;

}

UTWeap_EnforcerPlusOne.uc

Code:
class UTWeap_EnforcerPlusOne extends UTWeap_Enforcer;

// === VARIABLES ===

// Defaults

DefaultProperties {

	InstantHitDamage(0)=1000.000000
    InstantHitDamage(1)=1000.000000
    InstantHitMomentum(0)=10000.000000
    InstantHitMomentum(1)=10000.000000

}

// === FUNCTIONS ===

Ok, thats the actual source files. Then in "Unpublished\CookedPC\Localization" I put FirstProperMutator.int which contains:

Code:
[UTWeap_EnforcerPlusOne]
ItemName="Enforcer+1"
PickupMessage="Enforcer+1"

The compiled FirstProperMutator.u are in "Unpublished\CookedPC\Script", just for the record!

So in "UTGame\Config" (still in documents\my games\etc etc) I have:

Code:
...
...
[ModPackages]
ModPackages=HelloWorld  // This was just a really basic mutator to write "hello world" in the log
ModPackages=FirstProperMutator
ModPackagesInPath=..\UTGame\Src
ModOutputDir=..\UTGame\Unpublished\CookedPC\Script
...
...

And lastly here is the contents of FirstProperMutator.ini which is in "Documents\My Games\Unreal Tournament 3\UTGame\Config":

Code:
[FirstProperMutator UTUIDataProvider_Mutator]
ClassName=FirstProperMutator.FirstProperMutator
FriendlyName=Enforcer Boost
Description=My first mutator! Boosts enforcers damage.
GroupNames=
UIConfigScene=
bStandaloneOnly=False
bRemoveOn360=False
bRemoveOnPC=False
bRemoveOnPS3=False

[UTWeap_EnforcerPlusOne UTUIDataProvider_Weapon]
ClassName=FirstProperMutator.UTWeap_EnforcerPlusOne
AmmoClassPath=UTGame.UTAmmo_Enforcer
Flags=
FriendlyName=EnforcerPlusOne
Description=Its just plain better than the enforcer.
MeshReference=UI_Weapons.Mesh.SK_UI_Weapons_Enfocer_3P
bRemoveOn360=False
bRemoveOnPC=False
bRemoveOnPS3=False

Now I ran these with -useunpublished, and I got an error in the log saying:
Code:
Error: Error reading attributes for 'C:\Program Files\Unreal Tournament 3\Binaries\..\UTGame\ Unpublished\CookedPC\Script\FirstProperMutator.u'
Error: Error reading attributes for 'C:\Program Files\Unreal Tournament 3\Binaries\..\UTGame\ Unpublished\CookedPC\Script\HelloWorld.u'

So I copied the contents of "C:\Users\Joe\Documents\My Games\Unreal Tournament 3\UTGame" to "C:\Program Files\Unreal Tournament 3\UTGame". After doing this the error went away, and my HelloWorld mutator sent "hello world" to the log. Also FirstProperMutator sent "Inited First proper mutator" to the log as it was supposed to in the initMutator function.

However it never sends "Replaced an enforcer" to the log, which explains why the enforcer does not do any more damage when I use the mutator.. So it's not actually replacing any of the normal enforcers with my modified one, so what am I not seeing here?

Help!

Thanks in advance, and apologies for the huge post.

-Spec
 
Last edited:

MonsOlympus

Active Member
May 27, 2004
2,225
0
36
42
Ummz UTWeap_Enforcer is the Inventory class of the weapon not the pickup class.

Also I think the DefaultInventory array is usually 2 long so perhaps you are recieving both your enforcer and the normal one at spawn, would be hard to tell the difference between the two so Id suggest adding:

Code:
UTGame(WorldInfo.Game).DefaultInventory.Length = 1;
above
Code:
UTGame(WorldInfo.Game).DefaultInventory[0] = class'FirstProperMutator.UTWeap_EnforcerPlusOne';
That will remove the other enforcer and allows you weapon to replace the impact hammer, if your intention is not to replace the hammer then you can leave out that top bit and use DefaultInventory[1] instead which is the second weapon you are given :cool:
 

spectre1989

New Member
Feb 7, 2008
3
0
0
Hmm well I tried:
Code:
UTGame(WorldInfo.Game).DefaultInventory[1] = class'FirstProperMutator.UTWeap_EnforcerPlusOne';

Becuase I'm trying to replace the enforcer not the impact hammer, and this time it replaced the impact hammer, whereras when it's set to 0 instead of 1, it replaces the enforcer! I'm quite confused. Just to clarify though when I switch to enforcer "enforcer + 1" does come up on the screen, I just don't get why it does that but I don't seem to actually be using the better enforcer...
 

MonsOlympus

Active Member
May 27, 2004
2,225
0
36
42
Whoops yeah my bad, you had it right DefaultInventory[0] is the enforcer ;)

If you are getting the weapon in your inventory I see no problem why the damage isnt going up to 1000.

Edit: Oh I should mention that since you are now giving your players the new enforcers they are no longer getting the old ones in their inventories so you'll most likely only get "replaced and enforcer" log when picking up an enforcer from a map.
 
Last edited:

ambershee

Nimbusfish Rawks
Apr 18, 2006
4,519
7
38
37
Nomad
sheelabs.gamemod.net
Put the default properties at the bottom of the mutator class. I have a feeling that the compiler has to have these after the functions, and thus isn't reading the new values - which would explain why they are *always* at the bottom of the class.
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
Defaults can actually be anywhere in the class, just like the replication block. However, putting defaults anywhere but at the end of the class will likely mess up line numbers reported by the compiler.
 

ambershee

Nimbusfish Rawks
Apr 18, 2006
4,519
7
38
37
Nomad
sheelabs.gamemod.net
I would have thought it wouldn't make a difference too, seeing as the compiler didn't pick it up.

However! This reminds me of an old thread that died here in the crash.

Do not use 'one true brace' style programming. Always put parenthesis (squiggly brackets) on their own lines! I remember someone reporting problems with that before. (And my personal remark was 'eat that, one true brace!') XD
 

MonsOlympus

Active Member
May 27, 2004
2,225
0
36
42
Woah I missed that completely I saw the variables comment and went straight down to init, damn you no highlighting :lol:

I guess that would go for the comment at the bottom of the enforcer class as well. Id be inclined to do something like:

Code:
function bool CheckReplacement(Actor Other)
{
	local UTWeaponPickupFactory WeaponFactory;

	WeaponFactory = UTWeaponPickupFactory(Other);
	if (WeaponFactory != None && WeaponFactory.WeaponPickupClass == class'UTWeap_Enforcer')
	{
                      WeaponFactory.WeaponPickupClass == class'UTWeap_EnforcerPlusOne'
             }
}
 
Last edited:

spectre1989

New Member
Feb 7, 2008
3
0
0
Ok well you solved it, I'm not sure whether it was the curly braces or the position of the defaults, but a massive thank you to you all!