Npc Sleeping state question

Discussion in 'General Modification' started by anatoliy, Apr 18, 2020.

Remove all ads!
  1. marc1967

    marc1967 Established Member

    Joined:
    Jan 19, 2014
    Messages:
    555
    Likes Received:
    27

    I was hoping this wasn't the best way to do it, but it seems to be. Thanks for letting me know.

    It actually works very well, if a bit clunky, but with one nagging problem I can't fix. The spell effect ends when the party leaves the map, as does the spell itself. This may be a limitation/feature of the cast_spell() function. In contrast, if an effect is received from a spell cast in combat the effect continues when you leave the map.

    Anyway, I implemented it in two different ways, and it works good with both. I use one or the other depending on the situation.

    1. Cast the spell on an object, as you said. Full inventories were a problem, especially if you want multiple effects. So I put a permanent object in each player's inventory (like the tool in KOTB), and then the dummy spellcaster just grabs the tool, casts the spell on it, then reinserts it into the inventory. There's some flag setting and unsetting on the item during the process to deal with dropping and transferring, but not a big deal.

    2. The second way was to just have the dummy spellcaster casts a passive buff spell on himself using cast_spell(), and then within that code put the effect directly on the pc.

    As I said above, the only problem is when you leave the map the spell ends.
     
  2. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    2,861
    Likes Received:
    148
    Hmm, regarding the spell ending when changing maps. Try setting spell.caster = pc inside the script.

    The reason is that the game prunes active spells with null caster handle, and once you transfer maps, the original caster is unavailable so the handle gets set to null.
     
    Last edited: Oct 12, 2020
Our Host!