- For the purposes of this example, we will get the player to collect bodies, and with each one she collects, the plot is updated
- Because this is a test area, the prefix for resources will be “tst”
- Use three digits when numbering the subset of areas (for enough variation should the plot grow in ways you never thought it would). I will start at “100,” so the naming convention will be:
o Where “xx” is the prefix of the resource type. For example:
- Placeables = ip
- Items = im
- Conversations = NA
- Creatures = cr
- Areas = ar
- Etc
2. NOTE: This sends an event to the module’s script (in most cases, this is module_core)
3. NOTE: Instead of modifying Core resources, I made a duplicate copy specifically for my module (called “cc_module_core”)
4. Next, get all your resources together. Again, instead of modifying Core resources, find the one you want to use, Right Click, select Duplicate, set BOTH the Module AND the Owner Module to your module (in my case, “Test_Mod”)
5. Resources required for this test include:
a. Area (make any area you want, in my case, it was named “tst100ar_test_area”)
i. Area needs a starting waypoint
b. Placeables containing the item (in my case, “tst100ip_knight_corpse”)
c. Item (in my case, “tst100im_body”)
d. Plot file with main flags: (in my case, the plot file is named "tst100pt_bodies")
i. FIRST_BODY_FOUND
ii. SECOND_BODY_FOUND
iii. THIRD_BODY_FOUND
e. Constants file (in my case, named “tst_constants_h”)
i. The only constant in this file so far is:
//--------------------------------------------------------------------------------
// ITEMS
//--------------------------------------------------------------------------------
const string TST_IM_BODY = "tst100im_body";
----------------------------------------------------------------------------------
f. Module Script
i. As mentioned above, I made a duplicate copy of module_core with these modifications:
// Section: Includes before the “void main()”
#include "tst_constants_h"
#include "plt_tst100pt_bodies"
// Section: “case EVENT_TYPE_CAMPAIGN_ITEM_ACQUIRED:”
// After the “if” statement for the “gen_im_misc_backpack” item, insert:
if (GetTag(oItem) == TST_IM_BODY)
{
if (!WR_GetPlotFlag(PLT_TST100PT_BODIES, FIRST_BODY_FOUND))
{
WR_SetPlotFlag(PLT_TST100PT_BODIES, FIRST_BODY_FOUND, TRUE);
}
else if (!WR_GetPlotFlag(PLT_TST100PT_BODIES, SECOND_BODY_FOUND))
{
WR_SetPlotFlag(PLT_TST100PT_BODIES, SECOND_BODY_FOUND, TRUE);
}
else if (!WR_GetPlotFlag(PLT_TST100PT_BODIES, THIRD_BODY_FOUND))
{
WR_SetPlotFlag(PLT_TST100PT_BODIES, THIRD_BODY_FOUND, TRUE);
}
}
g. Explanation -- This code is saying:
i. If the item sending the SEND ITEM ACQUIRED EVENT is “TST_IM_BODY” (as specified in the tst_constants_h script), execute this code.
ii. If the plot flag FIRST_BODY_FOUND in the “tst100pt_bodies” plot file is not set, then set it.
iii. Else if the plot flag SECOND_BODY_FOUND in the “tst100pt_bodies” plot file is not set, then set it.
iv. Else if the plot flag THIRD_BODY_FOUND in the “tst100pt_bodies” plot file is not set, then set it.
6. Links
a. Go to File, Manage Modules, select your module name, then click on Properties, and set the script field to your custom module core (in my case, this was “cc_module_core”). If you can’t find the script, just type in the name in the Name field and click on Ok. Select your test area and waypoint in the “Starting Area” and “Starting Waypoint” fields, then click on Ok, and then close the Manage Modules window.
b. Placeable’s inventory contains the item
i. Item has the ITEM_SEND_ACQUIRED_EVENT to 1
c. Place the placeables in your area
d. Export with Dependant Resources for the following:
i. Area
ii. Each script
7. Load you module and try it out!
Note: Best practice is making your own constants file, so that if any items change (IE you’re using a chest placeable instead of a body), you can change it in the constants file once instead of having to track down and change the tag reference in multiple scripts. Initially, my cc_module_core was not picking up the item through the constants file because it was looking for a const string entry, not a const resource item, so the code in the constant file should read:
const string TST_IM_BODY = "tst100im_body";
· NOT
[color=red"· ]const resource TST_IM_BODY = R"tst100im_body.uti”;[/color]
[*](Please forgive the formatting)
Modifié par Deadmau5, 20 mars 2010 - 11:07 .





Retour en haut






