Aller au contenu

Photo

Money Check in Conversation


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

#1
modestystudio

modestystudio
  • Members
  • 8 messages
I'm trying to do the same thing described in this post here:
http://social.biowar...1/index/1957912

The answer is a bit too vague for me. I'm not sure how to set a defined flag as a condition in script. I've looked at several sample scripts that do something similar, but I haven't been able to figure it out myself.

Currently I have the plot set up like the linked post suggests: a main flag and a defined flag.

A nudge in the right direction would be most helpful. Thanks.

#2
Sunjammer

Sunjammer
  • Members
  • 925 messages
Lets assume, as in that example, you want to check if the player can afford 10 copper and, if they can, remove it. What you will need to do is create a plot (lets call it ms_money) with a main flag (lets call it MS_MONEY_TAKE_10) and a defined flag (lets call it MS_MONEY_CHECK_10). You will also need a custom plot script (lets call that ms_money) as well.

1. Once you have created your plot click on the ellipsis button in its Script property in the Object Inspector to bring up the Resource Open/Save form.

2. Click on the New button to bring up the Create New Resource form, set the Resource Name as "ms_money", and click the OK button.

3. Both forms will close and the plot's Script property should now say "ms_money". Right-click on the property and select Open Resource from the context menu.

NOTE: you can also open this script in the normal way by going to the Scripts tab in the Resource Palette and selecting it there.

4. Copy the following code into the empty script then save and compile it:

//------------------------------------------------------------------------------
//  ms_money
//------------------------------------------------------------------------------
#include "plot_h"
#include "utility_h"

#include "plt_ms_money"

//------------------------------------------------------------------------------
//  MAIN
//------------------------------------------------------------------------------

int StartingConditional()
{
    int bResult;

    // common variables
    object oHero = GetHero();

    // deconstruct event
    event evCurrent = GetCurrentEvent();
    int nEventType = GetEventType(evCurrent);
    int nPlotFlag = GetEventInteger(evCurrent, 1);

    //--------------------------------------------------------------------------
    // Handle the Get/Set Plot Events
    //--------------------------------------------------------------------------

    switch(nEventType)
    {
        case  EVENT_TYPE_SET_PLOT:
        {
            switch(nPlotFlag)
            {
                case MS_MONEY_TAKE_10:
                {         
                    UT_MoneyTakeFromObject(oHero, 10, 0, 0);
                    break;
                }
            }
            break;
        }
        case EVENT_TYPE_GET_PLOT:
        {
            switch(nPlotFlag)
            {
                case MS_MONEY_CHECK_10:
                {
                    bResult = UT_MoneyCheck(oHero, 10, 0, 0);
                    break;
                }
            }
            break;
        }
    }

    return bResult;
}

Obviously this is just an example and I've used a generic name "ms_money" which you can replace with your own preferred name. One thing to note is the third #include statement. The format for this is always plt_<plot_name> so if your plot name is different make sure you update that line.

Modifié par Sunjammer, 10 mai 2012 - 10:30 .


#3
modestystudio

modestystudio
  • Members
  • 8 messages
Many thanks. That clarifies a lot.
Also thanks for the example projects with main/defined flags. It really helped me figure out proper plot formats.