Skip to content

Any way to make a potion to Force Rest?

I wanna make a potion that instantly rests people. This is so caster classes (wizard, sorcerer, etc) can regenerate spells per day.

I've noticed that when the casters run out of spells, they're kinda screwed because their melee is weak.

Comments

  • ProlericProleric Member Posts: 1,283
    Clone an existing potion to cast a new spell. In the spell script, the ForceRest() command will do exactly what you want.
  • Ugly_DuckUgly_Duck Member Posts: 182
    edited February 2022
    I can't figure out how to apply the ForceRest thing. This is the script I made with Lilac Soul's Script Generator:
    /*   Script generated by
    Lilac Soul's NWN Script Generator, v. 2.3
    
    For download info, please visit:
    http://nwvault.ign.com/View.php?view=Other.Detail&id=4683&id=625    */
    
    void main()
    {
    object oPC;
    
    if (!GetIsPC(GetItemActivatedTarget())
    ){
    
    SendMessageToPC(GetItemActivator(), "Improper use of item!");
    return;}
    
    oPC = GetItemActivator();
    
    object oTarget;
    oTarget = oPC;
    
    
    }
    
    I put the void ForceRest (object oCreature) all over the script but couldn't get it to work. Also, I used UniquePower: Self Only on the potion itself.
  • ReachPWReachPW Member Posts: 27
    edited February 2022
    Create a potion with unique use.

    The tag needs to match the script name. So for example, put tag: force_rest_pot

    Then in script: force_rest_pot [.nss] try this:
    
    #include "x2_inc_switches"
    
    void main()
    {
        int nEvent = GetUserDefinedItemEventNumber();
    
        if (nEvent == X2_ITEM_EVENT_ACTIVATE) 
        {
            object oPlayer = GetItemActivator();
            //object oItem = GetItemActivated();
            ForceRest(oPlayer);
        }
    
    
    SetExecutedScriptReturnValue(X2_EXECUTE_SCRIPT_END);
    }
    
    




    edit:

    You also need this switch enabled (typically OnModuleLoad event) :
    SetModuleSwitch(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS, TRUE);
    

    reference:

    https://nwnlexicon.com/index.php?title=Grimlar_-_Introduction_To_Tag_Based_Scripting

  • Ugly_DuckUgly_Duck Member Posts: 182
    It worked! Thank you so much. I'm trying to learn scripting, but it's hard for me and I suck so thanks again!
  • Ugly_DuckUgly_Duck Member Posts: 182
    I decided to use a Misc. Small item for this instead of a potion, and it still works great. My reasoning behind this is casters should be able to pump out their spells the same way a fighter class pumps out melee attacks.

    It is quite a step away from official D&D rules, but it's gonna be fun!
  • AndarianAndarian Member Posts: 185
    edited February 2022
    It may be because you're using a potion rather than an item to execute it. Potion use might not be firing and setting variables the way you're expecting for an item script. When I did this I used an item script with an item that had a potion-like appearance, and a regular "use unique" (so that it could be used to target anyone the player wanted).
Sign In or Register to comment.