Aller au contenu

Photo

Explore XP help needed


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

#1
archer4217

archer4217
  • Members
  • 105 messages
Hiya sweeties,

I have this script that's supposed to give xp when a PC enters a new area and then set a variable on an object they carry so that they don't keep getting xp for entering that area again, but it isn't working right. The PC keeps getting xp no matter how many times they re-enter the area. What am I missing or doing wrong? Any help is greatly appreciated.

/*
 *  Script generated by LS Script Generator, v.TK.0
 *
 *  For download info, please visit:
 *  http://nwvault.ign.c....Detail&id=1502
 */
// Put this script OnEnter.


void main()
{
    object oTarget;

    // Get the creature who triggered this event.
    object oPC = GetEnteringObject();

    // Only fire for (real) PCs.
    if ( !GetIsPC(oPC)  ||  GetIsDMPossessed(oPC) )
        return;

    // Send a message to the player's chat window.
    SendMessageToPC(oPC, "You have discovered a new area. Exploration xp granted.");

    // Give 50 experience to the PC.
    GiveXPToCreature(oPC, 50);

    // Set a local integer.
    oTarget = GetObjectByTag("TokenExplore");
    SetLocalInt(oTarget, "ExplorationXP", 1);
}

#2
Rolo Kipp

Rolo Kipp
  • Members
  • 2 791 messages
<tosses off...>

Before sending a message to the PC, put in a conditional to check if he has the variable set on the token. Return if he does.

<...some good stuff *cough*>

#3
Rolo Kipp

Rolo Kipp
  • Members
  • 2 791 messages
<donning his old...>

Just a little aesthetic suggestion on the phrasing of the reward, if you don't mind <like most advice, it's worth what you pay for it>.

Instead of "Exploration xp granted", which is a little OOC jarring to me, would you consider something like "You've learned something new."? That is, in fact, what I use.

<...professor's mortar>

Modifié par Rolo Kipp, 29 octobre 2011 - 07:16 .


#4
archer4217

archer4217
  • Members
  • 105 messages
Hiya sweetie,
Thanks for the suggestion concerning the OOC message. You're absolutely right, and I'll definately change it. As for fixing the script....help!...I have no idea how to do that using the script generator. *sheepish*
Also, is this script good to use for all the areas, or does each area need something different?

#5
Fester Pot

Fester Pot
  • Members
  • 1 394 messages

void main()
{
object oTarget = GetObjectByTag("TokenExplore");

// Get the creature who triggered this event.
object oPC = GetEnteringObject();

// Only fire for (real) PCs.
if ( !GetIsPC(oPC) || GetIsDMPossessed(oPC) )
return;

if (GetLocalInt(oTarget, "ExplorationXP") == 1) return;

// Send a message to the player's chat window.
SendMessageToPC(oPC, "You have discovered a new area. Exploration xp granted.");

// Give 50 experience to the PC.
GiveXPToCreature(oPC, 50);

// Set a local integer.

SetLocalInt(oTarget, "ExplorationXP", 1);
}


It may be worth noting that if this token the variable is being set on is given to every PC, you should look to make oTarget examine the inventory of the one entering the area, otherwise, GetObjectByTag will get whatever first tag it finds with a match. This means, if it finds the token on another player before finding it on the PC that entered the trigger, the variable would be set on another token and not the desired token of those entering the trigger.

Also, if it's not an inventory item given to the player but rather a placeable somewhere, the first time a player enters the area, the variable "ExplorationXP" will be set to 1, thus any players who follow will not receive exploration experience as the variable has already been set to 1 on "TokenExplore".

FP!

Modifié par Fester Pot, 29 octobre 2011 - 07:53 .


#6
Rolo Kipp

Rolo Kipp
  • Members
  • 2 791 messages
<wipes the sweat from his brow...>

archer4217 wrote...
Hiya sweetie,
Thanks for the suggestion concerning the OOC message. You're absolutely right, and I'll definately change it.

You are welcome :-) You have no idea how ticklish some people <like you>Excuse me? *I* take advice very well<raven chuckles>I *do*!<as long as it's the advice you *asked* for> A base falsehood!<she's still listening, boss> Oh. Right.

As for fixing the script....help!...I have no idea how to do that using the script generator. *sheepish*
Also, is this script good to use for all the areas, or does each area need something different?

Fester Pot's script does the quick fix I mentioned, but *no*, it will work once. To work for *all* areas, you would need (as you described it) a separate variable for each area stored on the token item, perhaps appending the current area resref to the variable name.

Alternatively, if you are making this single player, you could store the variable on the *area* when it gets explored and check the area variable instead of a token item variable.

Either approach will store as many variables as explored areas, but the first will store them all on a token item *for each separate PC*, while the second does *not* require a token item on each PC and only tracks whether the area is explored (not by whom).

This is one of those design decisions you need to make before we go further (unless any of my esteemed colleagues have something super-elegant up their tricky little sleeves ;-).

<...and smiling in relief>

#7
Rolo Kipp

Rolo Kipp
  • Members
  • 2 791 messages
<looking a bit sheepish...>

archer4217 wrote...
 As for fixing the script....help!...I have no idea how to do that using the script generator. *sheepish*

Ah, caveat here.  I've heard nothing but good things about Lilac Soul's script generator, and I've even downloaded it... But I never get around to using it :-( I am just so used to firing up Notepad++ and banging away at the keyboard :-P 

So I can't actually tell you how to use LS to achieve what I see in my head <*no one* wants that, old man> Oh, just hush, bird.

<...himself>

#8
archer4217

archer4217
  • Members
  • 105 messages
Hiya again, sweetie,
So, here's a question I should have asked from the beginning, which only just occurred to me. Is it better to store the info on explored areas on the PC or on a token they carry, and for some reason, I just can't wrap my brain around how to do all this especially since I have a LOT of areas.
This is definately a multiplayer persistant world I'm working on.

#9
Rolo Kipp

Rolo Kipp
  • Members
  • 2 791 messages
<taking the personal approach...>

archer4217 wrote...

Hiya again, sweetie,
So, here's a question I should have asked from the beginning, which only just occurred to me. Is it better to store the info on explored areas on the PC or on a token they carry, and for some reason, I just can't wrap my brain around how to do all this especially since I have a LOT of areas.
This is definately a multiplayer persistant world I'm working on.

That last sentence is the driver.  This means you *must* store info on explored areas for *each player*.  So you should put it on an item or, perhaps their skin (isn't there a variable limit on the skin?).  The reason you put it on an item or the skin is so the variables are not lost on mod transition.

So, that being the case, you need to change the name of the variable to match the area and then loop through *each* PC entering to see if they have the "Xplor_"+( insert function for getting area resref )...

Ack! Gotta go, and I'm in the middle... :-(

Sorry, someone else has to carry on, I'm offline 'til tomorrow.

<...to executive management>

#10
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

Rolo Kipp wrote...


Ack! Gotta go, and I'm in the middle... :-(

Sorry, someone else has to carry on, I'm offline 'til tomorrow.

<...to executive management>


The Questions that need to be answered in order to be able to write the script are:

  • Do you want the XP given only once, or once per reset. This answers where the Var gets stored(Possesed item/PC/Area or whatever) 
  •  If the answer to one above is only once.
     How can the areas be uniquely  identified.  Area Name, Area Tag, Area ID#(Only Good if you do not plan on adding area to the module)
    what ever you use to ID the area you will have to make sure that they are unique for each area. 
     


#11
Xardex

Xardex
  • Members
  • 217 messages
There is no variable limit on the skin. (Why would there be?)

*snip* (lightfoot beat me to it)

Generally it's not a good idea to have many variables to one item. One way to avoid this would be to create a single string variable where you store the tags of the areas, or something like that.

Modifié par Xardex, 29 octobre 2011 - 09:27 .


#12
archer4217

archer4217
  • Members
  • 105 messages
Lightfoot,
The XP has to be given only once per area the PC enters. Each area has a unique tag, and I'm adding areas all the time.
Its a fun world to walk around in. :)

#13
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Ok, Try this:

void main()
{
  // Get the creature who triggered this event.
  object oPC = GetEnteringObject();
  object oTarget = GetItemPossessedBy(oPC, "TokenExplore");
  string sAreaLable = "ExplXP_"+GetTag(OBJECT_SELF);

  // Only fire for (real) PCs.
  if ( !GetIsPC(oPC) || GetIsDMPossessed(oPC) )
  return;

  if (GetLocalInt(oTarget, sAreaLable) == 1) return;
  if (!GetIsObjectValid(oTarget))
  {
    string sError = GetName(oPC)+", Account "+GetPCPlayerName(oPC)+" Is missing an Exploration DB Widget";

    SendMessageToAllDMs(sError);
    WriteTimestampedLogEntry(sError);
    SendMessageToPC(oPC,"OOC: Your character is missing a DB widget, Please contact a DM or staff");

    // Do not give the PC the XP if they do not have the widget.
    return;
  }

  // Send a message to the player's chat window.
  SendMessageToPC(oPC, "You have discovered a new area. Exploration xp granted.");

  // Give 50 experience to the PC.
  GiveXPToCreature(oPC, 50);

  // Set a local integer.
  SetLocalInt(oTarget,sAreaLable , 1);
}


EDIT:  Missed the not(!) in my check for a valid DB Item, Added it.

Modifié par Lightfoot8, 29 octobre 2011 - 11:39 .


#14
archer4217

archer4217
  • Members
  • 105 messages
It worked! Oh, thank you thank you! *hugs*

#15
Rolo Kipp

Rolo Kipp
  • Members
  • 2 791 messages
<limping slowly...>

Xardex wrote...
There is no variable limit on the skin. (Why would there be?)

It's in the back of my mind <a crowded and tiny space> that I saw a post somewhere warning about dumping everything on the skin. It may have been number of feats or something else entirely.

Unfortunately, a half hour search has failed to refresh my memory, so I'll waste no more time on it.

My own research into skins will wait until I model the races I want to use them ;-)

@Lightfoot: Thanks for covering my abrupt abandonment :-/ Had an actual contract walk in the door. Only $40, but it'll feed me or put gas in the tank. Not both, unfortunately :-(

Good catch on the missing widget check. I would have figgered it out when it bit me in a delicate spot... and not before. ;-/

<...back to his favorite tavern>

#16
Failed.Bard

Failed.Bard
  • Members
  • 774 messages

Rolo Kipp wrote...

<limping slowly...>

Xardex wrote...
There is no variable limit on the skin. (Why would there be?)

It's in the back of my mind <a crowded and tiny space> that I saw a post somewhere warning about dumping everything on the skin. It may have been number of feats or something else entirely.

Unfortunately, a half hour search has failed to refresh my memory, so I'll waste no more time on it.

My own research into skins will wait until I model the races I want to use them ;-)

<...back to his favorite tavern>


Performance drops substantially for checking the more variables are stored on an object.  If the PC skin is going to be used for storing other variables that will be checked regularly, you certainly wouldn't want to put hundreds of other variables that are only occasionally checked on it.

  It can actually be handled quite nicely in an IC way, in this case, by giving them an undroppable "Explorer's Journal" book item, and using that to store on.
  The extra few ms needed to check it don't matter if it's accessed once per map only, but it it's checked regularly, especially in combat, it can create a serious performance hit.

  The actual discussion on the performance aspect of it took place in the GetObjectByTag vs GetNearestObjectByTag discussion thread.

Modifié par Failed.Bard, 30 octobre 2011 - 02:48 .


#17
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

Rolo Kipp wrote...

<limping slowly...>

Xardex wrote...
There is no variable limit on the skin. (Why would there be?)

It's in the back of my mind <a crowded and tiny space> that I saw a post somewhere warning about dumping everything on the skin. It may have been number of feats or something else entirely.


As far as the .uti is concerened there is no differance between a skin and an other item.  They can become a pain to use however due to the engine unequiping then to advoid exploits and the X3 horse system failing to re-equip them at times.  i have never worked with skins that much however,  So I have not worked out what the problems are there that much.   

The problem you are most likely thinking of  is the limit that all item have, that is the limit of the number of item propteries that can be placed on an item,  That does limit the number of feats and skill increases/decreases that can be placed on the item.   The Max number if item-props is given in baseitems.2da.   

#18
Rolo Kipp

Rolo Kipp
  • Members
  • 2 791 messages
<giving the dwarf uber-barbarian a *very* heavy chest of gold coins...>

Failed.Bard wrote...
Performance drops substantially for checking the more variables are stored on an object.  If the PC skin is going to be used for storing other variables that will be checked regularly, you certainly wouldn't want to put hundreds of other variables that are only occasionally checked on it.

Yep, that's my understanding, though I have yet to put enough things together to notice anything ;-/

 It can actually be handled quite nicely in an IC way, in this case, by giving them an undroppable "Explorer's Journal" book item, and using that to store on.
  The extra few ms needed to check it don't matter if it's accessed once per map only, but it it's checked regularly, especially in combat, it can create a serious performance hit.

Grrr, I get a bit annoyed by "undroppable, unbreakable" things. I just hate loading the PC up with all that stuff... But until I find a better way, I'll deal.

Currently, I'm thinking of storing all that stuff on tagged placeables (there-by getting the placeable that stores certain variables quickly with GetObjectByTag) in a GM Lounge that is low AI.

That is something in the (self-same) back of my mind when I am looking at inter-mod & inter-server communication.  Be nice if we could attach an invis henchman "courier" for server transitions. I'm pretty sure it will work for inter-mod, but have huge doubts how to do it inter-server.
<sigh>

 The actual discussion on the performance aspect of it took place in the GetObjectByTag vs GetNearestObjectByTag discussion thread.

That was one of the best tech threads I've read lately =)

<...all but the top few being painted lead>

#19
Rolo Kipp

Rolo Kipp
  • Members
  • 2 791 messages
<snapping his fingers...>

Lightfoot8 wrote...
As far as the .uti is concerened there is no differance between a skin and an other item.  They can become a pain to use however due to the engine unequiping then to advoid exploits and the X3 horse system failing to re-equip them at times.  i have never worked with skins that much however,  So I have not worked out what the problems are there that much.   

The problem you are most likely thinking of  is the limit that all item have, that is the limit of the number of item propteries that can be placed on an item,  That does limit the number of feats and skill increases/decreases that can be placed on the item.   The Max number if item-props is given in baseitems.2da.   

*That* was it! Yup. Do you have any links so I can refresh my memory?

<...and making the light dawn>

#20
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

Rolo Kipp wrote...

<snapping his fingers...>

*That* was it! Yup. Do you have any links so I can refresh my memory?

<...and making the light dawn>


My be a late dawn on this one, For I have no links.   If you wanted to try and find some I would try a search on sub races, That is where most people find the limitation, as they try to put to much on the skin to emulate the race.

#21
QlippothVI

QlippothVI
  • Members
  • 109 messages
I'm pretty busy lately so sorry for the late replies, but Universe of Arlandia (google and download) has such a feature, though a db is used (either nwndb or mysql).

#22
QlippothVI

QlippothVI
  • Members
  • 109 messages
Sorry, on road trip and nwn system doEsnt allow edits. I meant a system for tracking explored areas.