Author Topic: Buff rod help please  (Read 403 times)

Legacy_Guppy01232

  • Newbie
  • *
  • Posts: 28
  • Karma: +0/-0
Buff rod help please
« on: January 10, 2014, 11:10:11 am »


               Don't suppose anyone has a buff rod script / erf or can point someone with limited scripting knowledge in the direction of one and how to get it working on a module that does not have tag based scripting turned on?

(I know its much easier to do with  tag based turned on. The issue I have is the Persistant world I inherited, has been entirely made without tag based scripting on and its kinda huge.. 1.3Gig HAK of custom content thousands of individual scripts and areas, kinda make it impossible for me to turn tag based scripting on and then pick my way through the hundreds of lines of code for events in the module properties and rewrite them with tag based turned on.)
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Buff rod help please
« Reply #1 on: January 10, 2014, 03:01:04 pm »


               I dont have time to answer the question right now, But perhaps you should be asking another question. The Question should be. " How do I add Tag Based Scripting to an old module without things going haywire? "
               
               

               


                     Modifié par Lightfoot8, 10 janvier 2014 - 03:02 .
                     
                  


            

Legacy_ruadhri10

  • Jr. Member
  • **
  • Posts: 52
  • Karma: +0/-0
Buff rod help please
« Reply #2 on: January 10, 2014, 03:37:52 pm »


               The DMFI Rod of Buffing would do the trick, but without tag-based scripting you will need to add some code to your module's OnItemActivated script after you import the DMFI erfs.

   object oSpellItem = GetSpellCastItem();
   object oTarget = GetSpellTargetObject();
   location lLocal = GetSpellTargetLocation();

   if (GetStringLeft(GetTag(oSpellItem), 5) == "dmfi_" ||
   GetStringLeft(GetTag(oSpellItem), 8) == "hlslang_")
   {
       SetLocalObject(OBJECT_SELF, "dmfi_item", oItem);
       SetLocalObject(OBJECT_SELF, "dmfi_target", oTarget);
       SetLocalLocation(OBJECT_SELF, "dmfi_location", lLocal);
       ExecuteScript("dmfi_activate", OBJECT_SELF);
       return;
   }

Have a look at the DMFI documentation, but I'm pretty confident this will do the trick out of the box :-)
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Buff rod help please
« Reply #3 on: January 11, 2014, 07:56:26 pm »


               

ruadhri10 wrote...

The DMFI Rod of Buffing would do the trick, but without tag-based scripting you will need to add some code to your module's OnItemActivated script after you import the DMFI erfs.

   object oSpellItem = GetSpellCastItem();
   object oTarget = GetSpellTargetObject();
   location lLocal = GetSpellTargetLocation();

   if (GetStringLeft(GetTag(oSpellItem), 5) == "dmfi_" ||
   GetStringLeft(GetTag(oSpellItem), 8) == "hlslang_")
   {
       SetLocalObject(OBJECT_SELF, "dmfi_item", oItem);
       SetLocalObject(OBJECT_SELF, "dmfi_target", oTarget);
       SetLocalLocation(OBJECT_SELF, "dmfi_location", lLocal);
       ExecuteScript("dmfi_activate", OBJECT_SELF);
       return;
   }

Have a look at the DMFI documentation, but I'm pretty confident this will do the trick out of the box :-)


DMFI does not use TBS for the rod and you should not have to set any of that up in the OnItemActvated script.   It is all taken care of in NW_S3_ActItem01.   It  is ran before the Item Actavated script therefore it is already tacken care of. 
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Buff rod help please
« Reply #4 on: January 11, 2014, 10:00:00 pm »


               Adding Tab Based Scripting (TBS) to an old module 


You can add TBS to a module that uses the old system by adding a unique prefix to all of your Tag based scripts.  This way you can run both the old system your module is using and TBS at the same time and not have it mess anything up.  

The first thing you will need to do is set up the prefix for your tag based scripts in the OnModuleLoad  event.  

   Open up the script and make sure that x2_inc_switches is included,  in older modules it may not be.If it is not add the line 

   #include "x2_inc_switches" 

  Before the void main. 

  Then add the two line 

  SetUserDefinedItemEventPrefix("tb_");
  SetModuleSwitch( MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS,TRUE);

  after the void main() {
  tb_  is just what I decided to use as a prefix, You can use something else if you like.   

Second open up your OnItemActavated script.    
  
  Again you will need to make sure that you have x2_inc_switches included at the top with the 
  #include "x2_inc_switches"
  line. 

  After the
  void main() {
  you will want to add

  
     object oItem = GetItemActivated();  

  // * Generic Item Script Execution Code
  // * If MODULE_SWITCH_EXECUTE_TAGBASED_SCRIPTS is set to TRUE on the module,
  // * it will execute a script that has the same name as the item's tag
  // * inside this script you can manage scripts for all events by checking against
  // * GetUserDefinedItemEventNumber(). See x2_it_example.nss
  if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
  {
    SetUserDefinedItemEventNumber(X2_ITEM_EVENT_ACTIVATE);
    int nRet =   ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
    if (nRet == X2_EXECUTE_SCRIPT_END)
    {
       return;
    }

 }


  oItem may already be defined in your script,   If it is just leave that line out and add the rest of the code after that line.   


You now have TBS set up in your module for the onactivate event.     The only thing now is getting the scripts to work for the event.    Anytime an item is now activated the Activate event is now checking to see if there is a script named with the tag of the item and the prefix tb_.

so an item with the tag  "sword"  will run the script named  "tb_sword"   if it exsists.     

So when ever you install someones TBS item into your module just rename the scripts given with the item to have a tb_ prefix  and you are good to go.   



I have to run right now.   Let me know if you need help in getting the other events to work with TBS also. 
               
               

               
            

Legacy_Guppy01232

  • Newbie
  • *
  • Posts: 28
  • Karma: +0/-0
Buff rod help please
« Reply #5 on: January 13, 2014, 09:33:49 am »


               You sir, are a star!

I shall try and get this working asap and see if it causes any issues!

Seriously ive spent the past 5 years wanting a fix for this. Clear concise exactly how to do it for someone with very limited scripting knowledge. Thankyou
               
               

               


                     Modifié par Guppy01232, 13 janvier 2014 - 11:15 .
                     
                  


            

Legacy_Guppy01232

  • Newbie
  • *
  • Posts: 28
  • Karma: +0/-0
Buff rod help please
« Reply #6 on: January 14, 2014, 08:55:08 am »


               It works!! I am like a kid in a candy store!!

All those scripts on the vault I used to look at and sigh when I saw the  "requirements : tag based scripting turned on" im comming to get you!!!

Thankyou so much for your clear concise script with perfect instructions on how to use, and understanding my onload and other mod scripts would be hundreds of lines long and explaining exactly where and what to slot in amongst them!!

If you are feeling particulary generous my next big thing is trying to introduce mounts to the module. I looked at an faq but it simply went on about changing the onclient enter and onmodule load stuff to standard bioware scripts, which I cant do as the cusom scripts contain hundreds of lines of things from the module.

I tried loading up the bioware scripts in a new module and then cut paste them into the jumble of script of my module but with no success. (I couldnt get the mount raidal within my mod)

More worryingly just to test I followed the faq and used the x3_ scripts for horses in on_load and on_enter from bioware and deleted the custom scripts I had in their place. When it came to compiling the scripts it found an error withing the include horse file. Saying something about Getobject tail not been defined....---Does this mean something has been added to the module that will mean horses wont ever work??

(sorry to go offtrack from original post but I thought I may aswell throw the question out their as my other question was answered so well)

Many thanks
               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Buff rod help please
« Reply #7 on: January 14, 2014, 03:56:53 pm »


               I made a tutorial for the Lexicon. If you take the Existing Modules section step-by-step, you should be fine, but I'm sure we can help if you run into specific issues.
               
               

               
            

Legacy_Guppy01232

  • Newbie
  • *
  • Posts: 28
  • Karma: +0/-0
Buff rod help please
« Reply #8 on: January 15, 2014, 09:32:40 am »


               Your guide is the one I used to try and implement horses however as brilliant and detailed as this guide is I failed at using it from the very beginning the issues being :

You describe first setting the following scripts to biowares standard ones

OnModuleLoad to X3_mode_def_load
OnClient_enter to X3_mod_def_enter
OnHeartbeat to X3_mod_def_hb

The issue I find is as this Persistent world has been added to since day 1 of NWN the above events have custom scripts controlling other parts of the world in them. These arent small scripts we are talking 1000+ lines of code so I simply cannot replace them with standard bioware scripts.

I am not very au fait with scipting in NWN however I did simply try copying the code from the above bioware scripts, putting any #include lines at the top of the custom script and the remaining code inside the void Main ()..but to no joy.

Just as a test I replaced the modules custom scripts as you described above with the X3_scripts just to see if I could get the mount horse from the raidal menu of a new character created within the module. However this is where I encountered a worrying error that has me wondering is something has been changed within the module that makes it impossible to include mounts.

Doing the above when I try and compile the scripts with the line #include "x3_inc_horse" at the start of them a seperate tab is brought up with the x3_inc_horse script in and an error occurs saying something about creature tail not defined (sorry not got module infront of me to check exactly atm) but this is with the original Bioware x3_inc_horse script.....

Any ideas?