@MagicalWisps
I think I ought to clear up some terminology here, as NWN2 handles parties, PCs, companions/cohorts, associates and even players differently.
1) NUMBER OF PARTIES
a) In a MP game, you can allow more than one party, where a number of players may form their own parties and own factions. (A PW approach.)
b) In a MP game, a module may restrict to a SINGLE PARTY (this is what I do), so no matter how many players join the game, they are all part of the same single party. (A MP Coop approach.)
c) In a SP game, there is only ever one party.
d) The PARTY SIZE is limited by the server settings. Therefore, you cannot, as you say, have a party size that is “unlimited”. Imagine a party size of 100, that would mean 100 portraits on the side.
2) PLAYER vs PCs v COMPANIONS
a) In a MP game, you can have as many players as your server can support, up to a maximum of ? … I don’t run a Persistent World server, so I don’t know what the maximum can be. However, I do run a MP campaign that limits the game to a SINGLE PARTY, which I allow up to four players. However, I allow up to six PCs in the SINGLE PARTY.
b) A player can often switch between their main PC (which they joined the game with), and/or any companions or cohorts they have had join their PARTY faction. If this is a SP game, then you will have a SINGLE player, with a SINGLE PLAYER FACTION, of which the player can have join as many cohorts (self made PCs), or companions (found in your world), as you allow.
c) Furthermore, you also have associates for every PC, such as familiars, animal companions, summons and henchmen.
3) YOUR SETUP: SP or MP Questions
To clarify your requirements, we need to know the following:-
a) Is this a SP or a MP module/campaign?
b) Are you allowing the player to add more PCs (cohorts) or find companions (from your world), to join this PARTY?
MY GUESS: I am guessing that you mean to design for a SP game only, and you will need to know what limit you are setting fro the party size for that single player. However, correct me if I have that wrong.
c) You say, “players are stuck”, but do you mean PCs? For when you say “players” (plural), then it sounds like a MP game.
d) Then you want the item to go into “the inventory of the PC character”. Again, we need to clarify if you mean it is a MP game (with more than one player), or is a SP game, with only one player? Then, we need to clarify if you mean the item can go into the inventory of the PC the player is currently possessing, or if you want the item to go into the Main PC (the one the player joined the game with), even if they currently posses another PC in their party?
e) So when you say “(Must be a PC)”, again, do you mean it has to be the Main PC, or any PC that the player has in their party, which they may, or may not, be possessing? Because, what if the player is playing their Main PC (who is a fighter), but the PC wizard (in their party) does the final kill? Did you mean that the Main PC still gets the item, even of their party wizard does the kill, as opposed to the fighter, who the player is actually (default) possessing at the time? Or, what if the player is possessing the wizard, and the Main PC (the fighter) kills the creature while the player is actually possessing the wizard PC?
MY CONCLUSION
ASSUMPTION 1: Here I will make as the best interpretation of what you are after: I assume you mean to say that this is a SP game, with a party of perhaps a maximum of six PCs (made from Main PC, cohorts and/or companions), which can indeed grow larger, if any of these PCs (of the same party) also have associates, such as summons, companions, familiars, or henchmen. Basically, a SINGLE PARTY game catering for a SINGLE PLAYER.
ASSUMPTION 2: Regardless of which PC the player currently possesses and plays, you wish the item to go to the Main PC upon the death of the creature.
ASSUMPTION 3: You need this item to drop (and be in the Main PC inventory) on the death of this creature.
I repeat that there is a risk that using GetLastKiller may not always give you what you need, and is why I am avoiding using it, unless you know it is not an essential item, which can go missed if this function fails.
SOLUTION A: As this item is effectively just a token, which you need to record progress, I would suggest implementing a journal update instead, and use that as the indication of what stage the player is at. I would also use variables to track the overall number of items collected.
SOLUTION B: Ensure the item is created on the Main PC (the one which the player joined the game with first), at the time of the creature death regardless of how it died. I make the assumption that the creature cannot die any other way, or if you intended an alternate way for the beast to die or not? If it is a simple matter of needing the item on the Main PC at time of the creature’s death, the the safest and surest way to do it (avoiding any potential OBJECT_INVALID via using GetLastKiller) is to use the script I posted above.
NB: If there is no chance of a MP game (and/or involving a DM), then you need not do the DM check, and you could even avoid the loop altogether. So when you say, “So You need a way to give the player the item when a creature is killed.”, then this is all you need…
SP VERSION: On the creature’s OnDeath hook.
(See my original script above for a MP version.)
//////////////////////////////////////////////////////////////////////////////////
// JUST GIVES AN ITEM TO PLAYER MAIN PC WHEN CREATURE KILLED (SP GAME ONLY)
// ASSUMES WE NEED THE ITEM ON THE MAIN PC REGARDLESS OF WHO KILLED THE CREATURE
// ALSO ASSUMES THAT THE CREATURE CANNOT DIE ANY OTHER WAY
//////////////////////////////////////////////////////////////////////////////////
void main()
{
CreateItemOnObject("item_resref", GetFirstPC(TRUE)); // <-- put your item's resref here
}
EDIT: I just read this …
So, this now begs the question about whether this is a SP or MP again? So, we need more description about how your module is setup to play.
Hopefully, after reading this post, you will be able to clarify your needs. This post info conflicts with your latest that says “The party size is unlimited”.
So, how does this fit in with your first quote I have for you? If not companions, are you meaning cohorts?