Neverwinter Nights: Enhanced Edition

Neverwinter Nights: Enhanced Edition

Adventures await!
Gather your mods before venturing forth. Discover planes filled with player-created adventures in Steam Workshop, then build your own Neverwinter Nights modules using the Aurora Toolset to share!
Learn More
Demigodone 9 Apr, 2024 @ 7:58am
trying to scrip a a simple boss fight.
hello all. I'm trying to script a simple phase spider boss fight in my sewers in my mod im building. I'm trying to make it so when the boss drops to 50% hp he cast web on the players (no save) immunity's okay if applicable.
summons smaller spiders at its current location or designated location/waypoints. and teleport's away to safety/waypoint. before reengaging the players.

As i am not a scripter. my skills and knowledge are very limited in these regards. i have learned what i know threw experimentation watching tutorials and using (lilac souls) script generator. i have a base understanding. i use the script generator for most things and try to cut and paste. scripts together with my limited knowledge. most scripts/systems i use are from the nwn vault. but as i think this type of call will be used frequently in my mod. i want to try to understand what im missing.

i read i can used ondamaged event to do this but am unsure how to code it.
the phase spider has a script similar in function already. under the user defined events script tab. here is the script.

//::///////////////////////////////////////////////
//:: NW_C2_DIMDOOR.nss
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Creature randomly hops around
to enemies during combat.
*/
//:://////////////////////////////////////////////
//:: Created By: Brent
//:: Created On: January 2002
//:://////////////////////////////////////////////

void JumpToWeakestEnemy(object oTarget)
{
object oTargetVictim = GetFactionMostDamagedMember(oTarget);
// * won't jump if closer than 4 meters to victim
if ((GetDistanceToObject(oTargetVictim) > 4.0) && (GetObjectSeen(oTargetVictim) == TRUE))
{
ClearAllActions();
effect eVis = EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, OBJECT_SELF);

// SpeakString("Jump to " + GetName(oTargetVictim));
DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, OBJECT_SELF));
DelayCommand(0.3,ActionJumpToObject(oTargetVictim));
DelayCommand(0.5,ActionAttack(oTargetVictim));
}
}
void main()
{
// * During Combat try teleporting around
if (GetUserDefinedEventNumber() == 1003)
{
// * if random OR heavily wounded then teleport to next enemy
if ((Random(100) < 50) || ( (GetCurrentHitPoints() / GetMaxHitPoints()) * 100 < 50) )
{
JumpToWeakestEnemy(GetNearestCreature(CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY));
}
}
}

My question is how do i make this function do what I'm trying to do. how do i make this not random.

if ((Random(100) < 50) || ( (GetCurrentHitPoints() / GetMaxHitPoints()) * 100 < 50) )
{

i can figure out the actions with the script generator unsure about this part. the script generator doesn't have ondamaged event setup or on user defined setup. which i have never used a userdefined event and unsure how to implement them.