Is there any way to change the mutator settings when changing the map/game?
Is there any way to change the mutator settings when changing the map/game?
Example for StuffSwapper I want different setting for different game. Not only StuffSwapper, I am interested in any mutator. In principle, is it possible? I know only one way - clone mutators (subclass/copyclass without change). But I do not want to produce too redundant entity, since the individual specimen is needed for each individual setting. Surely this question has already arisen before, but i don't know how to search the answer.
Last edited by f7r on Fri May 21, 2021 9:10 pm, edited 1 time in total.
Re: Is there any way to change the mutator settings when changing the map/game?
Using StuffSwapper as an example, which/what settings do you want to change for different game(types?)? It's not totally clear what you want to achieve.f7r wrote: ↑Fri May 21, 2021 7:33 pm Example for StuffSwaper I want different setting for different game. Not only StuffSwaper, I am interested in any mutator. In principle, is it possible? I know only one way - clone mutators (subclass/copyclass without change). But I do not want to produce too redundant entity, since the individual specimen is needed for each individual setting. Surely this question has already arisen before, but i don't know how to search the answer.
Re: Is there any way to change the mutator settings when changing the map/game?
Yes it is possible but very involved.
Firstly you create a small mutator that has all the settings and classes of whatever other mutator's settings you want to change.
Lets say your mod is called MySetter1.u and you want to change settings in StuffSwapper.u
Now when you set the EditPackages= in your UT.ini file for your mod, you add all the other mutator.u mod names as well.
So you have:
[Editor.EditorEngine]
EditPackages=StuffSwapper
EditPackages=MySetter1
Now when you compile your MySetter1.u it will add all the classnames for StuffSwapper into your mod so in your mod you can now call for instance:
StuffSwapperConfigsPage.default.CurrentConfig=3
You may need to use a DynamicLoadObject to do this as I cannot remember any more
Something like:
Like I say, very involved, maybe one of the boffins here can shine some better light on the subject
Firstly you create a small mutator that has all the settings and classes of whatever other mutator's settings you want to change.
Lets say your mod is called MySetter1.u and you want to change settings in StuffSwapper.u
Now when you set the EditPackages= in your UT.ini file for your mod, you add all the other mutator.u mod names as well.
So you have:
[Editor.EditorEngine]
EditPackages=StuffSwapper
EditPackages=MySetter1
Now when you compile your MySetter1.u it will add all the classnames for StuffSwapper into your mod so in your mod you can now call for instance:
StuffSwapperConfigsPage.default.CurrentConfig=3
You may need to use a DynamicLoadObject to do this as I cannot remember any more
Something like:
Code: Select all
local StuffSwapper SW;
SW = class<Mutator>(DynamicLoadObject("StuffSwapper", class'Class'));
SW.StuffSwapperConfigsPage.default.CurrentConfig=3
Re: Is there any way to change the mutator settings when changing the map/game?
Perhaps StuffSwapper is not best example... I want to have able to change settings (set of config variable i think) of any mutators when change game on server.
Thank you. I seem to grasp the idea. As I understand it, your code must be executed before spawn mutator. Right? So that the mutator worked with new settings.
Re: Is there any way to change the mutator settings when changing the map/game?
You mean something like medToggle?
Re: Is there any way to change the mutator settings when changing the map/game?
Only ProAsm understood me correctly. How to explain clear? For simple example, there is such a mutator as GravityControl - I want that in one game/map there was one level of gravity (config variable nGravityLevel), and in another game/map - another level. In order to change the parameters of the mutator when changing the game on server.
Re: Is there any way to change the mutator settings when changing the map/game?
In most cases including all these other packages is not needed, you only need to know the variable names. Then you can change them with SetPropertyText(). Sadly it does not work with arrays, for example Dispatcher.OutEvents[].
Your mutator has first to find the other mutator and then change its variable(s), before that mutator uses them. Example:
Code: Select all
ForEach AllActors(class'Mutator', M)
if (M.Name == 'WhateverMutator0') {
M.SetPropertyText("PropertyName", "New Value");
break;
}
I do this with a lot of maps on my server:
Code: Select all
enum EPatchStage {
PS_PreBeginPlayStart,
PS_PreBeginPlay,
PS_PostBeginPlay,
PS_State,
};
function bool PatchMap(string MapNameWithoutExtension, ELogType LogLevel, out int PatchCount, EPatchStage PatchStage) {
const CFunctionNamePatchMap = "PatchMap";
local int PredictedResult;
switch(MapNameWithoutExtension) // ordered by map name
{
case "MH-305":
if (PatchStage != PS_PreBeginPlay)
goto PatchMap_NoPatchDefined;
PredictedResult = 2 + 1;
PatchCount = PatchMap_MH_305();
Goto PatchMap_PatchWasDefined;
case "MH-3072-FloorWays_rv1":
if (PatchStage != PS_PreBeginPlay)
goto PatchMap_NoPatchDefined;
PredictedResult = 2;
PatchCount = PatchMap_MH_3072_FloorWays_rv1();
Goto PatchMap_PatchWasDefined;
...
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Re: Is there any way to change the mutator settings when changing the map/game?
What causes this function? Is it UEngine builtin?
How to achieve this? What should be the sequence? So that other mutator actor already exist, but did not processed to use variables.
Re: Is there any way to change the mutator settings when changing the map/game?
Very interesting indeed Barbie
Re: Is there any way to change the mutator settings when changing the map/game?
Every Actor has some events in the process of its creation. See Chain_Of_Events_When_Spawning_Actors in wiki.
So your mutator should call that PatchMap() function in every stage of that process:
Code: Select all
Class MapPatcher expands Mutator;
enum EPatchStage {
// event *Spawned* is left out
PS_PreBeginPlayStart,
PS_PreBeginPlay,
PS_PostBeginPlay,
PS_State,
};
event PreBeginPlay() {
local int PatchCount;
PatchMap(MapFilename, LogLevel, PatchCount, PS_PreBeginPlayStart);
...
PatchMap(MapFilename, LogLevel, PatchCount, PS_PreBeginPlay);
}
event PostBeginPlay() {
PatchMap(MapFilename, LogLevel, PatchCount, PS_PostBeginPlay);
...
}
auto state Ready {
begin:
if (bActive)
{
PatchMap(MapFilename, LogLevel, PatchesCount, PS_State);
...
}
}
Look at the code of the other mutator(s) and decide when to change its variables. Also the position in the chain of mutators is relevant.
(My MapPatcher has 18234 lines and 1805 compilations at the moment.)
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett