Author Topic: Default X2 tag based scripting ... ???  (Read 827 times)

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
Default X2 tag based scripting ... ???
« on: July 28, 2010, 09:04:33 pm »


               So, I have used tag based scripts for quite a while but now im doing a tag based 'On Hit: Unique Power' script...
Lets get to the point:

Stripped down x2_mod_def_act (OnActivate script)

#include "x2_inc_switches"
void main()
{
     object oItem = GetItemActivated();
     object oPC   = GetItemActivator();

    [b]SetUserDefinedItemEventNumber(X2_ITEM_EVENT_ACTIVATE);[/b]
    int nRet =   ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
    if (nRet == X2_EXECUTE_SCRIPT_END)
    {
        return;
    }
}

Just an example. You see that the user defined event -whatever, is set here, in the module scripts.


This is the 'On Hit: UP' part of the default X2 tag based script template.

    if (nEvent ==[b]X2_ITEM_EVENT_ONHITCAST[/b])
    {
        oItem  =  GetSpellCastItem();
        oPC = OBJECT_SELF;
        object oTarget = GetSpellTargetObject();
    }

What the hell?
There is no module event for On Hit! There is no module script that will set the user event to this!
How will this bit of the script ever fire??
               
               

               


                     Modifié par Xardex, 28 juillet 2010 - 08:05 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Default X2 tag based scripting ... ???
« Reply #1 on: July 28, 2010, 09:27:43 pm »


               When you get a successful hit this script is fired: "x2_s3_onhitcast"



I think that's what you were looking for?
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Default X2 tag based scripting ... ???
« Reply #2 on: July 28, 2010, 09:28:54 pm »


               x2_s3_onhitcast

bah GhostOfGod was first '<img'>
               
               

               


                     Modifié par ShaDoOoW, 28 juillet 2010 - 08:31 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Default X2 tag based scripting ... ???
« Reply #3 on: July 28, 2010, 10:38:21 pm »


               Funny thing with the way it works. Is about the same way as the OnActivate works.  OnAcitavate runs script. NW_S3_ActItem01  this script just runs the module event,  the module event then runs the tagbased script.  



With On Hit they  just just skiped the step of running a module event.  



               
               

               
            

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
Default X2 tag based scripting ... ???
« Reply #4 on: July 29, 2010, 08:13:24 am »


               Hidden module event?

Thats just evil...
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Default X2 tag based scripting ... ???
« Reply #5 on: July 29, 2010, 08:14:37 am »


               yea, spellhook is second hidden one
               
               

               
            

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
Default X2 tag based scripting ... ???
« Reply #6 on: July 29, 2010, 08:27:00 am »


               So... Is the hidden On Hit script ran on the PC?
Since the item script has this line...:
oPC = OBJECT_SELF;

               
               

               


                     Modifié par Xardex, 29 juillet 2010 - 07:28 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Default X2 tag based scripting ... ???
« Reply #7 on: July 29, 2010, 10:24:04 am »


               Yes, it is spell actually. OBJECT_SELF is always caster, actually not necessary PC if you allow onhit items to your npcs, but not recommended. GetSpellTargetObject then returns either target you just hit, in case of onhit is on the weapon, or npc that hits you, in case of onhit is on shield/armor. Also GetLastDamager works if its armor.
               
               

               
            

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
Default X2 tag based scripting ... ???
« Reply #8 on: July 29, 2010, 01:10:07 pm »


               Alright, thanks.