Aller au contenu

Photo

Surrendering Companion


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

#1
andysks

andysks
  • Members
  • 1 651 messages
OK, I think I got a tough one this time. Let's see.
I was creating a random encounter today, where some group ambushes the PC and his party. I was thinking, that the leader of the bandits will surrender when low and offer to join the party, for many reasons. Anyway.
I have done this before. But not on potential companions. I used the gb_surrender_sp as the OnSpawn script, and this one as the user defined. Thanks for Brandon Belina for it.


http://pastebin.myrr....php?v=db1-2664

Since this uses a spot on OnSpawn, and given the delicate "get low speak" method, I don't know if I can use this, or if this thing is even possible.
I have thought of an altenative method though.
Just a hostile creature that surrenders when low, fade to black, destroy this creature, spawn the companion one which is a duplicate with the companion scripts and jump to conversation.
So, all I ask is if there is an easier way?
Thanks.

#2
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
There's a function in there somewhere that switches out a creature's script set, used especially in situations like yours where a npc needs to become a companion. Having two separate creatures works too, though I would have the future companion script-hidden somewhere instead of trying to spawn them in on the fly.

#3
andysks

andysks
  • Members
  • 1 651 messages
Are you certain there is this function? I tried to search it on ec's super include but without success. Keywords I tried: change, switch, script, scriptset.
This way, if possible would be much better. The other one got complicated.

#4
andysks

andysks
  • Members
  • 1 651 messages
I spent some hour searching the scripts of AJ Haven, because I am certain they use something similar. I know that the guy we fought is the one in the small room, tagged 26_ammo_jero, while the companion is just ammon. I cannot seem to find though how and when they replace him. All I found similar to that, is a comment on the scripts that says "He is replaced now", but the following functions prove no help.

#5
kevL

kevL
  • Members
  • 4 070 messages
- from nwscript.nss

// Brock H. - OEI 03/28/06 -- These must match the values in NWN2_ScriptSets.2da
int SCRIPTSET_INVALID               = -1;
int SCRIPTSET_NOAI                  = 0;
int SCRIPTSET_PCDOMINATE            = 1;
int SCRIPTSET_DMPOSSESSED           = 2;
int SCRIPTSET_PLAYER_DEFAULT        = 3; // These are the default scripts that are loaded onto the player character
int SCRIPTSET_COMPANION_POSSESSED   = 4; // The scripts that are applied on the player when he is controlled by
int SCRIPTSET_NPC_DEFAULT           = 9; // The default scripts for generic NPCs
int SCRIPTSET_NPC_ASSOCIATES        = 10; // The default scripts for NPC associates (summoned creatures, henchmen, etc)

///////////////////////////////////////////////////////////////////////////////
// SetCreatureScriptsToSet
///////////////////////////////////////////////////////////////////////////////
// Created By:  Brock Heinz - OEI
// Created On:  09/23/05
// Modified:    12/19/05
// Description: Reassign all of the creature's scripts to a set specified by
//              the entry in the NWN2_ScriptSets.2DA file. If the creature
//              is not running his default scripts (for example, he is being
//              possessed by a DM), he won't start running the scripts from
//              the new set until he goes back to his default state
///////////////////////////////////////////////////////////////////////////////
void SetCreatureScriptsToSet( object oCreature, int nScriptSet );



you can define additional scriptsets in Nwn2_scriptsets.2da, which can then be referenced by row# (tho a switch from NPC to companion would be #9, already set, to #3 )

#6
Tchos

Tchos
  • Members
  • 5 063 messages
If I had been here sooner, I would have pointed you to Lidda Lightfingers, my thief companion, who begins with NPC scripts since she's sitting and eating at the tavern, and then switches to companion scripts if you let her join you. I used that command SetCreatureScriptsToSet() shown above. I also created a couple of custom script sets in the NWN2_ScriptSets.2DA for special purposes, when I was testing methods of turning an existing generic NPC walking around into a named questgiver with a new conversation. (Assigning a new conversation was the tricky part.)

#7
andysks

andysks
  • Members
  • 1 651 messages
Ah, thanks a lot. I still cannot make it work but at this point I think I am in the right way.
I try to spawn her now using the surrender scripts and hostile, but she will refuse to spawn. I guess it's the gb_comp_spawn... maybe it's necessary to use with my companion functions and library. Maybe I should spawn her with the companion scripts, then shift for the battle and shift again for joining.

#8
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages
In my Silverwand Sample Campaign I have a rogue who can join the party as either a henchman or a companion and that is done by switching his script sets. I haven't looked at that in a very long time though and he didn't start out hostile, so the situation isn't quite the same.

Regards

#9
Dann-J

Dann-J
  • Members
  • 3 161 messages
One important thing about switching scriptsets from 'standard creature' to 'companion' is that you have to force the companion on-spawn script to run on them afterward. Otherwise their companion-specific listening patterns don't get set, and they won't obey any of your commands (peaceful follow, stand your ground, etc). There's a chance the new on-spawn script might run if you reload from a saved game though.

#10
Tchos

Tchos
  • Members
  • 5 063 messages
I set the listening patterns manually in my particular rogue's script to get around that problem.

#11
andysks

andysks
  • Members
  • 1 651 messages

I tried some diferent aproaches, and it turned out the problem is on the companion for the time being. Once I fix it, and she decides to spawn, then I'll see if hostile or gb_comp_spawn are also a problem.



#12
andysks

andysks
  • Members
  • 1 651 messages

Solved the problem, it was something completely diferent. A saved game was causing trouble to the module load script. After this got solved, the companion spawned, even hostile and with the two custom scripts attached. When got low, surrendered as supposed, and also as Dann said she didn't follow when joined. I only need to figure out how to set the listening patterns now an matter is closed. Thanks for the help and info.



#13
Dann-J

Dann-J
  • Members
  • 3 161 messages

The easiest way is to force the default companion OnSpawn script to run on the creature in question.

 

http://nwn2.wikia.co...i/ExecuteScript



#14
kevL

kevL
  • Members
  • 4 070 messages

ie, the script to execute is 'gb_comp_spawn' i believe.

These are the pertinent calls:
 

// Sets up the special henchmen listening patterns (gb_setassociatelistenpatterns)
SetAssociateListenPatterns();
// Set standard combat listening patterns (x0_i0_spawncond)
SetListeningPatterns();
// Set additional henchman listening patterns (x0_inc_henai)
bkSetListeningPatterns();

'gb_comp_spawn' includes several niceties, like setting a follow-distance, etc. etc.



#15
andysks

andysks
  • Members
  • 1 651 messages
This seems fair. I just need to execute the gb_comp_spawn when he joins, or at the end of the surrendering script. Will try it when I get home later and see how it goes. Thanks.

#16
andysks

andysks
  • Members
  • 1 651 messages

The whole thing worked out perfectly. Thanks for the info on how this works. Really valuable information.

Recap: A companion will spawn even with a custom spawn script attached. He will spawn even on hostile faction. All in all, he will spawn no matter what. After that it was a matter of attaching the surrendering script and changing script sets and executing the gb_comp_spawn.

One thing to note, even if I was calling all hostile creatures to hide during the cutscene, the companion was visible. I had to hide him separately on the first node with a ga_scripthidden. I don't know why... I won't search further :D.