Starkson Wand Scripts

This forum is for those interested in discussing NWN scripting.

Moderators: DM_eaze, Luceran, DM_Jaydaan, ST_DM_Myle, dm_xeen1, DM Nexus, DM_TrainWrek, Carpe_DM1, DM_Unicorn, DM_Griphon, DM_Shadowlands, dm_zane, DM_Centaur, DM_Mystic, DM Rendyll, DM_Avalon

User avatar
driller
Site Admin
Site Admin
Posts: 4792
Joined: Tue Jul 04, 2006 8:52 am
Contact:

Post by driller »

The main problem with the scripts that I got from Jazelle is they were tag based scripts being called from a conversation.

The problem is is by the time you get around to choosing the action in the conversation tree is that the PC who last activated the wand is no longer valid or has changed to some else. Same for the target.

In a conversation use object oPC = GetPCSpeaker();
When you activate the wand, set the GetItemActivatedTarget() as a Local Object on the GetItemActivator().

When you select an action from the conversation menu, the target will be the local object you saved on wand activation.

That make sense?

-driller
Jazelle wrote:Driller would have to post a copy of that script to be sure it is. Hey Adrian nice to hear from you.
User avatar
Caesius
Duke
Duke
Posts: 735
Joined: Wed Jul 05, 2006 8:57 am
Location: Somewhere within the Imaginary Number Domain...

Post by Caesius »

I must admit that my skill with NWScript is still relatively at a basic level. I would like to find ways to make it more efficient while retaining it's menu based nature if such is possible. Sadly, I could not find a way for a conversation to pass parameters to organize the code into a smaller number of scripts.

I do acknowledge that the current version of SKS is still somewhat clunky. Driller is right, how the system stores it's targeting data will need adjustments to eliminate interference from other activation scripts. Advice is welcomed and appreciated.

Hello again Jazelle. :)
The only constant is change.
User avatar
Jazelle
Duke
Duke
Posts: 731
Joined: Thu Jul 06, 2006 12:56 am
Location: Land of gators and lizards
Contact:

Post by Jazelle »

Remember that 25% I said I do understand.... well that did kicked in there and I understand the problem and have a idea (layman's) how it needs to be fixed but not how to do it.
The world is a strange place.
User avatar
driller
Site Admin
Site Admin
Posts: 4792
Joined: Tue Jul 04, 2006 8:52 am
Contact:

Post by driller »

Code: Select all

    
#include "x2_inc_switches"
void main()
{
    int nEvent = GetUserDefinedItemEventNumber();    //Which event triggered this
    object oPC = GetItemActivator();
    object oTarget = GetItemActivatedTarget();
    //Cache the target on the activator
    SetLocalObject(oPC,"SKS_TARGET",oTarget);
    //Same for the tag of the item since you reference it in another script
    SetLocalString(oPC,"SKS_TAG",GetTag(GetItemActivated()));

    if (GetIsPC(oTarget))
    {
      switch (nEvent)
      {
          case X2_ITEM_EVENT_ACTIVATE:
              // * This code runs when the Unique Power property of the councilwand is used
              // * Note that this event fires for PCs only
             AssignCommand(oPC, ActionStartConversation(oPC, "sks_stk_cncil", FALSE));
             break;
      }
    }
    else
    {
      SendMessageToPC(oPC, "That is not a valid target to give keys to...");
    }
}

Code: Select all

//::///////////////////////////////////////////////
//:: SKS Starkson Property Removal Script v2.0
//::
//:: Copyright (c) 2006 Adrian Dion
//::
//:: This script will loop through a selected target's inventories and
//:: remove any non-wand Starkson items including keys and the
//:: citizenship scroll as well as Council Wands depending on the wand that
//:: is used to trigger this script.
//::
//:://////////////////////////////////////////////

#include "x2_inc_switches"

void main()
{
// Start main script

//Since we are in a conversation, get the speaker
object oPC = GetPCSpeaker();

//Get the target we cached when we activated the wand.
object oTarget=GetLocalObject(oPC,"SKS_TARGET");
//Tag too
string sTag = GetLocalString(oPC,"SKS_TAG");


//Make sure this script only executes when the user has activated the zapper.
//if ( GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_ACTIVATE ) return;

if (GetIsPC(oTarget))  // If it is a pc, strip the items
  {
  // Initialize: Get the first inventory item
  object oCurrentItem=GetFirstItemInInventory(oTarget);
  SendMessageToPC(oPC, "Items removed:");
  // Loop through all items in inventory
  while (oCurrentItem != OBJECT_INVALID)
    {
     //The following items can be removed by Council Wands, Universal
     //Key Zappers and the Sovereign Wand.
     if (GetTag(oCurrentItem)=="sks_stk_scroll")
       {DestroyObject(oCurrentItem);
        SendMessageToPC(oPC, "Starkson Scroll of Citizenship");}
     else if (GetTag(oCurrentItem)=="sks_stk_castlek")
       {DestroyObject(oCurrentItem);
        SendMessageToPC(oPC, "Starkson Castle Key");}
     else if (GetTag(oCurrentItem)=="sks_stk_councilk")
       {DestroyObject(oCurrentItem);
        SendMessageToPC(oPC, "Starkson Council Key");}
     else if (GetTag(oCurrentItem)=="sks_stk_innkey")
       {DestroyObject(oCurrentItem);
        SendMessageToPC(oPC, "Starkson Inn Key");}
     else if (GetTag(oCurrentItem)=="sks_stk_knightk")
       {DestroyObject(oCurrentItem);
        SendMessageToPC(oPC, "Starkson Knights Key");}

     //Only check for and remove the following if a UKZ or Sovereign Wand
     //is used.
     if (sTag =="sks_stk_sov" || sTag =="sks_stk_zapper")
       {
       if (GetTag(oCurrentItem)=="sks_stk_hou1k")
         {DestroyObject(oCurrentItem);
          SendMessageToPC(oPC, "House Key #1");}
       else if (GetTag(oCurrentItem)=="sks_stk_hou2k")
         {DestroyObject(oCurrentItem);
          SendMessageToPC(oPC, "House Key #2");}
       else if (GetTag(oCurrentItem)=="sks_stk_hou3k")
         {DestroyObject(oCurrentItem);
          SendMessageToPC(oPC, "House Key #3");}
       else if (GetTag(oCurrentItem)=="sks_stk_hou4k")
         {DestroyObject(oCurrentItem);
          SendMessageToPC(oPC, "House Key #4");}
       else if (GetTag(oCurrentItem)=="sks_stk_sovk")
         {DestroyObject(oCurrentItem);
          SendMessageToPC(oPC, "Starkson Sovereign Key");}
       else if (GetTag(oCurrentItem)=="sks_stk_cncil")
           {DestroyObject(oCurrentItem);
            SendMessageToPC(oPC, "Starkson Council Wand");}

       //The following items may only be removed by a sovereign wand.
       if (sTag=="sks_stk_sov")
         {
         if (GetTag(oCurrentItem)=="sks_stk_zapper")
           {DestroyObject(oCurrentItem);
            SendMessageToPC(oPC, "Universal Key Zapper");}
         else if (GetTag(oCurrentItem)=="sks_stk_golcom")
           {DestroyObject(oCurrentItem);
            SendMessageToPC(oPC, "Starkson Golem Command Wand");}
         }
       }
     // Destroy items with desired tags
     oCurrentItem=GetNextItemInInventory(oTarget);
     } // end while
   } // end if
  else {SendMessageToPC(oPC, "That would have no keys to Zap.");}
} // end main


-driller
User avatar
Pharo_IK
Count
Count
Posts: 121
Joined: Sat Jul 15, 2006 5:39 am

Post by Pharo_IK »

*Looks over all the pretty symbols and blinks*

Does that mean I can give my people keys without folks across the server asking me why a Starkson Key popped into thier inventory all the sudden?

Pharo
Lady Winesa Kenders(RIP): Divine Daughter of Lia, Treaty Holder of the Starkson Protectorate (All realms), Guardian of the Wildlands, Keeper of the Night´s Breath, Speaker of the Great Oak, Champion of Balance.
User avatar
Gibbo
Duke
Duke
Posts: 729
Joined: Wed Jul 05, 2006 7:05 pm
Location: East Coast - US

Post by Gibbo »

=P You could always ask them to stop asking and just accept it. Solving problems without the coding!
ZOMFGOMBIES!
User avatar
driller
Site Admin
Site Admin
Posts: 4792
Joined: Tue Jul 04, 2006 8:52 am
Contact:

Post by driller »

Yes.

-driller
Pharo_IK wrote:*Looks over all the pretty symbols and blinks*

Does that mean I can give my people keys without folks across the server asking me why a Starkson Key popped into thier inventory all the sudden?

Pharo
Locked