Hypnosis spell...need help on a script I'm almost done with (RESOLVED)

Below is the script:

#include "nw_i0_spells"

// Duration of the placeable in rounds
const int DURATION_ROUNDS = 10; // Adjust duration as needed

// Check if target is humanoid or demihuman
int IsTargetDemihuman(object oTarget)
{
    int nRace = GetRacialType(oTarget);
    return (nRace == RACIAL_TYPE_HUMAN ||
            nRace == RACIAL_TYPE_ELF ||
            nRace == RACIAL_TYPE_DWARF ||
            nRace == RACIAL_TYPE_HALFLING ||
            nRace == RACIAL_TYPE_GNOME ||
            nRace == RACIAL_TYPE_HALFELF ||
            nRace == RACIAL_TYPE_HALFORC);
}

// Apply hypnotic effect to valid targets
void ApplyHypnoticEffect(object oTarget)
{
    if (!IsTargetDemihuman(oTarget))
    {
        return; // Skip non-demihumans
    }

    int nDC = GetSpellSaveDC();
    if (!WillSave(oTarget, nDC))
    {
        // Hypnotic effect on the target (Daze)
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectDazed(), oTarget, 10.0);
    }
}

// Cast the Hypnosis spell
void CastSpell()
{
    // Create the hypnotic placeable at the target location
    object oPlaceable = CreateObject(OBJECT_TYPE_PLACEABLE, "phodfxfuryredblu", GetSpellTargetLocation(), TRUE);

    // Get all creatures in a sphere around the placeable
    object oCreature = GetFirstObjectInShape(SHAPE_SPHERE, 5.0, GetLocation(oPlaceable)); // Get first object in range

    // Loop through all objects in the sphere
    while (GetIsObjectValid(oCreature))
    {
        // Only apply effects to creatures that are not the caster
        if (oCreature != GetCaster()) // This checks if the creature is not the caster
        {
            ApplyHypnoticEffect(oCreature);
        }

        // Get the next object in range for the next iteration
        oCreature = GetNextObjectInShape(SHAPE_SPHERE, 5.0, GetLocation(oPlaceable));
    }

    // Optional: Apply a pulse visual effect at the placeable's location for flair
    ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_PULSE_COLD), GetLocation(oPlaceable));

    // Set a delayed action to remove the placeable after the specified duration
    DelayCommand(RoundsToSeconds(DURATION_ROUNDS), RemovePlaceable(oPlaceable));
}

// Remove the placeable object after spell duration expires
void RemovePlaceable(object oPlaceable)
{
    if (GetIsObjectValid(oPlaceable)) // Ensure the object is still valid before destroying
    {
        DestroyObject(oPlaceable);
    }
}

suppose to work like this:

Hypnosis

School: Enchantment (Compulsion)
Level: Bard 1, Sorcerer/Wizard 1
Components: Verbal, Somatic
Casting Time: 1 standard action
Range: Close (25 ft. + 5 ft./2 levels)
Target: One humanoid or demihuman creature
Duration: 1 round/level (Dazed effect)
Saving Throw: Will negates
Spell Resistance: Yes

Description:

With a soft, hypnotic chant, you lull your target into a trance, leaving them dazed and vulnerable. This spell works only on humanoid or demihuman creatures, such as humans, elves, dwarves, halflings, gnomes, half-elves, and half-orcs.

If the target fails a Will save, they become Dazed for the duration of the spell. While dazed, the target is unable to act, suffering from confusion and disorientation, making them an easy target for follow-up attacks or spells. The target remains unaware of the caster’s intentions but is incapacitated by the spell’s effects.

A creature that succeeds on the Will save is unaffected by the spell. The caster can target multiple creatures within range by casting the spell at a location or in the vicinity of the spell’s area of effect.

Special Components:

  • A placeable object representing the hypnotic focus (a visual effect or object) will be created at the spell’s target location. The placeable remains for a duration of the spell and helps visualize the spell’s hypnotic influence.

Notes:

  • The caster cannot target themselves or their allies with this spell.
  • The Dazed effect lasts for 1 round per caster level, or until the target succeeds on a Will save to break free early.

BUT…the placeable is not being created and i am getting the following error in the script;

ERROR: NO RIGHT BRACKET ON EXPRESSION

// Only apply effects to creatures that are not the caster if (oCreature != GetCaster()) // This checks if the creature is not the caster

Spell caster is OBJECT_SELF, is GetCaster a custom function?

This is what I get when I run it through my linter:

test:48:25 error: unable to resolve identifier 'GetCaster'

I think there is an issue open about the error message that you are seeing with the toolset compiler: nwn_script_comp: Wrong error type detected upon using an unknown identifier as an if() argument · Issue #123 · niv/neverwinter.nim · GitHub

@Imtherealthing - Just glancing at this I notice there is no void main() in your script as far as I can see, so this script doesn’t run at all. It’s just like an include script at the moment.

You could try with this script, it should do what the spell description says, as long as it’s called from a properly registered spell in the spells.2da file.

int GetIsHumanoid(object oTARGET)
{
    int nRACIAL = GetRacialType(oTARGET);
    switch (nRACIAL)
    {
        case RACIAL_TYPE_DWARF:
        case RACIAL_TYPE_ELF:
        case RACIAL_TYPE_GNOME:
        case RACIAL_TYPE_HALFELF:
        case RACIAL_TYPE_HALFLING:
        case RACIAL_TYPE_HALFORC:
        case RACIAL_TYPE_HUMAN:
        case RACIAL_TYPE_HUMANOID_GOBLINOID:
        case RACIAL_TYPE_HUMANOID_MONSTROUS:
        case RACIAL_TYPE_HUMANOID_ORC:
        case RACIAL_TYPE_HUMANOID_REPTILIAN:
            return TRUE;
    }
    return FALSE;
}

void CycleDaze(object oPLACE, object oTARGET, object oCASTER, int nSPELL, int nDC, float fDUR)
{
    if (fDUR < 6.0)
    {
        DestroyObject(oPLACE);
        return;
    }
    if (GetHasSpellEffect(nSPELL, oTARGET) == FALSE)
    {
        DestroyObject(oPLACE);
        return;
    }
    if (WillSave(oTARGET, nDC, SAVING_THROW_TYPE_MIND_SPELLS, oCASTER) != 0)
    {
        effect eFX = GetFirstEffect(oTARGET);
        while (GetIsEffectValid(eFX) == TRUE)
        {
            if (GetEffectSpellId(eFX) == nSPELL)
            {
                RemoveEffect(oTARGET, eFX);
                break;
            }
            eFX = GetNextEffect(oTARGET);
        }
        DestroyObject(oPLACE);
        return;
    }
    DelayCommand(6.0, CycleDaze(oPLACE, oTARGET, oCASTER, nSPELL, nDC, fDUR - 6.0));
}

void main()
{
    object oCASTER = OBJECT_SELF;
    object oTARGET = GetSpellTargetObject();
    if (GetIsImmune(oTARGET, IMMUNITY_TYPE_DAZED, oCASTER) == TRUE)
    {
        SendMessageToPC(oCASTER, "Target is immune against Daze effects.");
        return;
    }
    if (GetIsImmune(oTARGET, IMMUNITY_TYPE_MIND_SPELLS, oCASTER) == TRUE)
    {
        SendMessageToPC(oCASTER, "Target is immune against Mind spells.");
        return;
    }
    if (GetIsHumanoid(oTARGET) == FALSE)
    {
        SendMessageToPC(oCASTER, "Target is not humanoid.");
        return;
    }
    int nDC = GetSpellSaveDC();
    if (WillSave(oTARGET, nDC, SAVING_THROW_TYPE_MIND_SPELLS, oCASTER) != 0) return;

    int nLEVEL = GetCasterLevel(oCASTER);
    float fDUR = RoundsToSeconds(nLEVEL);
    location lSPELL = GetSpellTargetLocation();

    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectDazed(), oTARGET, fDUR);
    object oPLACE = CreateObject(OBJECT_TYPE_PLACEABLE, "phodfxfuryredblu", lSPELL, TRUE);
    int nSPELL = GetSpellId();
    DelayCommand(6.0, CycleDaze(oPLACE, oTARGET, oCASTER, nSPELL, nDC, fDUR - 6.0));
}
1 Like

Nope…I had GPT help with this script. I’m no scriper, but I try to understand what it is doing. I can’t get past this point. The script is there almost I feel. Is it possible you or someone else can finish it?

Yeah, as I mentioned to leo_x…I had GPT help me with this. That is what it created. Not sure why it came out like this. I’m trying to use GPT as much as I can instead of bothering or begging for help on the vault. I feel like I pester too many for help. I’m no scripter…just an ideas guy. :frowning:

Hi Clangeddin,

I’m not a scripter…so not sure if you mean I need to supplant my section of script with yours or put it in somwhere else?

I would suggest to replace it entirely, yes.
The script I made should (although I haven’t tested it) do what you ask for, provided it is properly implemented in the spells.2da file.

2 Likes

So do you mind rewriting the entire script with your changes/recommendations? If you don’t mind please.

It’s what I did, that’s the script rewritten from scratch.

1 Like

oops sorry…I did not scroll down the script…lol

Thanks bud…will try it…

Thanks bud,

Works! I will give you credit on the vault upload of this spell.

Two issues though.

  1. The placeable vfx on the half-orc pheno type seems to be placed not in front of the half-orc but on his body. It should give the appearance of the spell circling in front of his face.

Is it possible to put the placeable a bit more in front of the target?

  1. The spell description above says:

But I see at most the spell working only 3 rounds (my caster was 5th level) I saw that the one target failed three times then no more saves were made and the spell ended.

Could one also add maybe a WILL penalty to the spell…say a -2 on WILL?

I think it’s possible to put the put placeable a bit more in front of the target, the problem is that involves vector usage if I recall correctly and to be frank I don’t know the correct x/y/z values to adjust the position by the measure you like, I might end up making something that spawns the circle 2 meters ahead of the target.
Although I’m going by my memory of NWN2 scripting here, I don’t recall if NWN1 had those vector functions.

The duration of 3 rounds probably happened because they succeded the final saving throw and broke free of the spell on the third round? Is it always 3 rounds? Try it several more times, maybe against targets with very low saving throws (or with characters with very high DCs), maybe it was just RNG.

You can certainly add a WILL penalty to the spell, it’s basically as the same as raising the DC by +2, I’m pretty sure it’s equivalent in gameplay terms.

Ok…could you script the -2 penalty for me?

Yeah the creature made three failed saves…and then there were no more generated (tested this several times). It should have worked according to the spell 5 rounds (5 attempts to save) as my caster was 5th lv.

I guess I will just let the placeable vfx stay as is :slight_smile:

Thanks bud

Just change the line of nDC to the following

The duration being limited to 3 rounds seems kinda worrying though, it shouldn’t happen.
I’ll take another look at the script to see if I missed something.

1 Like

Thanks bud

Oh found out I had set my scrolls to 3rd level casting. That why it lasted 3 rounds :slight_smile:

Spell now works as should :slight_smile:

1 Like

Thanks everyone for your input!!

Posted to vault with credit to you guys :slight_smile: