Aller au contenu

Photo

I need help understanding the process by which an NPC is added as a companion to the party.


  • Veuillez vous connecter pour répondre
5 réponses à ce sujet

#1
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
This is how I understand it:

1)NPC is added to the roster and becomes a roster member
2)Roster member is added to the party.


In the functions that perform these actions, there is a string known as the "roster name".  Apparently it can only be 10 characters long.  I find this confusing because in the ga_ scripts, I can use roster names that are more than 10 characters and they still work.  Is this because the ga_ scripts come with code to parse out the roster name you add and only take the first 10 characters? 

Right now I am only comfortable using the ga_ scripts to add characters to the party.  I use custom scripts for testing but I don't understand it well enough to be confident to use custom scripting for scripts that will be part of the release.  Any help is appreciated.

#2
kevL

kevL
  • Members
  • 4 078 messages
hey Matt,

Did you try filtering for "roster" and/or "party" in
a) File->Open Conversation/Script
B) Script Assist

There's a half dozen or more but they aren't as complicated as they sound. I'm no roster expert but it sounds like you got the basis above, and the descriptions are pretty good. If you figure out what the "campaignnpc" switch does, pls let us know ...

#3
Shallina

Shallina
  • Members
  • 1 012 messages
the number of party member in the campign setting isn't a real limit, you need to script around it in order to make it a real limit.
----------------------------------------------------------------------------
here a function that give the numbre of party member.

//function that return the number of party number

int partySize(){

int size =0;
object oFM = GetFirstFactionMember(GetFirstPC(TRUE), FALSE);
while( GetIsObjectValid(oFM) )

{

size = size+1;


oFM = GetNextFactionMember(GetFirstPC(TRUE), FALSE);
}


return size;


}
--------------------------------------------------------------------------------------------------------------------------------

Here a script that add a NPC to the roster and in the party

void main(string sNPC_Tag){

string rosterName=sNPC_Tag;

AddRosterMemberByCharacter(rosterName,GetObjectByTag(sNPC_Tag));
AddRosterMemberToParty(rosterName,GetFirstPC(TRUE));
SetIsRosterMemberCampaignNPC(rosterName,3);
}
--------------------------------------------------------------------------------------------------------------------------------

here a script that remove a NPC from the party


//this script will remove the NPC with "tag" as tag from the party

void main(string tag){

AssignCommand(GetObjectByTag(tag),ClearAllActions(TRUE));
RemoveRosterMemberFromParty(tag,GetFirstPC(TRUE),FALSE);


}

----------------------------------------------------------------------------------------------------------------------------------------

A NPC doesn't need to be in a roster to be a party member. Beeing in the roster only provide additional functions. The main one is that the NPC can only exist once accross the campaign.

Modifié par Shallina, 01 décembre 2011 - 07:26 .


#4
Claudius33

Claudius33
  • Members
  • 258 messages
Below a generic script to add companion.

I usually have rostername = tag lowercase only.

My understanding of making a companion 'CampaignNPC' : If CampaignNPC a companion is automatically moved to another module, alongside with the PC, providing s/he is in the party. But you can't use the selection GUI as in the OCs. If you don't declare him/her as CampaingNPC, you can use the selection GUI, but must take care of companions when moving to another module even if they are in the party.

Personally I prefer the old school way to talk to companions to allow changes in the party, so I always declare them CampaignNPC. In that case line of dialogs are conditionned by a script to test the party limit, as Shalina has explained it.

// add a new companion

void main(string sRosterName, int nCampaignNPC)
{
    object oNPC = GetObjectByTag(sRosterName);
    object oPC = GetFirstPC();
    ChangeToStandardFaction(oNPC, STANDARD_FACTION_DEFENDER); // Set to PC's faction usually DEFENDER
    AddRosterMemberByCharacter(sRosterName, oNPC); // add to roster
    SetIsRosterMemberSelectable(sRosterName, TRUE); // make selectable
    int nXP = GetXP(oPC);       // adjust XP to PC's XP (optional)
    GiveXPToCreature(oNPC, nXP);
    ForceRest(oNPC);        // full health
    AddRosterMemberToParty(sRosterName, oPC);        // add to party (optional)
    SetIsRosterMemberCampaignNPC(sRosterName, nCampaignNPC); // make him/her campaign NPC
   
    // make the inventory identified
   
    object oItem = GetFirstItemInInventory(oNPC);
    while (GetIsObjectValid(oItem))
    {
        SetIdentified(oItem, 1);
        oItem = GetNextItemInInventory(oNPC);
    }
}

Very important :

If you allow the player to get back to a previous module, you must absolutely despawn all companions not in the party when leaving the previous module. Otw, the companions not in the party will retake their previous characteristics and inventories instead of their current ones when the player gets back.

Do not have two companions with the same CampaignNPC number. Some loops (see Shalina'script) won't work correctly and you will have to test companion in party one by one. I had to do it in 16 Cygni 3 because I made the mistake somewhere in 16 Cygni 2.

You must spawn all companions not in the party when entering a new module if you intend to make them available in the entered module. A bit more tricky but so convenient for the player who don't need to get back to a base camp such as the Sunken Flag to switch companions in the party.

Using the toolset, the companion scripts must be set to to a companion's scripts set usually 'b_companions_scripts'.

Make sure that the property 'Lootable corpse' is set to FALSE. Otherwise an unconscious companion will never get up again!

Unless you really want to use it, the Campaign Flag 'Use Reputation' must be set to FALSE. Otherwise the new companion will do nothing for you until you reach the required reputation level!

Hope it helps.

#5
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 603 messages
Like Claudius33 I prefer to add and remove companions using conversations. But I haven't had any issues using the standard scripts ga_roster_add_object and ga_roster_party_add when adding. You can look at the companion conversation conv_bonny in my King's Festival campaign to see the specifics.

The first time a particular companion is added the following scripts are used:
ga_roster_add_object
ga_bb_give_xp or ga_bb_set_xp_for_level (custom scripts used to set the companion's experience points to match their level)

Every time (including the first time) a companion is added the following scripts are used:
ga_roster_party_add
ga_setplotflag (to turn off the plot setting and make the companion damageable.)

When you tell the companion to leave the following scripts are used:
ga_setplotflag (to make them undamageable again so they aren't killed by hostile creatures that may be in the area)
bb_roster_party_remove (this is a custom script written by Dick Loraine that does the commands RemoveRosterMemberFromParty and SpawnRosterMember so that when you ask the companion to join your party later he/she still has the gear he/she had when he/she left the party.)

I haven't seen the need to make them CampaignNPC's to allow them to safely travel between modules within a campaign.

Regards

Modifié par Kaldor Silverwand, 03 décembre 2011 - 04:59 .


#6
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Thank you all for your explanations. They were very helpful and I feel like I have a better and more adequate understanding of adding companions.