Talk:Party Management via Dialog
From Divinity Engine Wiki
There are a number of omissions in this code for recruiting a character:
- You should call CharacterAssignToUser to ensure the character gets assigned to the correct user/player (otherwise all recruited characters will probably be assigned to the host user/player)
- You should disable all reactions to crimes (ProcCharacterDisableAllCrimes) for recruited characters, so they don't start complaining if you assault/kill someone in front of them, or steal/pickpocket
- You should set up allied in-party alignments for each potential player character and assign those to the characters (SetFaction) once they join the party. This ensures that if you e.g. charm an NPC (which makes the NPC allied to the character that charmed it), the charmed NPC will be allied to all player characters in the same party (otherwise it will probably be neutral, which makes it less careful about not harming you). Similarly, it ensures that if someone start a combat with one party member, all party members will join that combat (characters join combats if they see an allied character that is in combat)
- You should call ProcRegisterPlayerTriggers() for the character that joins, so that triggers that have been registered for all player characters also get registered for this new character
- Ideally, you should also call CharacterAttachToGroup() after recruiting it, so it gets chained to the character that recruited it (and hence follows it by default)
When dismissing a character, you should undo points 4, 3 and 2 again after making the character an NPC.
Finally, if you create an add-on for the main campaign rather than an independent mod, you should always use the PROC_GLO_PartyMembers_Add() helper, as defined in the GLO_PartyMembers goal of the DivinityOrigins mod. Otherwise a whole bunch of things won't be set up properly. That one requires that an in-party dialog gets defined by QRY_GLO_PartyMembers_GetInPartyDialog() (you can overload that routine) and that there's a DB_GLO_PartyMembers_DefaultFaction() which defines the in-party alignment of the character.