Aller au contenu

Photo

Peform action on area transition


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

#1
sea-

sea-
  • Members
  • 264 messages
I'm running into an interesting problem.  I have a scenario where the player, if a skill check is failed, has his/her pocket picked and loses 10% of his/her money.  The way I want it to work is for the player to only notice the theft later on.  The way I'm handling it (if I can) is thusly, in my module script:

       case EVENT_TYPE_AREALOAD_SPECIAL:
        {
            if (WR_GetPlotFlag(PLT_DESPERATE_MOTHER, MOTHER_MODULE_CHECK_IN_PROGRESS) == TRUE)
            {
                object oPC = GetHero();
               
                int nMoney = GetCreatureMoney(oPC);
                int nMoneyTheft = FloatToInt(nMoney * 0.1);
               
                if (nMoney > 9)
                {
                    UT_MoneyTakeFromObject(oPC, nMoneyTheft);               
                   
                    DisplayFloatyMessage(oPC, "<desc>You suddenly notice your wallet feels a little lighter.  Damned pickpockets.</desc>", FLOATY_MESSAGE, 16777215, 3.0);
                }
               
            WR_SetPlotFlag(PLT_DESPERATE_MOTHER, MOTHER_MODULE_CHECK_IN_PROGRESS, FALSE);
            }
        break;
        }

Only problem is, it doesn't work.  I know the plot flags aren't the issue because I have tested with those checks disabled - in fact, the entire block doesn't work because the floaty message never shows up.  I've tried a few different event types, and made sure to change things so I know 100% it should work (like removing the variables there), but no success so far.

So, my question is - is there a way to actually do this, or do I have to fake it using, say, triggers?  Is there any sort of elegant solution?

Modifié par sea-, 25 mars 2012 - 08:08 .


#2
Sunjammer

Sunjammer
  • Members
  • 925 messages
The first thing I noticed is you say module script but you are using an area event: area events are not automatically sent to a module script therefore I hope this was a simple misstatement. If not then you need to move that code block to a custom area event script.

The second thing I would say is that just because a floaty text message doesn't show up doesn't mean that the rest of the script isn't working. To confirm if something is actually working or not I recommend using PrintToLog as it doesn't have the same limitations as floaty text (which was presumably only intended for when the player can see the screen). If you do this you'll see the script is running the text simply isn't being displayed.

Fortunately there are a few ways round this. You could use triggers; you could use a heartbeat; or you could simply use a delayed event. for example:

case EVENT_TYPE_AREALOAD_SPECIAL:
{
    DelayEvent(3.0, OBJECT_SELF, Event(90210));
    break;
}
case 90210:
{
    if(WR_GetPlotFlag(PLT_DESPERATE_MOTHER, MOTHER_MODULE_CHECK_IN_PROGRESS))
    {
        object oHero = GetHero();
       
        int nTake = GetCreatureMoney(oHero) / 10;
      
        if(nTake > 0)
        {
            UT_MoneyTakeFromObject(oHero, nTake);               
            DisplayFloatyMessage(oHero, "<desc>You suddenly notice your wallet feels a little lighter.  Damned pickpockets.</desc>", FLOATY_MESSAGE, 16777215, 3.0);
        } 
        
        WR_SetPlotFlag(PLT_DESPERATE_MOTHER, MOTHER_MODULE_CHECK_IN_PROGRESS, FALSE);
    }
    break;
}

Modifié par Sunjammer, 25 mars 2012 - 10:09 .


#3
sea-

sea-
  • Members
  • 264 messages
I decided to just go with triggers. Had to modify a few waypoints and character locations to get it to really work smoothly, but it seemed the simplest solution. And yes, I was using the event in the module script, which was my first mistake.

The problem with doing it in area scripts is I'd have to put it in every other area script I have (or at least directly connected areas), which isn't very simple either. So, it would work, but it's not really elegant. In retrospect the timer option is probably the best for immersion's sake, but as it's a one-time event it's not really a big deal either way.

Thanks for your detailed response, though! That may well come in handy for some other ideas I have (and I learned how to delay events, too, yay).