Setting plot flag based on item in inventory
#1
Posté 05 janvier 2010 - 03:12
Anyway, I need to set a plot flag, GIFT_OBTAINED, based on whether the item is in inventory or not. I'm buying the item from a merchant.
Following the example of retrieving the innkeeper's sword from the Demo Tutorial mod, I added the following to my module script:
case EVENT_TYPE_CAMPAIGN_ITEM_ACQUIRED:
{
object oItem = GetEventObject(ev,0);
if (GetTag(oItem) == "sod_book")
{
WR_SetPlotFlag(PLT_SOD_GIFT_PLOT, GIFT_OBTAINED, TRUE,TRUE);
}
break;
}
The variable ITEM_SEND_AQUIRED_EVENT is set to "1"
I made sure to #include plt_sod_gift_plot in my module script.
The plot flag in question does in fact exist (I can trigger it just fine from dialogue, but that opens up the possibility of setting the flag without actually having the book).
The script compiles just fine, but when the item goes into my inventory (item type is Gift, and it's set as a Plot Item), the flag doesn't get set.
Anybody have any idea what I am missing? Or is more information needed?
#2
Posté 06 janvier 2010 - 12:01
The event EVENT_TYPE_CAMPAIGN_ITEM_ACQUIRED is generated by the player's EVENT_TYPE_INVENTORY_ADDED in player_core. If you aren't using that script, the module event won't fire.
#3
Posté 06 janvier 2010 - 01:39
cstanish wrote...
I have to confess David, I don't know what you mean by " what script is on the player." I freely admit to being a noob, and I don't recall seeing any references to player_core in any of the tutorials I've followed so far so I don't really know how to approach referencing it.
player_core is a script assigned by default to all party members. If you haven't intentionaly changed that, then it's probably not the problem.
Assuming everything is compiling and exporting properly, I'm at a loss as to why the script doesn't work, unless there's some minor typo somewhere, like in a tag. You may have to use logging to figure out exactly where it's going wrong.
#4
Posté 06 janvier 2010 - 06:04
cstanish wrote...
Well, I didn't change it intentionally, no but that's not to say I couldn't have done it by mistake.
I just triple-checked the tag for the item, and it's definitely correct. Hmmm.
Does it make a difference that I'm buying it from a merchant? I notice that when I first buy it, it doesn't appear in my inventory right away. I have to close the shop window and then re-open my inventory to see it.
It's worth testing. Just put another copy of the item in a container somewhere convenient and see if picking it up that way works. My instinct is that buying from a merchant should still work, but I can't say I've ever specificaly tested it.
#5
Posté 06 janvier 2010 - 04:34
#6
Posté 06 janvier 2010 - 09:39
cstanish wrote...
OK so I copied the text of ECLog.ini which was thankfully provided in the wiki and saved it as a new ini file in bin_ship. The log indicates that the EVENT_TYPE_CAMPAIGN_ITEM_ACQUIRED is apparently not happening, as neither of the PrintToLog messages appear in the resulting log file.
Try putting the log messages in something you know for sure is running, just to make sure you are getting log messages at all.
Once you know that, make a local copy of player_core and put some log nessages in there, too see why the event is not being created/sent. There should be an inventory event sent to the player when they get the item, see if you can get a message to print then. If you do, try and see if the variable is being recognized on the item and if the code is running to singal the event to the module.





Retour en haut






