Author Topic: Creature Skin - On Hit - Cast Spell(unique power)  (Read 978 times)

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Creature Skin - On Hit - Cast Spell(unique power)
« on: October 31, 2010, 08:42:20 pm »


               Hi Guys,
Im trying to get a script to fire when the player is hit by a physical attack, but im noticing that skin items dont seem to be firing their scripts on physical hits.

I have tag based scripting enabled.
My skin tag is called "vamp_hide", and it has the On Hit Cast Spell (unique power self).
so I have a script called "vamp_hide"

the content of the script is as follows...


#include "x2_inc_switches"
void main()
{
    WriteTimestampedLogEntry("SKIN TRIGGERED");
    int nEvent = GetUserDefinedItemEventNumber();    //Which event triggered this
    object oPC;                                                           //The player character using the item
    object oItem;                                                        //The item being used
    object oSpellOrigin;                                               //The origin of the spell
    object oSpellTarget;                                              //The target of the spell
    int iSpell;                                                             //The Spell ID number
    //Set the return value for the item event script
    // * X2_EXECUTE_SCRIPT_CONTINUE - continue calling script after executed script is done
    // * X2_EXECUTE_SCRIPT_END - end calling script after executed script is done
    int nResult = X2_EXECUTE_SCRIPT_END;
    switch (nEvent)
    {
        case X2_ITEM_EVENT_ONHITCAST:
            // * This code runs when the item has the 'OnHitCastSpell: Unique power' property
            // * and it hits a target(if it is a weapon) or is being hit (if it is a piece of armor)
            // * Note that this event fires for non PC creatures as well.
            oItem  =  GetSpellCastItem();               // The item triggering this spellscript
            oPC = OBJECT_SELF;                            // The player triggering it
            oSpellOrigin = OBJECT_SELF ;               // Where the spell came from
            oSpellTarget = GetSpellTargetObject();  // What the spell is aimed at
            SendMessageToPC(oPC,"Item:"+GetName(oItem)+",Player:"+GetName(oPC)+",SpellOrigin:"+GetName(oSpellOrigin)+",SpellTarget:"+GetName(oSpellTarget));
            //Your code goes here
            break;
    }
}

Basically, Im only seeing in my log files a 'Skin Triggered' event which is occuring for the 'on acquired' event of the item. But absolutely nothing is occuring when I get hit.


Am I using the right event here?
or is there something about skins that stop them from firing onhit events?
               
               

               


                     Modifié par Baaleos, 31 octobre 2010 - 08:42 .
                     
                  


            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Creature Skin - On Hit - Cast Spell(unique power)
« Reply #1 on: November 01, 2010, 01:20:49 am »


               I vaguely recall that the onhit needs to go on armor, and doesn't work on skins. Only about 80% sure of that.



Funky
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Creature Skin - On Hit - Cast Spell(unique power)
« Reply #2 on: November 01, 2010, 07:44:01 pm »


               

FunkySwerve wrote...

I vaguely recall that the onhit needs to go on armor, and doesn't work on skins. Only about 80% sure of that.

Funky

I can confirm that.

Im using armor for this with special rags that looks as naked char which I will equip if character unequip his armor.
               
               

               
            

Legacy_0100010

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Creature Skin - On Hit - Cast Spell(unique power)
« Reply #3 on: November 18, 2010, 07:26:30 am »


               I can confirm that your actually wrong.  SKin will receive OnHit event. It is how I set up a player struck event in HCR2.  However you do need to make sure you have properly set up proper row in iprp_onhitcastspell.2da and a corresponding row in spells.2da I am not routing the event through tag-based scripting.

In other news, I've also found a fix for the Skill check penalty bug when skins are equipped.
It only effects shiled, you just need to edit armorrulesets.2da and set the skillcheck penalty for all sheilds to 0, Leave the baseitem.2da sheild entries alone.  Only do this if you are using player skins.  I may need to test whether or not this adversely effects NPC who are not using skins.

EDIT:  Ok I just realized that this was scripting thread for NWN1, my above findings apply to NWN2 however, it might work for you guys as well.
               
               

               


                     Modifié par 0100010, 18 novembre 2010 - 07:28 .
                     
                  


            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Creature Skin - On Hit - Cast Spell(unique power)
« Reply #4 on: November 18, 2010, 08:11:08 am »


               Here's a thread explaining the actual operation in NWN1:

http://nwn.bioware.c...ight=onhit skin



I'm guessing the skills bug he mentions is NWN2 only, as I've never noticed any such thing. It's often the case that what's true in NWN1 is not in NWN2, and vice versa.



Funky