Hopeless. Will work for advice. *Holds out empty tin can*

  • Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

IconoclastDX

FNG / Fresh Meat
Mar 23, 2006
156
0
0
OK Here's where I am:

Got WOTgreal up and running:.... Check
Located the relevent code:...... Check
Edited code to my satisfaction:. Check
Write a mutator file to
include/reference the changes:.. !Check

I feel like a dunce. I have read every single Mutator tutorial I can find and they only thing that I can figure out is to extend (expand/sub-class??) the class I edited rather than expanding the mutator class.

The class I edited was ROPawn. I only needed to edit one function (HandleStamina) and add one variable. What I need to figure out now is how to write a mutator to include these changes. Do I call ModifyPlayer? PreBeginPlay? And how do I code the mutator to include my edited class? I have a feeling that when I figure this out there will be a loud "DUH" heard across the land. Any help wil be
GREATLY appreciated.
 

IconoclastDX

FNG / Fresh Meat
Mar 23, 2006
156
0
0
OK, I know that Ive taken a while to respond but I really wanted to read up on as much as I can. Well I did and I can safely say that I still am not sure what to do:(. My problem isnt editing the ROpawn, its writing a mutator that instructs the game to use either my modified function, or a subclass with the function in it.

For instance I know how to change simple things like default stamina
Code:
class MutDoubleStamina extends Mutator;

function ModifyPlayer(Pawn Other)
{
    ROPawn(Other).Stamina = ROPawn(Other).Stamina * 2;
    Super.ModifyPlayer(Other);
}
There a numerous example discribing similar modifications. But what I need to do is include a modified function not just a variable. I can find little to no examples of this. CheckReplacement was close but all the example of this that I can find include changing the gamerules with Level.Game.GameRulesModifiers.AddGameRules. And since AddGameRules is a funtion of GameRules I wasnt sure that the same would apply the ROPawn class. It seems like it would be so simple. I just cannot figure it out.
 
Last edited:

DingBat

FNG / Fresh Meat
Nov 21, 2005
751
0
0
I don't know much about Unreal code but it doesn't seem probable that you can tell a mutator to use an overloaded function. Maybe I'm wrong.

Are you familiar with basic OO principles? I'll assume not, so forgive me if I'm wrong.

If I were working in C++ or Java and I had to alter the function of a class I would probably create a new subclass. Let's call it MyROPawn. All you do then is overload the function you're interested in and that's it.

The trick then is to get the game to instantiate your new class rather than the old ROPawn. I take it this is player performance you're changing. So, I'd be looking for the code where the players are instantiated. That's probably somewhere pretty central. You could then overload that method as well.

From that point you should be ok. Note that I'm totally speaking through my hat from my experience with other OO languages.

Perhaps with a bit more background on what you're trying to do I can be of more help.

Cheers.
 

worluk

FNG / Fresh Meat
Nov 21, 2005
2,226
85
0
something like this doesnt work?:

Code:
class MutChangePlayerPerformance extends Mutator;
 
function bool CheckReplacement( Actor Other, out byte bSuperRelevant )
{
      if(Other.IsA("ROPawn")
      {
            ReplaceWith(Other,"MyROPawn"); 
      }
 
}

Of course you would have to create the MyROPawn class, which would need to be subclassed from ROPawn. There you can just overload the needed functions or add new.

If i have some time, i will check the code :)
 

IconoclastDX

FNG / Fresh Meat
Mar 23, 2006
156
0
0
Thanks Dingbat and worluk! No need to check any code worluk. Im bound and determine to learn this the hard way. I dont have the time to try this now but I will soon. As far as I could figure out, I didnt have a problem with subclassing ROPawn or even getting the game to use it. What I was having trouble with was getting the modification in a mutator class form. Why? I dunno exactly. I just kept reading that mutators were the nice and friendly way to go when creating small modifications.

What I have now is a subclass of ROPawn (MyROPawn) containing one overridden function and some variables (by subclass I mean that it contains the line "class MyROPawn extends ROPawn" and has default properties at the bottom). I thought that if I used the IsA > ReplaceWith method that the game would actually replace the entire ROPawn class with the MyROPawn class. But you seem to be saying that it would overwrite ROPawns member functions with the duplicate member data in MyROPawn. Which is, of course, exactly what I need. I knew this would be simple.
 
Last edited:

worluk

FNG / Fresh Meat
Nov 21, 2005
2,226
85
0
it replaces the ROPawn with your class, you are right.

But with OO programming every class derived from a parent class has the same attributes and methods as the parent itsself. Meaning if you subclass ROPawn, your new MyROPawn class has excatly the same variables and functions available as the ROPawn class (thats the only way you can assure other code still works). Now if you want to change some function or variable you overwrite it. You do that by writing your own function with the same name as in the parent class in your MyROPawn class.

Completely useless example:
You want to send a broadcast when a player changes its weapon.
You would subclass the ROPawn and write a new PrevWeapon function (lets only do this for the prevWeapon function ;) )

Code:
class MyROPawn extends ROPawn;
 
simulated function PrevWeapon()
{
  Level.Game.Broadcast( P, P.PlayerReplicationInfo.PlayerName@"changed his weapon" );
  super.PrevWeapon();
}
(damn i hope this works ;) but if not i think it explains the idea)

not more needed to keep the functionality while adding the Broadcast.
The switch functionality is done by the "Super class",the parent, in that case that would be ROPawn.

Your MyROPawn still has a nextWeapon function also its not in your MyROPawn code, it inherits it from the parent.

If i got you wrong and you have a good understanding of ObjectOrientated programming and im struggling to explain it without any reason, im sorry (maybe someone else might find it useful ;) )

if im right, i would advise you to make yourself familiar with this as much as you can, cause you wont get far without OO understanding.