Author Topic: Item Property On Hit Cast Spell Unique Power  (Read 431 times)

Legacy_EzRemake

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Item Property On Hit Cast Spell Unique Power
« on: November 18, 2014, 03:06:43 am »


               

I'm looking to use On Hit Cast Spell Unique Power because the default on hit cast spell system can be disastrous, but I'm having a hard time getting the appropriate tag based script to reference to PC properly.


 


I've tried using GetItemActivator as well as just referencing the last item activated and it's owner, but nothing seems to work.


 


If I drop a spell script in the tag based script, the spell effects run fine but the damage can't calculate because it can't make reference to anything.


 


Does anyone know how to make reference to the PC in this type of tag based scripting?



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Item Property On Hit Cast Spell Unique Power
« Reply #1 on: November 18, 2014, 03:22:41 am »


               

On Hit Cast Spell is not item activation. This runs more like a spell script so OBJECT_SELF is the caster. With Onhit that means the one wielding the weapon or wearing the armor (if the armor is what has the on hit cast property).  The target is retrieved with GetSpellTargetObject(). Take a look at x2_s3_onhitcast.nss.



               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Item Property On Hit Cast Spell Unique Power
« Reply #2 on: November 18, 2014, 04:01:30 am »


               

Save the following template  as a "text File"  in the  "scripttemplates"  folder in your  nwn install.   That way any time you need to reference how to get data for any of the events, all you have to do is click on the templates tab in the scripting window.  


 


It is a nice place to stash   crib sheets. 


 




#include "x2_inc_switches"




void main()
{
    object oPC;
    object oItem;
    int nEvent = GetUserDefinedItemEventNumber();
    switch (nEvent)
    {
        case X2_ITEM_EVENT_ACTIVATE:
            //oPC   = GetItemActivator();
            //oItem = GetItemActivated();
        break;


        case X2_ITEM_EVENT_EQUIP:
            //oPC = GetPCItemLastEquippedBy();
            //oItem = GetPCItemLastEquipped();
        break;


        case X2_ITEM_EVENT_UNEQUIP:
            //oPC    = GetPCItemLastUnequippedBy();
            //oItem  = GetPCItemLastUnequipped();
        break;


        case X2_ITEM_EVENT_ONHITCAST:
            //oItem  =  GetSpellCastItem();                  // The item casting triggering this spellscript
            //object oSpellOrigin = OBJECT_SELF ;
            //object oSpellTarget = GetSpellTargetObject();
            //oPC = OBJECT_SELF;
        break;


        case X2_ITEM_EVENT_ACQUIRE:
            //oPC = GetModuleItemAcquiredBy();
            //oItem  = GetModuleItemAcquired();
        break;


        case X2_ITEM_EVENT_UNACQUIRE:
            //oPC = GetModuleItemLostBy();
            //oItem  = GetModuleItemLost();
        break;


        case X2_ITEM_EVENT_SPELLCAST_AT:
            //oPC = GetLastSpellCaster();
            //oItem  = GetSpellTargetObject();
        break;


        default:
        break;
    }




}


               
               

               
            

Legacy_EzRemake

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Item Property On Hit Cast Spell Unique Power
« Reply #3 on: November 18, 2014, 04:06:47 am »


               

Thanks guys, I understand what I did wrong to get so confused, had some conflicts which prevented any tag based from activating >.>