Author Topic: OnDeath script...  (Read 805 times)

Legacy_keyofrassilon

  • Jr. Member
  • **
  • Posts: 92
  • Karma: +0/-0
OnDeath script...
« on: January 24, 2011, 05:54:50 pm »


               First question is are zombies supposed to gib? explode completely? I have seen other creatures do this and was wondering how to make zombies do this? I figured by commenting out all but the EffectDeath code would cause them to explode every time when they die... but in the game it does nothing... Just leaves a corpse that fades if NoPermDeath is not checked and remains if it is checked... Heres the modified script I am testing...


//:://////////////////////////////////////////////////
//:: NW_C2_DEFAULT7
/*
  Default OnDeath event handler for NPCs.

  Adjusts killer's alignment if appropriate and
  alerts allies to our death.
 */
//:://////////////////////////////////////////////////
//:: Copyright (c) 2002 Floodgate Entertainment
//:: Created By: Naomi Novik
//:: Created On: 12/22/2002
//:://////////////////////////////////////////////////

#include "x2_inc_compon"
#include "x0_i0_spawncond"

void main()
{
    int nclass = GetLevelByclass(class_TYPE_COMMONER);
    int nAlign = GetAlignmentGoodEvil(OBJECT_SELF);
    object oKiller = GetLastKiller();
    string sTag     = GetTag(OBJECT_SELF);
    float fHP       = IntToFloat(GetCurrentHitPoints());
    float fMaxHP    = IntToFloat(GetMaxHitPoints());

    // Gib target if massive damage is caused
    //if (fHP < fMaxHP - (fMaxHP * 4.00)){
        ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDeath(TRUE, FALSE), OBJECT_SELF);
    //}
    // Otherwise leave a corpse
    /*else {
        // Prevent corpse fading.
        SetIsDestroyable(FALSE, FALSE, FALSE);

        // Create a corpse dummy.
        object oCorpse      = CreateObject(OBJECT_TYPE_PLACEABLE, "prop_corpse", GetLocation(OBJECT_SELF), FALSE, sTag);
        object oGib         = CreateObject(OBJECT_TYPE_PLACEABLE, "prop_holder", GetLocation(OBJECT_SELF));
        SetLocalObject(OBJECT_SELF, "gib", oGib);
        DestroyObject(oCorpse, 300.0);
        DestroyObject(oGib, 300.0);
    }*/

    // If we're a good/neutral commoner,
    // adjust the killer's alignment evil
    if(nclass > 0 && (nAlign == ALIGNMENT_GOOD || nAlign == ALIGNMENT_NEUTRAL))
    {
        AdjustAlignment(oKiller, ALIGNMENT_EVIL, 5);
    }

    // Call to allies to let them know we're dead
    SpeakString("NW_I_AM_DEAD", TALKVOLUME_SILENT_TALK);

    //Shout Attack my target, only works with the On Spawn In setup
    SpeakString("NW_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK);

    // NOTE: the OnDeath user-defined event does not
    // trigger reliably and should probably be removed
    if(GetSpawnInCondition(NW_FLAG_DEATH_EVENT))
    {
         SignalEvent(OBJECT_SELF, EventUserDefined(1007));
    }
    craft_drop_items(oKiller);


}

As you can see I commented out the check for critical hit to make it happen each time it died... I was able to change the blood color using appearence.2da that I extracted from cep2 top v23 hak file and placed it in my own but I dont see how that would cause gibbing to break for zombies... In fact I dont think I have ever seen zombies explode in the game ever... so is this impossible?
               
               

               
            

Legacy_keyofrassilon

  • Jr. Member
  • **
  • Posts: 92
  • Karma: +0/-0
OnDeath script...
« Reply #1 on: January 24, 2011, 08:54:10 pm »


               I take it no ones tried messing with this then? No matter what I choose any monster I cannot seem to force them to gib so I take it its hardcoded and therefore impossible to script... I google for this and come up with absolutely nothing... I did find how to change monster blood color but that was it... So theres my answer it cant be done...
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
OnDeath script...
« Reply #2 on: January 24, 2011, 09:41:26 pm »


               

keyofrassilon wrote...

I take it no ones tried messing with this then?

Its a few hours there, what did you expected?

Well I think that to ensure that npc always explode, you must first ressurect her and then apply EffectDeath(TRUE).

No code from me though, gn ':wizard:'
               
               

               
            

Legacy_keyofrassilon

  • Jr. Member
  • **
  • Posts: 92
  • Karma: +0/-0
OnDeath script...
« Reply #3 on: January 24, 2011, 09:52:13 pm »


               Oh I ment in general it seemed no one asked this question when i searched google...

Ok Ill give that a shot...  Or if anyone knows where I could find a script for this already done that would help too...



Just seems like this should be a simple task...
               
               

               
            

Legacy_keyofrassilon

  • Jr. Member
  • **
  • Posts: 92
  • Karma: +0/-0
OnDeath script...
« Reply #4 on: January 24, 2011, 10:43:31 pm »


               Ha I figured it out! visual effects was what i was missing...



Heres the working code:



   SetIsDestroyable(FALSE);

   effect eDeath = EffectDeath(TRUE,FALSE);

   effect eLink = EffectLinkEffects(EffectVisualEffect(VFX_COM_CHUNK_RED_MEDIUM),eDeath);

   SetPlotFlag(OBJECT_SELF,FALSE);



   DelayCommand( 1.0, SetIsDestroyable(TRUE));

   DelayCommand( 1.0, ApplyEffectToObject(DURATION_TYPE_INSTANT,eLink,OBJECT_SELF,5.0));

   DestroyObject( OBJECT_SELF, 5.0);
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
OnDeath script...
« Reply #5 on: January 24, 2011, 10:58:26 pm »


               I am not even sure why someone added the Effect death to the script there. When the Effect is applied to them they are already dead after all. As far as having any kind of effect on an undead, yould have to be able to effect them with death magic first. here is what the lexicon says about the EffectDeath.

EffectDeath() can easily be countered by Immunity: Death Spells, which is what the immunity protects against. It is only considered easy from what is in the NwN pallet, and the fact that (even in D&D) many undead and constructs will be unaffected too.


               
               

               


                     Modifié par Lightfoot8, 24 janvier 2011 - 10:59 .
                     
                  


            

Legacy_zero-feeling

  • Sr. Member
  • ****
  • Posts: 287
  • Karma: +0/-0
OnDeath script...
« Reply #6 on: January 25, 2011, 08:33:48 pm »


               zombies only explode when hit with a critical hit, make them have a crit hit on the last blow a player makes might be an idea to work with.



zero
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
OnDeath script...
« Reply #7 on: January 25, 2011, 08:43:02 pm »


               

zero-feeling wrote...

zombies only explode when hit with a critical hit, make them have a crit hit on the last blow a player makes might be an idea to work with.

zero

 Good Idea,  But since that part of the combat system is hard coded.  Im at a loss as to how that would be done.  Unless of cource nwnx has a function for it.
               
               

               
            

Legacy_zero-feeling

  • Sr. Member
  • ****
  • Posts: 287
  • Karma: +0/-0
OnDeath script...
« Reply #8 on: January 26, 2011, 08:23:31 am »


               could they possibly be exploded pre-death? i know theres a VFX to make bones and blood fly out, could that be used on death, then just make it not leave a corpse?

zero