Question About Plots
#1
Posté 16 août 2012 - 11:12
So I was looking at sunjammer's tutorial on plots on the wiki. What I'm looking for is how to set a plot to check if a player has an item. I believe the wiki is on point with this but I am just not sure if I have it right. Alternatively maybe a script would work better anyway here is the just of what I am looking at:
Player meets npc who is trapped in a cell,
Player can either offer to help free the npc or reject it, if player rejects when they come back the NPC basically ask if they had a change of heart
If player accepts, player subsequently needs to find a key.
**All the above works so far**
What I need is this
If the player returns without a key a conversation promps with a basic "Did you find the key?" answer: yes or no
Now, the no option is showing up just fine because it shows up by default
Problem is getting a conditional for the yes option that checks that player has key in their inventory.
Hmmm, now that I right this I am thinking a conditional script would be the better way to go rather than messing with plot defined flags...
~Lucrane
#2
Posté 17 août 2012 - 04:19
For any function that returns a true/false you can also directly set nResult using it, i.e. nResult = UT_MoneyCheck(oPC, 0,0,1);case PLAYER_HAS_KEY_CHECK:
{
if ((UT_CountItemInInventory(oPC, R"key.uti") == 1))
{
nResult = TRUE;
}
}
Then just have a conditional line that points to your defined flag - when the line appears, the script will be called to check for the items in the player's inventory and return either true or false depending on it. To actually, say, remove the key, or reward XP or anything like that, you will need to use a standard plot flag, because defined flags can only be checked when they are called and can't execute scripts themselves.
This is all made much easier by the conversation system, though you could also use a script to handle things, i.e. manually updating a plot flag in your script when a defined flag is true.
Modifié par sea-, 17 août 2012 - 04:23 .
#3
Posté 17 août 2012 - 07:29
#include "wrappers_h"
#include "plot_h"
#include "PLT_QUE_SID_HAK"
int StartingConditional()
{
// default result is false
int nResult;
event evEvent = GetCurrentEvent();
int nEventType = GetEventType(evEvent);
// the plot flag is the second value in the event's ints list
int nPlotFlag = GetEventInteger(evEvent, 256);
if(nEventType == EVENT_TYPE_GET_PLOT)
{
switch(nPlotFlag)
{
case KEY_FOUND:
{
// get a reference to the player
object oHero = GetPartyLeader();
// check if all items have been collected
if(IsObjectValid(GetItemPossessedBy(oHero, "ald200_prisonkey")))
{
nResult = TRUE;
}
break;
}
}
}
return nResult;
}
Additionally I have a plot named que_sid_hak, there is a defined flag in this plot called KEY_FOUND and the flag int of this defined flag is 256, and finally there is a key hidden in the area with a tag of ald200_prisonkey.
So two questions: Is this script good to go like this? Second, where does this script go? currently I have it as the event script assigned to this plot resource via the object inspector for this plot.
#4
Posté 18 août 2012 - 03:04
#include "log_h"
#include "utility_h"
#include "wrappers_h"
#include "plot_h"
#include "PLT_QUE_SID_HAK"
int StartingConditional()
{
event eParms = GetCurrentEvent(); // Contains all input parameters
int nType = GetEventType(eParms); // GET or SET call
string strPlot = GetEventString(eParms, 0); // Plot GUID
int nFlag = GetEventInteger(eParms, 1); // The bit flag # being affected
object oParty = GetEventCreator(eParms); // The owner of the plot table for this script
object oConversationOwner = GetEventObject(eParms, 0); // Owner on the conversation, if any
int nResult = FALSE; // used to return value for DEFINED GET events
object oPC = GetHero();
plot_GlobalPlotHandler(eParms); // any global plot operations, including debug info
if(nType == EVENT_TYPE_SET_PLOT) // actions -> normal flags only
{
int nValue = GetEventInteger(eParms, 2); // On SET call, the value about to be written (on a normal SET that should be '1', and on a 'clear' it should be '0')
int nOldValue = GetEventInteger(eParms, 3); // On SET call, the current flag value (can be either 1 or 0 regardless if it's a set or clear event)
// IMPORTANT: The flag value on a SET event is set only AFTER this script finishes running!
switch(nFlag)
{
//put main, non-defined plot flags in here
}
}
else // EVENT_TYPE_GET_PLOT -> defined conditions only
{
switch(nFlag)
{
case KEY_FOUND:
{
// check if all items have been collected
if(IsObjectValid(GetItemPossessedBy(oHero, "ald200_prisonkey")))
{
nResult = TRUE;
}
break;
}
}
}
plot_OutputDefinedFlag(eParms, nResult);
return nResult;
}
Note that you don't really need GetPartyLeader there unless for some reason you have replaced the player-created hero or don't have one (GetMainControlled also works). Personally I also just use UT_CountItemInInventory but your method should work fine too.
Modifié par sea-, 18 août 2012 - 03:06 .





Retour en haut







