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

Code Mutator Common Coding Problems and solutions

Did you try to replace the default pawn setting in the gametype via a mutator?
Something like
Code:
function PreBeginPlay() 
{     
   super.PreBeginPlay();
   class'Package.Class'.default.WhateverProperty=10; 
}

The stuff I want to change isn't a setting. I want to override existing functions with my own.

Unrealscript confuses me in that if I take the controller which owns the pawn and typecast the pawn to my own custom class which extends ROPawn, then assign it to the controller's pawn, it breaks. The old pawn disappears (if I use checkreplacement and return false) and the new one doesn't have any functionality. If I don't use checkreplacement the old pawn hangs around but doesn't work.
 
Upvote 0
I have a few questions to which I do not have the answer. I hope someone can help me out:

  1. How can I write something to the RO2 log file?
    I've tried the `log and `logd macro with -debug passed to the make command, but I still do not see anything appear in the log files.
  2. How should I make my mutator known (and selectable) in the web-admin tool?
  3. How should the format of the defaulthullmgmutator.ini file look like for the next mutator class? (it's just a snipped of the class)
Code:
class HullMGMutator extends Mutator
    config(HullMGMutator);
    
struct MissPercentages
{
    var float Recruit;
    var float Soldier;
    var float Veteran;
    var float Hero; 
};

var config MissPercentages HullMGMissPercentages;
I've tried this, but the mutator doesn't seem to load it:
Code:
[HullMGMutator.HullMGMutator]
HullMGMissPercentages=(Recruit=75.0,Soldier=70.0,Veteran=65.0,Hero=60.0)

100% ditto on logging. Would make debugging this stuff a lot easier to see what the variables are at certain points.
 
Upvote 0
The stuff I want to change isn't a setting. I want to override existing functions with my own.

Unrealscript confuses me in that if I take the controller which owns the pawn and typecast the pawn to my own custom class which extends ROPawn, then assign it to the controller's pawn, it breaks. The old pawn disappears (if I use checkreplacement and return false) and the new one doesn't have any functionality. If I don't use checkreplacement the old pawn hangs around but doesn't work.

You misunderstood. I suggested you replace the gametypes default pawn that way, therefore not requiring a checkreplacement as the standard gamecode would spawn your pawn by default.
 
Upvote 0
I have a few questions to which I do not have the answer. I hope someone can help me out:

  1. How can I write something to the RO2 log file?
    I've tried the `log and `logd macro with -debug passed to the make command, but I still do not see anything appear in the log files.
  2. How should I make my mutator known (and selectable) in the web-admin tool?
  3. How should the format of the defaulthullmgmutator.ini file look like for the next mutator class? (it's just a snipped of the class)
Code:
class HullMGMutator extends Mutator
    config(HullMGMutator);
    
struct MissPercentages
{
    var float Recruit;
    var float Soldier;
    var float Veteran;
    var float Hero; 
};

var config MissPercentages HullMGMissPercentages;
I've tried this, but the mutator doesn't seem to load it:
Code:
[HullMGMutator.HullMGMutator]
HullMGMissPercentages=(Recruit=75.0,Soldier=70.0,Veteran=65.0,Hero=60.0)

*shrug* no idea about the log, HoS was not in any state when i tried and i wont touch its code with a ten foot pole now.
What you could do though for debugging (in case you dont want to use the to my knowledge working, real debugger option that comes with nfringe), you can use a broadcast call to print stuff ingame. Did that for debugging tank code for CC.

For the mutator to show up in webadmin you need the .ini and .int file for the mutator. Check other files of that sort and the standard tutorials on UT3/UE3 mutators on how those should look.
 
Upvote 0
*shrug* no idea about the log, HoS was not in any state when i tried and i wont touch its code with a ten foot pole now.
What you could do though for debugging (in case you dont want to use the to my knowledge working, real debugger option that comes with nfringe), you can use a broadcast call to print stuff ingame. Did that for debugging tank code for CC.

For the mutator to show up in webadmin you need the .ini and .int file for the mutator. Check other files of that sort and the standard tutorials on UT3/UE3 mutators on how those should look.

I did, but they all refer to using this command:
Code:
ucc dumpint HullMGMutator.u
But I can't find any ucc executable :(

By the way. I was always in the impression that those .int files were only for UT2003 and not for UT2004 and his offspring's.

Well at least I got mu mutator to load the defaulhullmgmutator.ini file now. There was a typo in the .ini file name on my server :D
 
Upvote 0
No need for that command, the int files are plain ascii anyway. As i said, there are enough mutator tutorials out there stating how those files are set up. You will need .ini, .u and .int for the mutator to show up in the webadmin

I did that. I have the .ini and .u. I also created a .int following instructions from the internet, but still the mutator doesn't show up on the Change Map screen.
Mostly I've been using this http://wiki.beyondunreal.com/Legacy:UnrealScript_Hello_World (which is using the 'older' UT2003) and this http://wiki.beyondunreal.com/UnrealScript_Hello_World. And again here http://wiki.beyondunreal.com/Legacy:Create_An_INT_File (which is again for UT2003 only).
But none of those works.

Maybe you know a better web-link for me, because i'm running out of options? :(
 
Last edited:
Upvote 0
Yeah, it's not a file problem. (also, the .int files are unicode, not ascii)

It looks to me like there's a flaw in the webadmin mutator handling. It's recognizing that the mutators are there, and it's reading the ROUIDataProvider_Mutator block correctly (the part that checks for duplicates functions) but it's not populating that data into the DCEMutator object that it uses for all its internal handling (verified with "getall dcemutator classname" on the server console). With all the data left null, the later logic breaks down, of course.

It looks to me like it's missing a call to DCEMutator.init() on DataStoreCache.uc line 574.
 
  • Like
Reactions: Ducky
Upvote 0
Yeah, it's not a file problem. (also, the .int files are unicode, not ascii)

It looks to me like there's a flaw in the webadmin mutator handling. It's recognizing that the mutators are there, and it's reading the ROUIDataProvider_Mutator block correctly (the part that checks for duplicates functions) but it's not populating that data into the DCEMutator object that it uses for all its internal handling (verified with "getall dcemutator classname" on the server console). With all the data left null, the later logic breaks down, of course.

It looks to me like it's missing a call to DCEMutator.init() on DataStoreCache.uc line 574.

Amazing... You really did dive deap into the scripting that comes with the SDK. Nice bug tracking :)
 
Last edited:
Upvote 0
I did, but they all refer to using this command:
Code:
ucc dumpint HullMGMutator.u
But I can't find any ucc executable :(

By the way. I was always in the impression that those .int files were only for UT2003 and not for UT2004 and his offspring's.

Well at least I got mu mutator to load the defaulhullmgmutator.ini file now. There was a typo in the .ini file name on my server :D

The UCC.exe was the old UT2004 compiler, so you could try running rogame.exe dumpint HullMGMutator.u to see if that works.
 
Upvote 0
The issue I'm having is that as a client on a dedicated server I'm not seeing any of the mutator function calls working. None of my log messages show up in the console. Nothing client side seems to happen. I've tried some very basic stuff and have tried making a client function then having the server call it, but nothing happens.

The server-side stuff seems to work (such as modifying variables that are replicated to the client), and the client side stuff works on a listen server, but thats it.
 
Upvote 0
The issue I'm having is that as a client on a dedicated server I'm not seeing any of the mutator function calls working. None of my log messages show up in the console. Nothing client side seems to happen. I've tried some very basic stuff and have tried making a client function then having the server call it, but nothing happens.

The server-side stuff seems to work (such as modifying variables that are replicated to the client), and the client side stuff works on a listen server, but thats it.

If you run it on a dedicated server, do you then see your log lines in the server logs?

An other thing that you can try is to place your mutator by hand in the steam\SteamApps\common\Red Orchestra 2\ROGame\CookedPC\Script folder. Next connect to the dedicated server and try it again.
 
Upvote 0
As I said, the server stuff runs, but I can't find evidence that my client stuff runs at all. Changing sensitivity is entirely client-side.

It'd be nice if someone had a simple example that worked so I can try to figure out what I'm doing wrong. I have the functions I am calling as "client" or "simulated" and I have them mentioned in the replication statement:

Code:
replication
{
    reliable if (Role == ROLE_Authority)
        addInputClient, LogicCheckerTimerClient;
}


reliable client function addInputClient(PlayerInput newinput, ROPawn MyPawn) {
... etc
 
Last edited:
Upvote 0
How can I write something to the RO2 log file?
I've tried the `log and `logd macro with -debug passed to the make command, but I still do not see anything appear in the log files.

Script logging is disabled by default to improve the performance of players who don't need it. To enable it type 'Unsuppress ScriptLog' into the console or remove 'Suppress=ScriptLog' from ROEngine.ini.

Adding a custom logging group such as, 'MyMutatorClass', also does the trick because MyMutatorClass is not suppressed.
 
Upvote 0