Aller au contenu

Photo

Setting plot flag based on item in inventory


37 réponses à ce sujet

#1
cstanish

cstanish
  • Members
  • 90 messages
Seems like it should be pretty straightforward, but I'm obviously missing something here.  Basically, the first quest of my mod-in-progress has the main character buying a birthday present for his little sister (how everything spirals out of control from that innocuous event is the gist of the whole story). 

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
Mengtzu

Mengtzu
  • Members
  • 258 messages
Your module script may not receive the event. You could try making a script for the item itself.

#3
DavidSims

DavidSims
  • BioWare Employees
  • 196 messages
What script is on the player?



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.

#4
cstanish

cstanish
  • Members
  • 90 messages
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.

#5
DavidSims

DavidSims
  • BioWare Employees
  • 196 messages

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.

#6
cstanish

cstanish
  • Members
  • 90 messages
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.

#7
Craig Graff

Craig Graff
  • Members
  • 608 messages
Is your module an addin? If so, is your module script passing through to module core? It sounds like you have some funky behavior going on. Addin module scripts should never pass through to module_core.

Modifié par Craig Graff, 06 janvier 2010 - 08:28 .


#8
DavidSims

DavidSims
  • BioWare Employees
  • 196 messages

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.

#9
Sunjammer

Sunjammer
  • Members
  • 925 messages
Have you set the Script property on your Plot to point to a script?  If you haven't then you need to remove the second TRUE from the WR_SetPlotFlag call.

Modifié par Sunjammer, 06 janvier 2010 - 08:45 .


#10
Craig Graff

Craig Graff
  • Members
  • 608 messages
Well, you shouldn't *have* to since it should just run the default plot_core script, which doesn't really do a whole lot, but it would be slightly more efficient.

As David suggested, it would be a good idea to use logging to check if the relevant bit of code is firing.

social.bioware.com/wiki/datoolset/index.php/Logging

Basically, enable logging in your ECLog.ini file and then make your code something like this:
[dascript]
      case EVENT_TYPE_CAMPAIGN_ITEM_ACQUIRED:
      {
            object oItem = GetEventObject(ev,0);
            PrintToLog("EVENT_TYPE_CAMPAIGN_ITEM_ACQUIRED, tag of oItem: " + GetTag(oItem));
            if (GetTag(oItem) == "sod_book")
            {                                   
                PrintToLog("plot flag should be set");
                WR_SetPlotFlag(PLT_SOD_GIFT_PLOT, GIFT_OBTAINED, TRUE,TRUE);
            }

            break;
      }
[/dascript]

Modifié par Craig Graff, 06 janvier 2010 - 08:58 .


#11
cstanish

cstanish
  • Members
  • 90 messages

Craig Graff wrote...

Is your module an addin? If so, is your module script passing through to module core? It sounds like you have some funky behavior going on. Addin module scripts should never pass through to module_core.


It's a standalone module, so as of now I do have it passing unhandled events to module_core from the main module script. 

I won't have a chance to try all the suggestions here until after I get back from work tonight; thanks for all the suggestions and I will be reporting back.

#12
cstanish

cstanish
  • Members
  • 90 messages
OK I had a few extra minutes this morning.



-the Script option in the variables for the Plot resource is set to None. I removed the second TRUE from WR_Set_Plot_Flag call, and there was no change.



-I placed another copy of the item in a nearby container, and it made no difference whether I took it from there or got it from the merchant.



-There is no ECLog.ini file in my Program Files\\Dragon Age\\bin-ship folder. And according windows Search, it doesn't exist on my computer at all.

#13
cstanish

cstanish
  • Members
  • 90 messages
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.

#14
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
Wouldn't a defined flag/condition work better for this?

#15
cstanish

cstanish
  • Members
  • 90 messages
If you're asking me, I'd have to say "I don't know" because I'm a noob. But I'm going to look into that.

#16
Sunjammer

Sunjammer
  • Members
  • 925 messages
This is one of the things I got wrong in LRRHR.

If it is a plot item then a main flag would do. If it is an normal item that you can dispose of then a defined flag would be better. Of course you can't set a defined flag so you'd have to get the value based on IsObjectValid(GetItemPossessedBy(...)).

Modifié par Sunjammer, 06 janvier 2010 - 04:04 .


#17
DavidSims

DavidSims
  • BioWare Employees
  • 196 messages
One disadvantage of using a defined flag in this case is you can't update the journal when the player picks up the item, assuming you want a journal at all. For quest items, I like to give feedback when the player picks the item up, because they may not realize what it's for otherwise.

#18
cstanish

cstanish
  • Members
  • 90 messages

Sunjammer wrote...

This is one of the things I got wrong in LRRHR.

If it is a plot item then a main flag would do. If it is an normal item that you can dispose of then a defined flag would be better. Of course you can't set a defined flag so you'd have to get the value based on IsObjectValid(GetItemPossessedBy(...)).


Actually I was looking at those very scripts (btw, thanks for distributing the B2B packages on those, I've learned a lot by studying them) but I didn't have any luck using that method either.

#19
cstanish

cstanish
  • Members
  • 90 messages

DavidSims wrote...

One disadvantage of using a defined flag in this case is you can't update the journal when the player picks up the item, assuming you want a journal at all. For quest items, I like to give feedback when the player picks the item up, because they may not realize what it's for otherwise.


And that's the issue for me right there.  If I didn't want a journal update for this, I wouldn't even necessarily need this particular plot flag, but since I do, I need to work out why it's not happening. 

It's amazing how much I swing between feeling like I'm making progress in learning this stuff and feeling like I'm in way over my head.

#20
DavidSims

DavidSims
  • BioWare Employees
  • 196 messages

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.

#21
cstanish

cstanish
  • Members
  • 90 messages
Hello again. I hadn't had much time to work on this recently, but I got back into it today and this is what I've found. I am definitely getting log messages, I put one in my "EVENT_MODULE_START" section right after the SetName command to say "Name is Set" and it appears in the log.



I'm going to place some in player_core as suggested, so let's see what happens.



I also noticed that in the logs, there are a number of GET PLOT and SET PLOT lines. Some of them reference generic plot resources (like the one I use for opening a merchant's shop) but my custom plot's name never actually appears in the log. There's a number of them that have GET PLOT or SET PLOT followed by 32 characters' worth of hexadecimal code. Is that what it's supposed to look like?

#22
cstanish

cstanish
  • Members
  • 90 messages
Also, I presume my local copy of player_core is going to go in ModuleID\\Core\\Override?

#23
cstanish

cstanish
  • Members
  • 90 messages
No log messages from the player_core:

  int bSendCampaignEvent = GetLocalInt(oItem, ITEM_SEND_ACQUIRED_EVENT);
            if ( bSendCampaignEvent != 0 )
            {
                PrintToLog("Item Obtained Event Sent");
                SendEventCampaignItemAcquired(GetModule(), oItem, bProcessImmediate);

Nothing.

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


I can't seem to identify this inventory event that you say should be sent to the player when I get the item.  Unless you mean the one I copied above...

#24
hunharibo

hunharibo
  • Members
  • 126 messages
stupid question, but did you make sure your module's core script is set to your custom script instead of module_core?

#25
cstanish

cstanish
  • Members
  • 90 messages

hunharibo wrote...

stupid question, but did you make sure your module's core script is set to your custom script instead of module_core?


Yes, I did