Aller au contenu

Photo

remove available spells?


  • Veuillez vous connecter pour répondre
17 réponses à ce sujet

#1
bealzebub

bealzebub
  • Members
  • 352 messages
I'm trying to figure out how to force cast or remove, a pc and companions, available spells. So when they awaken, naked and weaponless, the mages and clerics don't have any spells to cast.
After giving it some thought, and looking through the list of functions, I realized I don't even know where to begin.
If someone could point me in the right direction, I would be very thankful.

#2
Dann-J

Dann-J
  • Members
  • 3 161 messages
You could try reducing their spell-casting ability to 10 via a supernatural effect. Or you can apply 100% spell failure to them. Their spells won't be gone, but they won't be able to cast them.

I too have looked for a function that does what you want, and had no luck. The closest I could find was a function that reduces the number of uses a feat has left per day. There doesn't seem to be a corresponding function for spells though.

#3
Morbane

Morbane
  • Members
  • 1 883 messages
Right out of the Lexicon...

Decrease the number of spell uses of a particular spell for a given creature.

void DecrementRemainingSpellUses( object oCreature, int nSpell);

Parameters:
oCreature

Creature to decrement the remaining spell uses of a particular spell.

nSpell: SPELL_*

Description
Decreases the remaining number of spell uses per day for a creature by one. A creature must have at least one spell use for this function to work. To make this work correctly, it should be used with GetHasSpell().

nSpell doesn't have to be a spell. It can be any entry in the spells.2da file.

If they do not have any castings of nSpell memorised, then nothing will happen.

Note that this has to be added into a loop, with GetHasSpell(), to remove all the avalible castings of nSpell.

#4
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
I wonder what would happen if you temporarily reduced their intelligence and wisdom. Would that make them automatically lose their spells?

#5
Morbane

Morbane
  • Members
  • 1 883 messages

Kaldor Silverwand wrote...

I wonder what would happen if you temporarily reduced their intelligence and wisdom. Would that make them automatically lose their spells?


Urg! Me Mage! .....Oh yes my good fellow I have no spells anymore! :lol:

#6
Claudius33

Claudius33
  • Members
  • 258 messages
Hello,

The function below will remove cast spelling capabalities from any creature (PC, party member ...) :

// prevent magic

void NoMagic(object oCreature)
{
    effect eAnti = EffectSpellFailure(100);
    eAnti = SupernaturalEffect(eAnti);
   
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, eAnti, oCreature);   
}

usage sample : NoMagic(GetFirstPC());

The function below gives cast spelling capabilities back to the creature :

// restore magic


void Magic(object oCreature)
{
    effect eEffect = GetFirstEffect(oCreature);
    while (GetIsEffectValid(eEffect) == TRUE)
    {
        if (GetEffectSubType(eEffect) == SUBTYPE_SUPERNATURAL)
        {
            if (GetEffectType(eEffect) == EFFECT_TYPE_SPELL_FAILURE)
            {
                RemoveEffect(oCreature, eEffect);
            }
        }
        eEffect = GetNextEffect(oCreature);
    }   
}

usage sample : Magic(GetFirstPC());

You can use them in a loop to prevent/restore party's and/or opposition magic capabilities. Put the cooresponding scripts  in the connexion to an area event and to the exit area event to forbid any spell in a specific area. Sorry for the appromative translation, my toolset is in French.

#7
Dann-J

Dann-J
  • Members
  • 3 161 messages

Morbane wrote...

Right out of the Lexicon...

Decrease the number of spell uses of a particular spell for a given creature.

void DecrementRemainingSpellUses( object oCreature, int nSpell);


Now I remember what it was I was trying to do - I was trying to *increase* the number of uses per day of an item that could only be used outside (the Horn of the Skymage). If you used it inside you got a message instead of it activating - except that you lost a use per day anyway. At the time I could only find ways of decrementing feat/spell usages, and no way of incrementing the uses per day of an item (if it was a fixed-charge item it wouldn't have been a problem).

Stupid memory. At least it's not as bad as my memory though.

#8
bealzebub

bealzebub
  • Members
  • 352 messages
hmm,
So if I took the DecrementRemainingSpellUses route, to remove all spells, I would have to script a check for every possible spell, and loop it for every spell, say 6 times, to make sure I got all the uses per day. I want to remove only spells, not feats and such, so I would need to go through the spells.2da and just get the int of spells I want to remove. That's a lot of spells.
Claudiaus33's, prevent magic route, would mean that scrolls would not work either. I want to leave a few scrolls, so that's out.
Reducing intelligence, wisdom, and charisma would be the easiest, and scrolls would still work. Though it is not really what I want to do.
Do ya'll think that about summs it up?

#9
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
I'm surprised there isn't a function to return the spells someone has readied so you could just loop through them and remove them.

I'm not suggesting you leave them stupid by the way, just drop the intelligence, wisdom, (and charisma I guess) and then restore them. I'm guessing the engine will remove the spells for you. Never tried it though.

Regards

Modifié par Kaldor Silverwand, 10 janvier 2012 - 12:43 .


#10
Dann-J

Dann-J
  • Members
  • 3 161 messages
There is a bug with sorcerers whereby if you repeatedly remove and replace a nymph cloak (after having rested with it on) you gradually lose all of your spells. The game engine removes the additional spell usages you got when your charisma was boosted before you slept, but doesn't notice that you are re-requipping the cloak, so it keeps removing spell usage as you keep unequiping the cloak (or anything else that boosts charisma).

This might suggest that reducing the casting ability to 10 for a few seconds (I'd do it for at least a round - maybe 7 seconds to make sure) will remove the spell usages. As Kaldor suggests, it requires some experimentation to confirm though.

#11
MasterChanger

MasterChanger
  • Members
  • 686 messages

Kaldor Silverwand wrote...

I'm surprised there isn't a function to return the spells someone has readied so you could just loop through them and remove them.


A while ago when I was trying to figure out a way to make a custom quickspell menu, this was exactly the problem I ran into. If you only have to loop over all spells once (as in the situation the OP is discussing) that's not really a terrible thing. I was facing a potential need to do it repeatedly. I unfortunately never found a good work-around.

It's also too bad that the only way currently available to restore spells is to force rest. I'm pretty sure that's how Tiberius did it in The Maimed God's Saga: "resting" not at an altar would just restore hit points, but praying at an altar would actually result in a rest (then decrement your HP back to where it was).

It would be nice if some of the brilliant NWNX :wizard: folks could come up with a plugin that gives script access to the spells a character has readied, both for retrieval purposes and for incrementing.

#12
bealzebub

bealzebub
  • Members
  • 352 messages
I'll give reducing ability scores a try. I'll let ya'll know if it works. (It may take a day or so).

#13
The Fred

The Fred
  • Members
  • 2 516 messages
You could probably hook into the GUI to keep your own track of what spells people have known and/or readied. It's probably more work than it's worth, though.

#14
bealzebub

bealzebub
  • Members
  • 352 messages
And the prize goes to... *drum roll* ... Kaldor Silverwand, for his lower the ability scores suggestion!

I just made a simple OnEnter script that lowers ability scores by 10 for 10 seconds, and wallah, no more available spells. Thanks Kaldor.

#15
kamal_

kamal_
  • Members
  • 5 250 messages
and stuff... taking spammer off the most recent post...

#16
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
Glad it works. Rereading DannJ's post before mine though he also suggested reducing the spell-casting ability. I just didn't read his post (sorry, DannJ). So in the spirit of the holiday season I pass this tremendous prize on to DannJ. I'm keeping the drumroll though.

#17
Chass

Chass
  • Members
  • 50 messages
NWN1 used to have a Spell hook which when cast would fire a script prior to the spell.. Does NWN2 have that ability?

#18
The Fred

The Fred
  • Members
  • 2 516 messages
Yep.