Aller au contenu

Photo

Item Codex Entry


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

#1
darrenr22

darrenr22
  • Members
  • 138 messages
I have created a custom item (a ring). This item spawns in Bodahn's inventory and is intended to be an alternative to the best late game rings such as Lifegiver. Everything is working correctly thus far.

As an extra flourish, I wish to give this item a rather splendid legendary item codex entry.

Now, I understand that codex entries are a type of plot. What I do not understand is how to link the acquisition of an item with a plot. I assume I will need some form of script but being a newbie at this mod business I am looking for advice. Any assistance would be much appreciated.

#2
midnightgeek

midnightgeek
  • Members
  • 30 messages
I figured out how to do this by setting the item variable ITEM_SEND_ACQUIRED_EVENT to 1 and then handling the event EVENT_TYPE_CAMPAIGN_ITEM_ACQUIRED in the module script. You can then check for the item's tag and set the plot flag accordingly.



I am puzzled though by how the official campaign is handling this because while looking through module_core it appears to be only handling 3 types of items: Specialization books, Codex items (i.e. scrap of paper) and backpacks. But there is no code to handle the acquisition of unique items. I am determined to figure this out now, lol.

#3
mikemike37

mikemike37
  • Members
  • 669 messages
i know for sure that this isn't the *best* solution, but since im also a scripting noob, I can't tell you with confidence how to do the better way, but I can tell you what the better way is afterwards.

(guess this is what you get if you post a scripting question in the custom content subforum... youve only yourself to blame rly! ;) ) I am assuming you are extending the single player module from your description.



okay, firstly in your item, scroll down to variables and set ITEM_SEND_ACQUIRED_EVENT to 1. At this point, you will trigger the event CAMPAIGN_ITEM_ACQUIRED in sp_module_item_acq (and possibly another one based on the three letter item prefix). Simply copy the style used for all the other codex items to update your plot flag.



I think that will work. However, now I'll explain why that solution is bad: To use those scripts you would need to modify them, and doing so will immediately make your modification incompatible with any other mod that does the same. The alternative is to have your item have a custom script that catches the CAMPAIGN_ITEM_ACQUIRED event before it falls through to sp_module_item_acq and does that codex bit then lets the event fall through to the "normal" script. I am unsure of the complications this would cause and there may be a better way to do it.



lets hope somebody who knows what theyre talking about can help you ^^

#4
mikemike37

mikemike37
  • Members
  • 669 messages
@midnightgeek - ensure you have single player on in your hierarchy. you should then find the many item acquired scripts. They all begin with sp_module_item_acq and then fall through to the other ones based on the tag's first three letters (ex. "arl_thisitem" falls through to arlev_item_acquired)

#5
mikemike37

mikemike37
  • Members
  • 669 messages
(edit: double post sorry)

Modifié par mikemike37, 20 juin 2010 - 11:44 .


#6
midnightgeek

midnightgeek
  • Members
  • 30 messages
Aha!  I assumed the official campaign was using the "module_core" script when actually it's "sp_module" which in turn passes events to the other scripts.  It was easy to see the hierarchy once I opened up "sp_module".

As it turns out, the item tags are all hardcoded in "sp_module_item_acq" (Tsk tsk, devs :P)  so doing it my way would be the preferred method.  (Add code to handle the item acquired event in your module script)

Thanks, Mike! It would have taken me quite a while to figure that one out :D

#7
darrenr22

darrenr22
  • Members
  • 138 messages
If any moderator is reading this, would it be possible to move this topic to the scripting sub-forum?

Anyway, despite my very limited understanding of what is going on in scripts I have tried to combine a script from this thread with the one I am already using. I would rather not blunder around with the module script until I get some opinions so here is my no doubt error-ridden effort. If it is complete and utter nonsense do not be afraid to tell me :blink:, although an edited correct script to show me where I am going wrong would be much appreciated. This script is supposed to add an item ("Ring of Souls") to Bodahn's inventory and add a legendary item codex entry when the item is bought:

#include "wrappers_h"
#include "events_h"
#include "plt_ros_bodahn_plot"
#include "plt_ros_acquired_codex"

void main()
{
   if ( WR_GetPlotFlag( PLT_ROS_ACQUIRED_CODEX, ROS_ACQUIRED ) == TRUE ) return;

   event ev=GetCurrentEvent();
      if (GetEventType(ev)==EVENT_TYPE_CAMPAIGN_ITEM_ACQUIRED)
     {        
             object oItem=GetEventObject(ev,0);
             object oPC=GetEventCreator(ev);        
             if (GetTag(oItem)=="ring_of_souls")            
                  WR_SetPlotFlag(PLT_ROS_ACQUIRED_CODEX, ROS_ACQUIRED, TRUE);    
      }

  if ( WR_GetPlotFlag( PLT_ROS_BODAHN_PLOT, ROS_ITEM_GIVEN ) == TRUE ) return;

  object oStore = GetObjectByTag("store_camp_bodahn");

  if (IsObjectValid(oStore)) 
  {    
      CreateItemOnObject(R"ring_of_souls.uti", oStore, 1, "", TRUE);

      WR_SetPlotFlag( PLT_ROS_BODAHN_PLOT, ROS_ITEM_GIVEN, TRUE );  
   }
}        
                   //---SCRIPT END---

Modifié par darrenr22, 20 juin 2010 - 02:16 .


#8
darrenr22

darrenr22
  • Members
  • 138 messages
Hmmm.... when I try to save this script I get an error relating to wrappers_h, there there is no main or StartingConditional.