• 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 Referencing RS classes and iteration

Cranston_29thid

Grizzled Veteran
Jun 13, 2010
103
0
Question #1:
I'm wondering how to iterate through each element in an array. Consider the following example:

ROMI = ROMapInfo(WorldInfo.GetMapInfo());

function FindAxisRole()
{
local int i;
local int RoleArrayLength;

foreach(ROMI.AxisSquads[0].FireTeams[0].Roles, i)
{
if(Roles.RoleInfo == class'RORoleInfoAxisRifleman')
{
WorldInfo.Game.Broadcast(self, "Found a Axis Rifleman!");
}
}
WorldInfo.Game.Broadcast(self, "Looped through all roles");
}

When I compile this it complains about the foreach line, saying
"Error, Missing ")" in expression."
I'm clearly using the foreach incorrectly. Could someone enlighten me as to what I'm doing wrong?


Question #2:
It seems the compiler does not recognise any Rising Storm classes. So far I've tried RSRoleInfo and RSMapInfo, and the compiler doesn't recognise either.

local RSMapInfo MyRSMI;

gives me the following error: "Error, unrecognized type 'RSMapInfo'." I also noticed while playing around with the editor that RS packages are not loaded by default like RO2 packages are. It feels like this is related.

Any ideas?
 
Last edited:
Question #1:
I'm wondering how to iterate through each element in an array. Consider the following example:

ROMI = ROMapInfo(WorldInfo.GetMapInfo());

function FindAxisRole()
{
local int i;
local int RoleArrayLength;

foreach(ROMI.AxisSquads[0].FireTeams[0].Roles, i)
{
if(Roles.RoleInfo == class'RORoleInfoAxisRifleman')
{
WorldInfo.Game.Broadcast(self, "Found a Axis Rifleman!");
}
}
WorldInfo.Game.Broadcast(self, "Looped through all roles");
}

When I compile this it complains about the foreach line, saying
"Error, Missing ")" in expression."
I'm clearly using the foreach incorrectly. Could someone enlighten me as to what I'm doing wrong?


You can't use an integer as an iterator for that one. I don't have the SDK code here at hand, but I assume that Roles is of type RORoleInfo (or something like that). If yes, then use:

Code:
local RORoleInfo Role; // Nut sue if this one is the correct type

foreach ROMI.AxisSquads[0].FireTeams[0].Roles(Role)
{
    if (Role.RoleInfo == class'RORoleInfoAxisRifleman')
    ...
}

or use:

Code:
local int i;

for (i = 0; i < ROMI.AxisSquads[0].FireTeams[0].Roles.Length; i++)
{
    if (ROMI.AxisSquads[0].FireTeams[0].Roles[i].RoleInfo == class'RORoleInfoAxisRifleman')
    ...
}

Question #2:
It seems the compiler does not recognise any Rising Storm classes. So far I've tried RSRoleInfo and RSMapInfo, and the compiler doesn't recognise either.

local RSMapInfo MyRSMI;

gives me the following error: "Error, unrecognized type 'RSMapInfo'." I also noticed while playing around with the editor that RS packages are not loaded by default like RO2 packages are. It feels like this is related.

Any ideas?

Check your ROEditor.ini file.
 
Upvote 0
Thanks for the reply. Unfortunately for me, Roles is an array filled with RORoles. RORole is a native struct within ROSquadInfo.

struct native RORole
{
var() instanced RORoleInfo RoleInfo; // Type of Role(instanced so we can modify the properties)
var Controller Owner; // Player or AI currently filling this Role
};

ROFireTeam is a native struct as well. I've been trying to get around it but it seems my chances are even more slim now. Because they're native structs I can't make my own ROFireTeam, set it up how I want, then insert it into the MapInfo. My idea then was to iterate over all roles, find the roles I want, and insert them in arbitrary positions. Will this still be possible you think?

Regarding referencing RS classes, I spoke to THOR and he had the same issue. I will be sending a PM to Yoshiro to see if they missed something on their end.
 
Upvote 0
Yes it is possible. You can manipulate ROFireTeam.MinimumPlayers to enable or disable roles. The MinimumPlayers member determines how many players there must be to get that role unlocked. Likewise you can manipulate ROSquadInfo.MinimumPlayers to enable/disable roles.

Suppose you want to enable all squads and fire teams, then you can do that with:
Code:
for (squad = 0; squad < ROMI.AxisSquads.Length; squad++)
{
    ROMI.AxisSquads[squad].MinimumPlayers = 1;

	for (fireTeam = 0; fireTeam < ROMI.AxisSquadsCD[squad].FireTeams.Length; fireTeam++)
	{
		ROMI.AxisSquadsCD[squad].FireTeams[fireTeam].MinimumPlayers = 1;
	}
}

The above code will enable all squads and fire teams as soon as 1 player is connected.

Likewise you can disable them all by setting MinimumPlayers to 65.

If you want to enable a specific role, then you must check the role of the fire team and set MinimumPlayers to 1 if it's the role is the right one.

One remark, if you change MinimumPlayers at server side, then the client won't be aware of it and the player can still select that default roles. You must run the same function (easiest by making it static) at client side too.
 
Upvote 0
I found this issue with RS classes too. You must go into the ROEditor.ini file that Ducky mentioned, find the EditPackages section, and add:

Code:
EditPackages=RSGame
EditPackages=RSGameContent

Or similar. I'm fairly certain it's located in that file. You probably want to put this right after the ROGame and ROGameContent lines.
 
Last edited:
Upvote 0
Thanks dibbler. Can't believe I didn't find it, I was looking for "EditPackages" even. The lines are in ROEngine, not ROEditor. Note that RO related packages are not listed, so don't be confused about that. I guess stock packages don't have to be listed.

Anyway, I added the above two lines and it compiles fine now. Thanks a lot!
 
Upvote 0
Thanks dibbler. Can't believe I didn't find it, I was looking for "EditPackages" even. The lines are in ROEngine, not ROEditor. Note that RO related packages are not listed, so don't be confused about that. I guess stock packages don't have to be listed.

Anyway, I added the above two lines and it compiles fine now. Thanks a lot!

No problem. I actually had put ROEngine initially and then edited it after the fact because I second guessed myself! :p I think I'll create a thread to let everyone know how to do this.
 
Upvote 0