Writing a plugin can be frustrating sometimes, and not in the bad way always.
In this case, I planned enhancing the dropable object behaviour to be linked to the inventory, but it came out that the last modification for the plugin was just that but not fully.
The idea for this implementation was not to break anything and allow designers to enhance simmer experience.
So how the implementation works in v2.07 rc4 build:
When we define a <drop_object> element, we have a new attribute by the name: "barcode". If you ever defined an Inventory or Store you should know by now that a barcode is a unique identifier for an item.
Old mission will not fail if they are missing this attribute, since default value is "empty string", meaning, ignore this feature.
So now we have a dual set up, we have the "num_of_tries" attribute and the "barcode" attribute, while the "num_of_tries" is mandatory, the "barcode" is not. The idea is to keep backward compatibility with older implementation of this feature.
So what is new here ?
First: The plugin will evaluate first the "num_of_try" attribute. If it reaches Zero, then it will also evaluate the "barcode" attribute.
If it is not EMPTY, then it will test how many items in the plane inventory. Now here is the catch, If designer defined barcode string, but did not handle "onDrop" event (since v.207 rc3) then the inventory will always have the item in its stock, and it will always return true to the plugin.
Therefore, once you decided to implement barcode with "drop_object", you must also handle inventory event every drop of an item.
Here is an example:
The steps we need to construct so the simmer will have everything ready for the mission:
- Create a store that will hold the 3 items. Simmer can now acquire these items.
- Create drop_object element, define "3" for "num_of_tries" and barcode attribute.
- Add "onDrop" event under "drop_object" element, with inventory action that will decrease the number of items in the inventory.
<drop_object num_of_tries="3" barcode="bomb_150kg" file_name="xp_bomb_01.obj" file_name_on_ground="" radius_mt="130" fail_can_continue="0">
<target name="FishBoat1" />
<inv_action operation="remove" store_name="plane" item_name="Dumb Bomb" barcode="bomb_150kg" amount="1" weight_kg="150" />
To summarize the latest enhancements to the Mission-X v2.07 plugin, we have now the option to:
1. Handle event "onHitFailed" (since v2.07 rc2). Its drawback is that it does not handle multi target messages correctly in the same step, but works fine on one target per step.
2. Handle event "onDrop" (since v2.07 rc3). Allow the designer to mange inventory each time a simmer drops an object.
3. [v2.07 rc4] Allow plugin to be aware of item availability in inventory when it tests "fail_can_continue" option. It will ignore "num_of_tries" value if it reaches Zero as long as the item is in the inventory and "barcode" was set correctly.
Caveats: Designer must define "onHit" event with "inv_action" that will decrease the item no. every drop.
The drop_object element will continue to be evolved during the v2.1x phases, but for our current version and build this should be the last modification to the plugin.