Aller au contenu

Photo

Question about handling PC resting script in multiplayer.


  • Veuillez vous connecter pour répondre
1 réponse à ce sujet

#1
Clangeddin86

Clangeddin86
  • Members
  • 220 messages

Hello everyone. I have a script attached to a persistent feat given to every creature (so it fires off after a rest as well).

This script is meant to restore the mana of the one who rests to full, or of the whole party in single player.

oChar = OBJECT_SELF;
if (GetLastPCRested() == oChar)
{
        object oNPC = GetFirstFactionMember(oChar, FALSE);
        while (GetIsObjectValid(oNPC) == TRUE)
	{
		nTOTAL = GetLocalInt(oNPC, "CLANGEDDIN_MANA_MAXIMUM");
		SetLocalInt(oNPC, "CLANGEDDIN_MANA_CURRENT", nTOTAL);
		oNPC = GetNextFactionMember(oChar, FALSE);
	}
}

This script works fine for single player. However, I'm afraid that for multi player it may not work as intended and that it would restore the mana of other player characters who have not rested as well.

Anyone got any idea on how I should modify the above script to make it compatible with multi player? Keep in mind that when I rest in multiplayer, I want to restore the MP of the Player owned character, all his associates AND the NPC companions (like the campaign characters Bishop, Ammon ecc...) that can be controlled by the Player character that rested.



#2
kevL

kevL
  • Members
  • 4 056 messages
The first thing that strikes me is, that should be done in the onModuleRest event, or at least called or triggered directly from there. The Lexicon says that GetLastPCRested() should be used only in the rest event ....

(that's not to say that GetLastPCRested() won't get an accurate return elsewhere but )


The 2nd thing I don't know is whether or not all PC are always in the same faction in MP, regardless of whether they're in the same party. I heard, and suspect, they are. The thing is: refresh the Companions/Associates in a different codeblock than the rested PC. So I suspect all parties are going to get refreshed Companions & Associates.

here's a simple loop for refreshing the latter without any PC
 
    object oChar = OBJECT_SELF;
    int nTOTAL;

    object oNPC = GetFirstFactionMember(oChar, FALSE);
    while (GetIsObjectValid(oNPC) == TRUE)
    {
        if (GetIsOwnedByPlayer(oNPC) == FALSE)
        {
            nTOTAL = GetLocalInt(oNPC, "CLANGEDDIN_MANA_MAXIMUM");
            SetLocalInt(oNPC, "CLANGEDDIN_MANA_CURRENT", nTOTAL);
        }

        oNPC = GetNextFactionMember(oChar, FALSE);
    }
then do the rested-PC also.