Page 1 of 1

Spookeh creatures

Posted: Tue Aug 26, 2003 5:55 pm
by Neve
Okay. Another funny thing I made lately. I hope it's usable to anyone. At least it's annoying as hell for wizards as it forces them to go in close combat =) A "ghostly" creature will attack as any other creature, but when it's damaged, it will disappear, and reappear behind the player who damaged it, with the correct amount of HP left. These creatures will only appear at night.

Create a new custom creature, preferrably a Spectre or Shadow, though it will work on every creature, and replace the following scripts :

OnDamaged :

Code: Select all

/*
    August 25, 2003 - Eric Ettes - Raiko - zeiren@hotmail.com
    This script creates a new ghost just behind the player who just damaged it
    Place this script in the OnDamaged slot
*/

location RearLocation(object oPC){
    float  fDistance    = 2.0;
    object oTarget      = (oPC);
    object oArea        = GetArea(oTarget);
    vector vPosition    = GetPosition(oTarget);
    vPosition.z        += 0.5;
    float  fOrientation = -GetFacing(oTarget);
    vector vNewPos      = AngleToVector(fOrientation);
    float  vZ           = vPosition.z;
    float  vX           = vPosition.x - fDistance * vNewPos.x;
    float  vY           = vPosition.y - fDistance * vNewPos.y;
    fOrientation        = -GetFacing(oTarget);
    vX                  = vPosition.x - fDistance * vNewPos.x;
    vY                  = vPosition.y - fDistance * vNewPos.y;
    vNewPos             = AngleToVector(fOrientation);
    vZ                  = vPosition.z;
    vNewPos             = Vector(vX, vY, vZ);

    return Location(oArea, vNewPos, fOrientation);
}

void main(){
    object NewGhost;
    object oAttacker = GetLastDamager();
    string GhostType = GetResRef(OBJECT_SELF);
    int NewHitPoints;

    if(!GetLocalInt(OBJECT_SELF, "Damaged")) SetLocalInt(OBJECT_SELF, "Damaged", 1);
    else{
        NewHitPoints = GetMaxHitPoints() - GetCurrentHitPoints();
        DestroyObject(OBJECT_SELF);
        NewGhost = CreateObject(OBJECT_TYPE_CREATURE, GhostType, RearLocation(oAttacker));
        ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(NewHitPoints), NewGhost);
        AssignCommand(NewGhost, ActionAttack(oAttacker));
    }
}
OnSpawn :

Code: Select all

/*
    August 25, 2003 - Eric Ettes - Raiko - zeiren@hotmail.com
    This script makes the creature spooky and sets a localint used for damage
    Place this script in the OnSpawn slot
*/

#include "NW_I0_GENERIC"

void main(){
    if(GetIsNight()){
        SetLocalInt(OBJECT_SELF, "Damaged", 1);
        ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), OBJECT_SELF);
        SetListeningPatterns();
        WalkWayPoints();
        return;
    }
    DestroyObject(OBJECT_SELF);
}

Posted: Tue Aug 26, 2003 6:04 pm
by Maelstrom
Why do you need to destroy the creature and create a new one? Can't you just move the creature?

Posted: Tue Aug 26, 2003 6:36 pm
by Drakuul
I would assume it's because if you destroy it and recreate it, all characters in combat have to retarget it - annoying as hell! I like it!

Posted: Tue Aug 26, 2003 7:10 pm
by Neve
Indeed, and you can only hit it once =) Moving the ghost would stop the ghost from attacking, and make it walk to another location while the player could keep bashing it. Aaand, the ghost wouldn't disappear, and promptly appear behind the player, which was the point of the script =) It would just move to another location as if it was walking/floating.

Imagine a wizard casting a fireball which destroys one ghost, but damages all other ghosts. All those damaged ghosts would instantly be in close combat with the wizard, and we all know how good wizards are in Close Combat :twisted:

Posted: Tue Aug 26, 2003 7:37 pm
by Maelstrom
I guess I was just thinkin' you could use the JumpToLocation function to produce the same effect without having to Destroy the existing creature and Create a new one. It seems to me that you would want to avoid those functions unless absolutely necessary because of the intensive nature of them. Dunno.

Posted: Tue Aug 26, 2003 7:39 pm
by Neve
Ahh gah. I didn't even think of using that function really :P

Posted: Tue Aug 26, 2003 9:02 pm
by maxinion
I imagine that you wouldn't have to click again, though, because you're still locked in the attack. Their location just moves. The spell won't be broken, the attacker will automatically turn around, etc.

Posted: Wed Aug 27, 2003 4:32 am
by Myk D'vor
Maxguy25 wrote:I imagine that you wouldn't have to click again, though, because you're still locked in the attack. Their location just moves. The spell won't be broken, the attacker will automatically turn around, etc.
unless you added a AssignCommand(oPC,ClearAllActions(TRUE)); to it...

Just clear the PCs actions, then have the critter jump behind them, they'll have to re-click (the TRUE above is to force the PC to break combat).

Myk D'Vor