I've been trying to get this to work all evening, and it just isn't happening. I'm creating a small area in the beginning of my campaign where the player can assemble their full team (either multiplayer or Zehir-style party creation), then level the team to the recommended level for the adventure, and purchase supplies on a set budget.
I've got the party system, I've got the store. The levelling, not so much. I'm using SetXP, but try as I might I can only get it to work on the first member of the team. I've searched online and haven't come up with anything useful. Ideally, it would just be one script the executes on a conversation choice that levels the whole party. But up until now I've been stumbling through scripting, doing my level best to pretend I understand what I'm doing.
Any suggestions?
Can SetXP be used on the whole party?
Débuté par
Tonytobinus
, août 07 2010 03:50
#1
Posté 07 août 2010 - 03:50
#2
Posté 07 août 2010 - 04:12
A script example might be useful here, but I can ask if you are using a loop of any sort to iterate through party? That is generally how it is done.
I made an on spawn script for my Tomb of Horrors adaptation that applies to any character that enters the module. There is used this script:
void a_spawn_exp()
{
object oNPC = OBJECT_SELF;
int exp = 40000;
SetXP(oNPC, exp);
}
I call it at the end of the Companion default spawn script with ExecuteScript(). This is still a basic workaround as the ToH is still in progress,,,
I made an on spawn script for my Tomb of Horrors adaptation that applies to any character that enters the module. There is used this script:
void a_spawn_exp()
{
object oNPC = OBJECT_SELF;
int exp = 40000;
SetXP(oNPC, exp);
}
I call it at the end of the Companion default spawn script with ExecuteScript(). This is still a basic workaround as the ToH is still in progress,,,
#3
Posté 07 août 2010 - 04:16
You need to loop through the faction members. This script should work for you.
Regards
// ga_bb_give_xp
// by Brendan Bellina
// December, 2007
// rev. June, 2008 to default to conversation OWNER
// rev. Aug, 2010 to allow giving to an entire faction
// Conversation action script to give xp to a creature.
// Useful when first adding a companion or henchman to a party.
// By default uses GiveXPToCreature
// Pass 1 as useSet to use SetXP
// Note: Cannot set xp to 0
// Pass 1 as nParty to give/set xp to everyone in the faction
#include "ginc_param_const"
void main(string sPC, int nXP, int useSet = 0, int nParty = 0)
{
// Give nXP to creature with tag sPC, or if sPC is blank to conversation owner
object oPC = GetTarget(sPC, TARGET_OWNER);
if (GetIsObjectValid(oPC) == TRUE && nXP)
{
if (!nParty)
{
if (!useSet)
GiveXPToCreature( oPC, nXP );
else
SetXP( oPC, nXP );
}
else
{
object oFM = GetFirstFactionMember(oPC, TRUE);
while( oFM != OBJECT_INVALID )
{
if (!useSet)
GiveXPToCreature( oFM, nXP );
else
SetXP( oFM, nXP );
oFM = GetNextFactionMember(oPC, TRUE);
}
}
}
else
{
ErrorMessage("ga_bb_give_xp: " + sPC + " not found or no XP specified");
}
}
Regards
#4
Posté 07 août 2010 - 04:17
Hmmm... well I guess the old code tags don't work here. Sorry about that.
#5
Posté 07 août 2010 - 04:32
Kaldor Silverwand wrote...
Hmmm... well I guess the old code tags don't work here. Sorry about that.
You haven't seen it when ALL formatting is removed - it gets all bunched up into a single text block - very annoying I think
BTW, this site has lots of ga_ and gc_ scripts for conversations: http://nwcitadel.for...splay.php?f=153
Modifié par Morbane, 07 août 2010 - 04:37 .
#6
Posté 07 août 2010 - 05:00
Thanks so much, guys! I think I had the right idea, looping through faction members, but without any real understanding of the language. my version went something like:
void main()
object oPC = GetFirstPC();
object oTeam = Get NextPC();
SetXP(oPC, ######);
SetXP(oTeam, #####);
SetXP(oTeam, #####);
and so on, going in after each failure and substituting oTeam with different objects that I didnt entirely understand but sounded kinda right. This is why "Lilac" is my favorite color. Well, I'm learning - slowly but surely. Thanks again.
void main()
object oPC = GetFirstPC();
object oTeam = Get NextPC();
SetXP(oPC, ######);
SetXP(oTeam, #####);
SetXP(oTeam, #####);
and so on, going in after each failure and substituting oTeam with different objects that I didnt entirely understand but sounded kinda right. This is why "Lilac" is my favorite color. Well, I'm learning - slowly but surely. Thanks again.
#7
Posté 07 août 2010 - 11:41
Just my usual note on things like this - you might find my scripting tutorial useful. Along with a bunch of other things, it has a section on looping through objects. Written for the beginning scripter. Link below in sig.
#8
Posté 16 août 2010 - 07:10
Thanks, Knight! I'll be referencing that a lot in the weeks (probably months) to come.
#9
Posté 17 août 2010 - 11:24
NP, hope you find it helpful. If you have any suggestions for edits/additions feel free to let me know.
#10
Posté 17 août 2010 - 10:31
Hmm. I seem to be running into some problems with this still, and I can't figure out why. I'm using the ga_bb_give_xp script above, triggering it when the player clicks on a line of dialogue. I set the variables in the actions tab, with nXP set to the right amount, and useSet and nParty both set to 1. sPC is left blank, but from what I understand, that just means the script identifies oPC as the speaker of the line of dialogue triggering the script, in this case the player. When I go in and test this, there is no xp granted. Nothing happens
I went into the script and changed this:
object oPC = GetTarget(sPC, TARGET_OWNER);
to this:
object oPC = GetPCSpeaker();
Ran the test again. The correct amount of xp is awarded to the active character only, and not the rest of the team. At this point I'm considering just making it a single player, non-party adventure, just so I can get on with the actual meat of the game. But before I settle for less, can anyone point me to the giant, neon "this is what you're doing wrong, newbie!" sign flashing right in front of me that I seem to be missing?
I went into the script and changed this:
object oPC = GetTarget(sPC, TARGET_OWNER);
to this:
object oPC = GetPCSpeaker();
Ran the test again. The correct amount of xp is awarded to the active character only, and not the rest of the team. At this point I'm considering just making it a single player, non-party adventure, just so I can get on with the actual meat of the game. But before I settle for less, can anyone point me to the giant, neon "this is what you're doing wrong, newbie!" sign flashing right in front of me that I seem to be missing?
#11
Posté 17 août 2010 - 11:30
Tonytobinus wrote...
Ran the test again. The correct amount of xp is awarded to the active character only, and not the rest of the team. At this point I'm considering just making it a single player, non-party adventure, just so I can get on with the actual meat of the game. But before I settle for less, can anyone point me to the giant, neon "this is what you're doing wrong, newbie!" sign flashing right in front of me that I seem to be missing?
As written that script will only give the XP change to a single designated character. To give the XP to all characters in the party you would need to loop through the party members and give it to them that way.
#12
Posté 17 août 2010 - 11:35
Are you sure the modified version Kaldor posted above won't do it? That's what I'm using, and it looks like it is set up to loop to the next faction member as long as oFM is a valid target.
#13
Posté 18 août 2010 - 12:15
Doh! I was looking at a copy of his original script posted in the link Morbane provided, sorry about that. Just ignore me lol.
#14
Posté 18 août 2010 - 04:14
Nah, you've been plenty helpful already, so ignoring you would be unwise. I'm going to keep plugging away at this, even if it is slowing me down. I feel like giving players the chance to bring a well-rounded team would let a designer really cut loose and come up with really inventive encounters, without that nagging 'but when if they don't have a ____" feeling.
#15
Posté 18 août 2010 - 05:36
So I am settling for a bull#### workaround in which I enable party chat and make the levelling dialogue a repeatable option, and even rationalized it a bit with the conversation. I tried using the suggestions above. I even understand how they should work, but for whatever reason it is just not cooperating. Hopefully this will work, though. I will find out tomorrow.
#16
Posté 20 août 2010 - 06:41
I'll take another look at the script. Seems like it should work fine though.
#17
Posté 20 août 2010 - 09:21
*nods* thank you so much - anything you can do to help is greatly appreciated. Would any additional information that you can think of help?
*edit* and this, of course, means that my attempted work-around did not help. I've moved on to building other parts of the mod for now, but whether or not I can get the team-levelling to work has a big impact on how I balance the game.
*edit* and this, of course, means that my attempted work-around did not help. I've moved on to building other parts of the mod for now, but whether or not I can get the team-levelling to work has a big impact on how I balance the game.
Modifié par Tonytobinus, 20 août 2010 - 09:23 .
#18
Posté 21 août 2010 - 03:48
HOT DAMN! I got it to work - kind of. It's not exactly what I wanted, but the end result is the same.
I did a little digging in the SoZ opening area to see how they got the whole team to level 3. They used an onEnter script that I was able to tweak to my needs. The only thing - the script will not level BOTH the initial player character and the 3 player-created faction members. Only one or the other. So I placed a trigger under where the intial PC spawns to set their XP (and fire only once), and the onEnter script applies to the rest of the team. My "in-character" rationale for setting the party's level is out the window, but seeing as this is in no way relevant to the plot, I can happily sacrifice it.
Thank you again, Kaldor, Morbane and Knightmare, for your help, you definitely steered me in the right direction and taught me a few cool things!
Also, here's the modified SoZ onEnter script. It basically sets a minimum xp number for every faction member entering the area, and if they have less than that, it sets it to that number (which...anyone who has posted here could easily tell. I'm just showing off that I'm learning):
#include "ginc_companion"
#include "ginc_debug"
void main()
{
object oEnter = GetEnteringObject();
PrettyDebug("nx2_enter_levelup: " + GetName(oEnter) + " entered " + GetName(GetArea(oEnter)));
if ( !GetIsRosterMember(oEnter) || GetTag(oEnter) != "" || GetLocalInt(oEnter, "nx2_bEnterXPGranted"))
{
PrettyDebug("nx2_enter_levelup: " + GetName(oEnter) + " is either not a roster member, or is a cohort" );
return;
}
object oPC = GetFirstPC();
while ( GetIsObjectValid(oPC) && oPC == oEnter )
{
oPC = GetNextPC();
}
int nXP = GetXP(oEnter);
int nPCXP = GetXP(oPC);
int nMinXP = 190000;
PrettyDebug("nx2_enter_levelup: nMin XP = " + IntToString(nMinXP));
// Set XP if less than the Min XP
if ( nXP < nMinXP )
{
PrettyDebug("nx2_enter_levelup: Setting XP of " + GetName(oEnter) + " to " + IntToString(nMinXP));
SetXP(oEnter, nMinXP);
// Set a local variable on the character so they won't get this XP again.
SetLocalInt(oEnter, "nx2_bEnterXPGranted", 1);
}
else
PrettyDebug("nx2_enter_levelup: " + GetName(oEnter) + " has " + IntToString(nXP) + " XP which is not greater than the Minimum " + IntToString(nMinXP) + " XP");
}
I did a little digging in the SoZ opening area to see how they got the whole team to level 3. They used an onEnter script that I was able to tweak to my needs. The only thing - the script will not level BOTH the initial player character and the 3 player-created faction members. Only one or the other. So I placed a trigger under where the intial PC spawns to set their XP (and fire only once), and the onEnter script applies to the rest of the team. My "in-character" rationale for setting the party's level is out the window, but seeing as this is in no way relevant to the plot, I can happily sacrifice it.
Thank you again, Kaldor, Morbane and Knightmare, for your help, you definitely steered me in the right direction and taught me a few cool things!
Also, here's the modified SoZ onEnter script. It basically sets a minimum xp number for every faction member entering the area, and if they have less than that, it sets it to that number (which...anyone who has posted here could easily tell. I'm just showing off that I'm learning):
#include "ginc_companion"
#include "ginc_debug"
void main()
{
object oEnter = GetEnteringObject();
PrettyDebug("nx2_enter_levelup: " + GetName(oEnter) + " entered " + GetName(GetArea(oEnter)));
if ( !GetIsRosterMember(oEnter) || GetTag(oEnter) != "" || GetLocalInt(oEnter, "nx2_bEnterXPGranted"))
{
PrettyDebug("nx2_enter_levelup: " + GetName(oEnter) + " is either not a roster member, or is a cohort" );
return;
}
object oPC = GetFirstPC();
while ( GetIsObjectValid(oPC) && oPC == oEnter )
{
oPC = GetNextPC();
}
int nXP = GetXP(oEnter);
int nPCXP = GetXP(oPC);
int nMinXP = 190000;
PrettyDebug("nx2_enter_levelup: nMin XP = " + IntToString(nMinXP));
// Set XP if less than the Min XP
if ( nXP < nMinXP )
{
PrettyDebug("nx2_enter_levelup: Setting XP of " + GetName(oEnter) + " to " + IntToString(nMinXP));
SetXP(oEnter, nMinXP);
// Set a local variable on the character so they won't get this XP again.
SetLocalInt(oEnter, "nx2_bEnterXPGranted", 1);
}
else
PrettyDebug("nx2_enter_levelup: " + GetName(oEnter) + " has " + IntToString(nXP) + " XP which is not greater than the Minimum " + IntToString(nMinXP) + " XP");
}
#19
Posté 21 août 2010 - 05:02
Incidentally - I believe that once the party enters the game / mod the OnEnter will not fire again - i.e. from a saved game the OnEnter doesn't fire again. I could be mistaken, but I have never had it happen to me, because the OnEnter method is what I use in ToH.





Retour en haut






