Navigation

    City of Arabel

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    OnDeath

    Scripting
    6
    16
    5281
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      darkelf24420 last edited by

      Okay so I'm working on my OnDeath script and I can't get the PC to go to the death plane. Seem like everything else is firing properly just can't get him to move areas.

      Heres my script:

      /* Script generated by
      Lilac Soul's NWN Script Generator, v. 2.3

      For download info, please visit:
      http://nwvault.ign.com/View.php?view=Ot ... 683&id=625 */

      //Goes OnPlayerDeath of the module properties
      void main()
      {

      object oPC = GetLastPlayerDied();

      if (!GetIsPC(oPC)) return;

      object oTarget;
      oTarget = GetObjectByTag("PClootbag");

      object oItem;
      oItem = GetFirstItemInInventory(oPC);

      while (GetIsObjectValid(oItem))
      {
      AssignCommand(oTarget, ActionTakeItem(oItem, oPC));

      oItem = GetNextItemInInventory(oPC);
      }

      int nInt;
      for (nInt=0; nInt <num_inventory_slots; nint++)<br="">{
      oItem = GetItemInSlot(nInt, oPC);

      if (GetIsObjectValid(oItem))
      AssignCommand(oTarget, ActionTakeItem(oItem, oPC));
      }

      AssignCommand(oTarget, TakeGoldFromCreature(GetGold(oPC), oPC));

      location lTarget;
      oTarget = GetWaypointByTag("toDeathplane");

      lTarget = GetLocation(oTarget);

      //only do the jump if the location is valid.
      //though not flawless, we just check if it is in a valid area.
      //the script will stop if the location isn't valid - meaning that
      //nothing put after the teleport will fire either.
      //the current location won't be stored, either

      if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;

      SetLocalLocation(oPC, "ls_stored_loc", GetLocation(oPC));

      AssignCommand(oPC, ClearAllActions());

      DelayCommand(3.0, AssignCommand(oPC, ActionJumpToLocation(lTarget)));

      oTarget = oPC;

      //Visual effects can't be applied to waypoints, so if it is a WP
      //the VFX will be applied to the WP's location instead

      nInt = GetObjectType(oTarget);

      if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_UNSUMMON), oTarget);
      else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_UNSUMMON), GetLocation(oTarget));

      }</num_inventory_slots;>

      Not sure what the issue is, no errors in the script.

      Cola Sane….... is now just a side

      Barakis- Vengeful Coward.

      1 Reply Last reply Reply Quote
      • Snowstorm
        Snowstorm last edited by

        My guess is the PC could just cancel the action to teleport that was set on him.

        Here is a revised version with more commentary and some changes that should ensure the PC teleports to death plane.

        I did not test if this code compiles, but I think it should be ok.

        /* 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 */
        
        //Goes OnPlayerDeath of the module properties
        
        //Queue of actions that jumps a PC to the death plane
        void ActionMoveToDeathPlane(object oWaypoint)
        {
            //apply a visual effect
            ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_IMP_UNSUMMON), GetLocation(OBJECT_SELF), 6.0); //OBJECT_SELF refers to oPC in this function because the command was assigned to him: AssignCommand(oPC, ActionMoveToDeathPlane(oWaypoint));
        
            ClearAllActions(); //clear the PC's action queue
            ActionWait(3.0); //assign the action to wait 3 seconds
            ActionJumpToObject(oWaypoint); //assign the action to jump to oWaypoint (in the death plane)
            ActionDoCommand(SetCommandable(TRUE)); //assign the action to unlock the action queue so that the player regains control of his PC
            SetCommandable(FALSE); //lock the PC's action queue so that he does not cancel what we just asked him to do!
        }
        
        void main()
        {
            //the PC who jsut died
            object oPC = GetLastPlayerDied();
        
            //if it's not a PC, don't run this script
            if (!GetIsPC(oPC)) return;
        
            //the loot bag in which we will place the PC's belongings
            object oLootBag = GetObjectByTag("PClootbag");
            //oitem will cycle through the inventory of the PC
            object oItem = GetFirstItemInInventory(oPC);
        
            //move the items in the PC's 6 inventory pages to the loot bag
            while (GetIsObjectValid(oItem))
            {
                AssignCommand(oLootBag, ActionTakeItem(oItem, oPC));
        
                oItem = GetNextItemInInventory(oPC);
            }
        
            //move the items by the PC to the loot bag
            int nInt;
            for (nInt=0; nInt
        

        White teddy bear

        1 Reply Last reply Reply Quote
        • D
          darkelf24420 last edited by

          Line 10 could not compile.

          ActionMoveToDeathPlane(object oWaypoint)

          should it read?:

          ActionMoveToLocation(object oWaypoint DeathPlane)

          Cola Sane….... is now just a side

          Barakis- Vengeful Coward.

          1 Reply Last reply Reply Quote
          • C
            COA_Aristos last edited by

            Heh, uh, no.

            Just put "void " in front of it, that ought to fix it.

            –----------------------------
            Character - Belir Faethalor (Hellos)
            Character - Pang (smash!)
            Character - Hannan Swift (dead)
            Character - Zacham Nefzen (dead)

            1 Reply Last reply Reply Quote
            • C
              COA_Aristos last edited by

              I'd like to suggest you take a wee bit of a pause, and take some time to go read the forum sticky and get some of the basic basics of programming. The Tutorial section of NWNLexicon in particular I'd recommend.

              It's a very good introduction into what's going on when the compiler is looking at your code.

              –----------------------------
              Character - Belir Faethalor (Hellos)
              Character - Pang (smash!)
              Character - Hannan Swift (dead)
              Character - Zacham Nefzen (dead)

              1 Reply Last reply Reply Quote
              • Snowstorm
                Snowstorm last edited by

                I fixed the mistake in my code.

                I recommand downloading the nwn lexicon if it's not already done. It gives you a lot of informations with examples that are not present in the toolset compiler.

                White teddy bear

                1 Reply Last reply Reply Quote
                • haljordan
                  haljordan last edited by

                  I don't know if it's still available but "LilacSoul's Script Generator" can do a lot of this stuff.

                  Romar: Moustached man of Tempus
                  Selsal Thervain: Sneaky shoot stab stab
                  Morich Leonson: Grumpy old man
                  Kyra De'syr: DeSchurr NPC

                  1 Reply Last reply Reply Quote
                  • D
                    darkelf24420 last edited by

                    I'm using the script generator.

                    I still can't get the PC to jump areas to the "death plane".

                    Reading and the web are helping, but the script still isn't working right.

                    Cola Sane….... is now just a side

                    Barakis- Vengeful Coward.

                    1 Reply Last reply Reply Quote
                    • Snowstorm
                      Snowstorm last edited by

                      Did you set the waypoint correctly?

                      White teddy bear

                      1 Reply Last reply Reply Quote
                      • B
                        Bongo last edited by

                        You need to create a waypoint in your death area with the Tag “toDeathplane“

                        Also out of curiosity Snowstorm:
                        What happens if you don’t have this check;

                        //only do the jump if the destination waypoint exists 
                        if (GetIsObjectValid(oWaypoint)) 
                        ```And there is no waypoint?
                        
                        =)
                        1 Reply Last reply Reply Quote
                        • Snowstorm
                          Snowstorm last edited by

                          Everything except jumping to the waypoint happens.

                          In this case, the variable ls_stored_loc is stored on the PC, a visual effect would be applied and the player would lose the control of his character for about 3 seconds. The character would not be moved to an Invalid waypoint.

                          White teddy bear

                          1 Reply Last reply Reply Quote
                          • D
                            darkelf24420 last edited by

                            The waypont was there the whole time, but I changed the waypoint from blue to green, and then it started working. Thanks again for the fixes.

                            Cola Sane….... is now just a side

                            Barakis- Vengeful Coward.

                            1 Reply Last reply Reply Quote
                            • Snowstorm
                              Snowstorm last edited by

                              Changing the color shouldn't affect anything.
                              But if you say it's now working, that's good to know.

                              White teddy bear

                              1 Reply Last reply Reply Quote
                              • Turbospew
                                Turbospew last edited by

                                does this also disable the respawn popup window?

                                The Universe is Hostile, So impersonal. Devour to survive. So it is; So it's always been.

                                1 Reply Last reply Reply Quote
                                • Snowstorm
                                  Snowstorm last edited by

                                  I have no idea what triggers the popup respawn window.

                                  White teddy bear

                                  1 Reply Last reply Reply Quote
                                  • C
                                    COA_Aristos last edited by

                                    PopUpGUIPanel() or PopUpDeathGUIPanel() pull up the standard or a custom GUI for when you die. It's called in the code of the OnDeath script (if it is used).

                                    See "x2_death"

                                    So, creating your own OnDeath script that doesn't call either of those functions will "disable" (actually, will just not use) the death GUI.

                                    –----------------------------
                                    Character - Belir Faethalor (Hellos)
                                    Character - Pang (smash!)
                                    Character - Hannan Swift (dead)
                                    Character - Zacham Nefzen (dead)

                                    1 Reply Last reply Reply Quote
                                    • 1 / 1
                                    • First post
                                      Last post