Creating item with note in Codex
Author: dr. dummie, Sunjammer Module UID: lpt Folder of all my resourses: z_lpt
This tutorial:
- Allows you to create book, that add new note in Codex.
- You can create another item with Codex note and even more than one.
Book with Codex
this quick version is if you in example find some book in your area and want to give player some information about it (well - codex)
1 - create examinable item on your level (area) like book (gen_ip_book or similar in core resources)..
2 - create new plot (like "lpt_codex_my_book") and add main flag like MY_CODEX _BOOK (it really could be anything here, just make it meaningful).
3 - under journal part of plot create text which you want to be displayed in codex..
4 - under properties of plot look for "entry type" and select in example: codex - books & songs (search if i write it wrong)
5 - select your item from level (area) and choose Variable_2da under it's properties
6 - under PLC_CODEX_FLAG insert NUMBER of your flag (in this case it's 0 - coz it's only one flag inside)
7 - under PLC_CODEX_PLOT insert NAME OF YOUR PLOT (lpt_codex_my_book)
now when you examine book in game, new codex entry will be added and displayed..
Another item
rest is relatively simple, so like before:
1 - create your item (in example "lpt_awesome_sword")
2 - create plot file with same ("lpt_awesome_sword") and set it to be codex plot with main flag of your wish (ie. SWORD_ACQUIRED - remember number of flag! it is 0 in this case coz it's first and only one in your plot), and wished journal entry ("You got the Awesome sword!")..
3 - in VARIABLES section of your item (lpt_awesome_sword) set ITEM_SEND_ACQIURED_EVENT to 1
4 - in VARIABLES section of your item (lpt_awesome_sword) set ITEM_CODEX_FLAG to number of your MAIN FLAG for your plot (in this case it's 0 coz it's only one codex entry for this item))
you need to add following section to your module script, this is another "case" statment for module script, and you need to add it like other module events:
//other module events like "module load"..
//we use this to know when we get some important items for campaign
case EVENT_TYPE_CAMPAIGN_ITEM_ACQUIRED: { object oAcquirer = GetEventCreator(ev); object oItem = GetEventObject(ev, 0); string sItem = GetTag(oItem); // Make item indestructible - maybe for plot items SetItemIndestructible(oItem, TRUE); //little debug what item we get //DisplayFloatyMessage(GetHero(), sItem, FLOATY_MESSAGE, 16777215, 20.0); // Set plot flags if required (sItem tells us which item has been acquired) //WR_SetPlotFlag(GetTag(oItem), nCodexItem, TRUE, TRUE); //set codex plot - for this to work "item" must have plot file //with same name, in variables section of item 2 variables must be set: //ITEM_SEND_ACQUIRED_EVENT to 1 and ITEM_CODEX_FLAG to NUMBER of //main flag in your plot file, plot entry type must be set to some codex type int nCodexItem = GetLocalInt(oItem, ITEM_CODEX_FLAG); if (nCodexItem > -1 && IsFollower(oAcquirer)) { //we disabled things that we dont need, we dont want to destroy //our new items, right? //some tutorial plot - i guess we dont need it.. //WR_SetPlotFlag(PLT_TUT_CODEX_ITEM, TUT_CODEX_ITEM, TRUE); //set codex plot WR_SetPlotFlag(GetTag(oItem), nCodexItem, TRUE, TRUE); //normally this would be destroyed as codex item //WR_DestroyObject(oItem); } PrintToLog("------> MODULE CAMPAIGN ITEM ACQUIRED: " + sItem ); //we dont want to let main script handle it cause it would destroy item nEventHandled = TRUE; break; } // add more items // else if (sTag == "cod_item_bloodofval") //{ // WR_SetPlotFlag(PLT_COD_ITEM_BLOODOFVAL, COD_ITEM_BLOODOFVAL, TRUE); //} // end //How it has to look like case EVENT_TYPE_CAMPAIGN_ITEM_ACQUIRED: { object oAcquirer = GetEventCreator(ev); object oItem = GetEventObject(ev, 0); string sTag = GetTag(oItem); if(IsFollower(oAcquirer)) { if(sTag == "cod_item_bldval") { WR_SetPlotFlag(PLT_COD_ITEM_BLDVAL, COD_ITEM_BLDVAL, TRUE, TRUE); } else if(sTag == "somethingelse") { WR_Set... } else if(sTag == "yetandotherthing") { WR_Set... } } break; }