here’s my attempt at an MP/MP loop without redundancy …
object oPc = GetFirstPC(FALSE); // oPc is controlled
while (GetIsObjectValid(oPc))
{
if (oPc == GetFactionLeader(oPc)) // <- do iff controlled is the faction leader
{
object oParty = GetFirstFactionMember(oPc, FALSE);
while (GetIsObjectValid(oParty))
{
if (GetAssociateType(oParty) == ASSOCIATE_TYPE_NONE
{
// hit 'oParty' here
}
oParty = GetNextFactionMember(oPc, FALSE);
}
}
oPc = GetNextPC(FALSE);
}
the idea is to loop over all PCs and Companions (not associates) regardless of how many players are in the game and/or whether or not those players have joined into one or more PC-parties
(the not-associate line can be taken out to include associates ofc)
[edit] The trick is to not hit any PC or Companion more than once.
More PW stuff, I guess, where more than one party (each player) can exist in the game. I tend to differentiate different players within the same party, but controlling their own PCs in that party, which blind-sided me.
Therefore (for what it says), yes, it looks good to me.
Just out of interest, what happens (with respect to leadership) when a player possesses another companion to play anyway?
I thought I had a vague recollection that that possessed PC became the leader anyway, but that may be in a SP game only. Wouldn’t it mean oPC was always the faction leader anyway? … Although, perhaps this does differ depending on campaign settings with respect to number of parties in game? (An area I have not looked at as I only allow one party.)
Then there is also the ability to transfer leadership … in a MP game, but then I guess with more “parties” you could also potentially have more than one leader anyway … just thinking aloud here.
i can’t readily test multiplayer … that’s why I’m asking for feedback … that said,
The problem is that we don’t have functions GetFirst/NextFactionLeader() – that would solve the issue without needing a nested loop.
So, instead, the routine loops over all player controlled characters and hits their faction if and only if he/she is a faction leader. Only one leader per party … so each party gets iterated over only once … it should work unless as you suggest GetFactionLeader() doesn’t return the controlled character of the faction leader, due to a quirk in multiplayer/multiparty …
the controlled character becomes the FactionLeader per GetFactionLeader()
ie. the player’s TruePC is no longer the faction leader
Alternately, the outer loop could be
object oPc = GetFirstPC();
while (GetIsObjectValid(oPc))
{
if (oPc == GetOwnedCharacter(GetFactionLeader(oPc)))
// etc
So, you are after a loop that affects a party of PCs, bearing in mind that there can be more than one party in a MP game of a PW type that allow more than one party in a module.
I have a backup question to this, as it is an area I am not totally familiar with myself, and that is, are we also making the assumption that players in a MP module may have their own party, or could be a member of another party that has more than one player in that party?
But, as the transfer leadership can only be assigned to another player in the same party …
However, having said all that, I believe there may be a “party” function that may help distinguish a party, maybe its members as well.
Let me check that … back in a bit.
Well, you do have GetPartyName etal, but it does now appear to allow a parameter to test any particular member …
I have only used string sPartyName = GetPartyName(); in one place, which did return the party name as set by the player when they create their party … but that is also under the assumption of having allowed only a single party in the module. Therefore, unfortunately, I am not convinced this function will be able to distinguish such … I think that is designed for the SoZ party GUI only.
As you probably know already, PWs work in a different manner altogether. I imagine they may even track individual parties in a database for the exact kind of thing you are looking at doing.
From a MP (OC) point of view (not PW), then players join the same party and this problem of looping through a specific party is not an issue. It’s very much a PW issue I believe, and if so, this is how I would probably consider handling it …
Track a party on a database and have a homebrew function that told me what party the PC targetted belongs to, and then loop that party from data I had already setup.
I like the idea of the function you did, but, like you, unfortunately, I do not have a PW type environment setup to check for nuances in handling. I believe I played around with the server settings when first testing my own campaign, but ended up just allowing one party only, as that suited my needs. As an aside, it can be tested with GetOnePartyMode function I believe.
Bottom line, if you know anyone who has setup a PW, or can get your hands on their code/function, that may help. If I have any more ideas or ways of offering any help, I’ll let you know.
yeh that’s what I remember reading years ago: there is only 1 pc-faction and all players join that faction regardless of whether they are in the same party.
(which strikes me as completely bonkers but /meh)
It really throws the usage of GetFactionLeader() into doubt … i mean, does it mean GetPartyLeader() ??
I guess they considered the PW side of things was not going to be used quite as much, and for those that did, I reckon they assumed the builders would handle such multi-party stuff on their servers in their own ways.
In your situation, unless you really wanted to test your function within a PW environment, I would make the assumption that it only needs to support a single party … and if that is the case, the loop becomes much easier as locating any active PC will do, as there is also only one leader involved.
Well, I have used GetFactionLeader (I assume that’s what you meant), BUT, it has become relevant to me because in my MP game, while there is only ever one leader for the party, that party can have more than player in it, and so, I may want to determine which of those players is leader at that time, and then affect the PCs that they are controlling only. ← Unique to my campaign. (i.e. although same party, I have different players in that party controlling their own group of PCs within it.)
This was a hurdle and a confusion to me when I first setup the campaign structure … and I reckon I may still have to double-check some uses where it may not actually be required …
That said, it does still serve a purpose for me. (And, to be honest, this may remain one of the only purposes where it may be helpful.)
I was merely suggesting that GetFactionLeader might be more accurately labelled GetPartyLeader – i mean in a multiparty campaign there can obviously be more than one party-leader, but if all PCs belong to the same faction regardless of party … what does “faction leader” mean …
/shrug
… in a single-party game, GetFactionLeader() ought be unambigious, a good and useful function yep. Just remember that it returns the controlled PC rather than the TruePC …
I hear you … but then the game allows the “transfer of leadership” when there are at least two players in the same party - and is why we had that whole MotB issue a while back.
I don’t have the PW background to check how multiple PCs join a single faction or not. I think they set up factions, in that case I think the code is OK. It should work single player. If a PW wants this code, they probably make adjustments to all of this code anyway.
Kaedrin’s later work really focused on PWs. The original loop he had would work fine in a PW with no companions. Same for the ClearAllActions in the equip script.