Author Topic: Explore XP help needed  (Read 612 times)

Legacy_archer4217

  • Full Member
  • ***
  • Posts: 206
  • Karma: +0/-0
Explore XP help needed
« on: October 29, 2011, 07:39:41 pm »


               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);
}
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Explore XP help needed
« Reply #1 on: October 29, 2011, 07:57:37 pm »


               <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*>
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Explore XP help needed
« Reply #2 on: October 29, 2011, 08:02:12 pm »


               <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 .
                     
                  


            

Legacy_archer4217

  • Full Member
  • ***
  • Posts: 206
  • Karma: +0/-0
Explore XP help needed
« Reply #3 on: October 29, 2011, 08:30:53 pm »


               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?
               
               

               
            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Explore XP help needed
« Reply #4 on: October 29, 2011, 08:42:52 pm »


               

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 .
                     
                  


            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Explore XP help needed
« Reply #5 on: October 29, 2011, 08:57:40 pm »


               <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>
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Explore XP help needed
« Reply #6 on: October 29, 2011, 09:05:39 pm »


               <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>
               
               

               
            

Legacy_archer4217

  • Full Member
  • ***
  • Posts: 206
  • Karma: +0/-0
Explore XP help needed
« Reply #7 on: October 29, 2011, 09:51:44 pm »


               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.
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Explore XP help needed
« Reply #8 on: October 29, 2011, 10:04:50 pm »


               <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>
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Explore XP help needed
« Reply #9 on: October 29, 2011, 10:22:46 pm »


               

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. 

     

               
               

               
            

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
Explore XP help needed
« Reply #10 on: October 29, 2011, 10:25:40 pm »


               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 .
                     
                  


            

Legacy_archer4217

  • Full Member
  • ***
  • Posts: 206
  • Karma: +0/-0
Explore XP help needed
« Reply #11 on: October 29, 2011, 11:55:24 pm »


               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. '<img'>
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Explore XP help needed
« Reply #12 on: October 30, 2011, 12:37:24 am »


               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 .
                     
                  


            

Legacy_archer4217

  • Full Member
  • ***
  • Posts: 206
  • Karma: +0/-0
Explore XP help needed
« Reply #13 on: October 30, 2011, 01:01:29 am »


               It worked! Oh, thank you thank you! *hugs*
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Explore XP help needed
« Reply #14 on: October 30, 2011, 01:57:38 pm »


               <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>