Aller au contenu

Photo

Tutorial: Usable campaign items


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

#1
Proleric

Proleric
  • Members
  • 2 361 messages
I posted a tutorial on how to make a usable item (such as a sword or a helmet) that is also vital to the plot.

This includes post-processing a merchant, which may be of wider interest, as there's no specific event for this.

The problem with regular Plot items is that they're really just tokens that can't be used for anything else.

As always, this is just my best shot - happy to learn if there's a better way.

#2
TimelordDC

TimelordDC
  • Members
  • 923 messages
You probably want to set the Droppable to FALSE too (and check if that prevents selling)



One possible alternative to restore the items is to track the UI changes through EVENT_TYPE_GAMEMODE_CHANGE (rather than relying on the next AI update) - I think the store panels fall under GM_GUI.

Using the same logic, if you are handling EVENT_TYPE_GAMEMODE_CHANGE to track when a store was opened, you could try setting the Item Object as Plot (SetPlot) and see if that prevents selling.



The other options you will have to keep in mind is to check if a follower being fired has the plot item equipped and either notify the player or move it to the shared inventory space automatically.

#3
Proleric

Proleric
  • Members
  • 2 361 messages

TimelordDC wrote...

You probably want to set the Droppable to FALSE too (and check if that prevents selling)

One possible alternative to restore the items is to track the UI changes through EVENT_TYPE_GAMEMODE_CHANGE (rather than relying on the next AI update) - I think the store panels fall under GM_GUI.
Using the same logic, if you are handling EVENT_TYPE_GAMEMODE_CHANGE to track when a store was opened, you could try setting the Item Object as Plot (SetPlot) and see if that prevents selling.

The other options you will have to keep in mind is to check if a follower being fired has the plot item equipped and either notify the player or move it to the shared inventory space automatically.

Good suggestions. I already looked at some of them.

Droppable=FALSE doesn't seem to affect anything except treasure drops for dead enemies.

Surprisingly, the GAMEMODE_CHANGE and GUI_OPENED events don't fire when a store closes. Monitoring the module, the player and the store, I found that no event fires at that time. The navbar and army control GUIs open immediately after the store GUI, so if you restore the items then, they are available for sale.

The plot flag is wierd. If set before the player acquires the item, it prevents selling, but it also prevents use. If set after acquisition, GetPlot says it is set, but the GUI doesn't treat the item as plot until an inventory event occurs on it. So, you can still sell the item, but you can't buy it back.

That's why I ended up using the next AI update as the trigger for restoring the items. Not very elegant, but it works.

I'll add your follower point - good catch.