PC's throwing boulders

I gave you a fully-working OnActivateItem script here (click on “all right” to see it). Use it in a freshly-made module and you’ll see it in action.

What might be hard to understand is that OnActivateItem handles activation of all items in the module. And so you have to check which item is activated to call code specific to it so it doesn’t get mixed up with code for other items (that’s what GetTag(oItem) == "BOULDER" and similar are for).

Ok started a new module. Created item. I tried to merge your script with the OnActivateItem script on Events. I could not compile it…because I suck at scripting…this is what I did in blending it:


//:://////////////////////////////////////////////
//:: Created By: Georg Zoeller
//:: Created On: 2003-07-16
//:://////////////////////////////////////////////

#include "x2_inc_switches"
void main()
{
    object oPC = GetItemActivator();
    object oItem = GetItemActivated();
    object oTarget = GetItemActivatedTarget();
    location lTarget = GetItemActivatedTargetLocation();

    if(GetTag(oItem) == "BOULDER")
    {
        // boulder item activated
        AssignCommand(oPC, ClearAllActions());
        AssignCommand(oPC, ActionCastSpellAtObject(

     // * Generic Item Script Execution Code
     // * If MODULE_SWITCH_EXECUTE_TAGBASED_SCRIPTS is set to TRUE on the module,
     // * it will execute a script that has the same name as the item's tag
     // * inside this script you can manage scripts for all events by checking against
     // * GetUserDefinedItemEventNumber(). See x2_it_example.nss
     if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
     {
        SetUserDefinedItemEventNumber(X2_ITEM_EVENT_ACTIVATE);
        int nRet =   ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
        if (nRet == X2_EXECUTE_SCRIPT_END)
        {
           return;
        }

     }

}

// This action casts a spell at oTarget.
// - nSpell: SPELL_*
// - oTarget: Target for the spell
// - nMetamagic: METAMAGIC_*
// - bCheat: If this is TRUE, then the executor of the action doesn’t have to be
// able to cast the spell.
// - nDomainLevel: TBD - SS
// - nProjectilePathType: PROJECTILE_PATH_TYPE_*
// - bInstantSpell: If this is TRUE, the spell is cast immediately. This allows
// the end-user to simulate a high-level magic-user having lots of advance
// warning of impending trouble
void ActionCastSpellAtObject(int nSpell, object oTarget, int nMetaMagic=METAMAGIC_ANY, int bCheat=FALSE, int nDomainLevel=0, int nProjectilePathType=PROJECTILE_PATH_TYPE_DEFAULT, int bInstantSpell=FALSE);

Hi Gnomocratic,

Sigh…I know you are trying to help…and I appreciate it…but what you just posted…lol…isn’t helping me because I have next to no scripting skills to implement it. Maybe you can work on this together with NWShacker and release a full step by step script with animated boulder maybe a test module (I think that would help a lot for me to see how it works). Then from there…I could sort of figure it out.

As I mentioned…I want to be able to carry a boulder in my inventory and throw it. It can only be thrown by someone with the strength of 32 or greater. It shows the animation of the boulder thrown. It has a specific range and damage. It would be nice too if one could put a placeable of a boulder down if you drop the item on the ground similar to the net throwing script I downloaded above I posted from years ago someone uploaded to the vault. I think seeing it work in a module you create and upload here on this vault would be great.

Take my script and replace with it everything from the default OnActivateItem.

oh…ok…will try that

Hey NWShacker…I just used your script and it worked…now why the hell doesn’t it work in my module? Ugh!!

Animation worked nicely…But still no strength based activation on this

Going to bed…It is 1:30am here…

I wonder how I will put this into my module now…why won’t it work?? Night you all.

Try using a PC with less than 32 strength and you’ll see.

It doesn’t work in your module because of errors in your OnActivateItem. In 99% of cases more than few lines of somebody’s code will not work in your script. You need to adapt it. Which is why you also need to understand it in the first place.

A safe way of making OnActivateItem is like this - each item in own function. It minimizes the change of them interfering with each other. You can use it as a basis for all your activated items.

CLICK HERE TO SEE THE SCRIPT
// OnActivateItem with support for two example items

void ActivateStaffOfDancing()
{
    object oUser = GetItemActivator();
    object oItem = GetItemActivated();
    object oTarget = GetItemActivatedTarget();
    location lTarget = GetItemActivatedTargetLocation();

    // put your code for staff here
    // adapt variable names from above
}

void ActivateBoulder()
{
    object oUser = GetItemActivator();
    object oItem = GetItemActivated();
    object oTarget = GetItemActivatedTarget();
    location lTarget = GetItemActivatedTargetLocation();

    // put your code for boulder here
    // adapt variable names from above
}

void main()
{
    string sTag = GetTag(GetItemActivated());

    if(sTag == "STAFFOFDANCING")
    {
        ActivateStaffOfDancing();
    }
    else if(sTag == "BOULDER")
    {
        ActivateBoulder();
    }
    else
    {
        FloatingTextStringOnCreature(
            "Activated item with unknown tag " + sTag + "!",
            GetItemActivator());
    }
}

Or go with tag-based scripting, which might be easier for you to implement (or not).

Here is my OnActivateItem script (part 1) cut in half as it is too long to list as one:

[code]

//the following is the verbatim wrapper script as used in the SoU:OC Ch 1
// -Merentha

// x1_itemactivate
//:://////////////////////////////////////////////////
/*
Common script to be used as OnActivateItem script for
all modules. Executes the script with a name matching
the tag of the item being activated. Functions like
GetItemActivator() and GetItemActivatedTarget() will
work in these scripts, since they are being executed
from the perspective of the module itself. ???

Credit for this idea belongs to tjm, who posted it to
nwvault.ign.com.

*/
//:://////////////////////////////////////////////////
//:: Created By: Naomi Novik
//:: Created On: 09/27/2002
//:://////////////////////////////////////////////////
#include “lilarcor_include”
#include “x2_inc_switches”
//#include “horse_inc_h”
#include “pjr_chat_inc”
#include “xs_detonate_loc”
#include “x3_inc_horse”
#include “zep_inc_phenos”
#include “nw_i0_generic”
#include “sd_portable_inc”
#include “blsg_h”
#include “JS_I0_DMTCHK”
#include “cs_activate”
#include “x0_inc_portal”
#include “x2_inc_plot”
#include “_town_crier_inc”
#include “x2_inc_itemprop”

void main()
{
BladeSingerModuleOnActivated();
ExecuteScript(“fly_mod_activate”,OBJECT_SELF);
ExecuteScript(“cr_onact”, GetItemActivator());
ExecuteScript(“dmfi_activate”, GetItemActivator());
ExecuteScript(“dreamscape_onac”,OBJECT_SELF);
CSact();
//:://////////////////////////////////////////////////
//:: Prototypes
object oPC = GetItemActivator();
object oItem = GetItemActivated();
object oActivator = GetItemActivator();
object oTarget = GetItemActivatedTarget();
location lActivator = GetLocation(oActivator);
string sItemTag = GetTag(oItem);
object oPlayer = GetItemActivator();
string sPlayer = GetPCPlayerName(oPlayer);

//fudge time item …found in custom misc. other…made it so PC’s now can use this rather than just DM

object oUser=GetItemActivator();
location lLoc=GetItemActivatedTargetLocation();
string sTag=GetTag(oItem);

if(sTag=="FudgeTime")
{
 AssignCommand(oUser, ActionStartConversation(oUser, "ld_con_fudge", TRUE));
}

// Global Economy Tool …found in custom misc. other…made it so PC’s now can use this rather than just DM… this script is also below for DM

if(sTag==“kpbwand”)
{
AssignCommand(oUser, ActionStartConversation(oUser, “kpb_wand”, TRUE));
}

// Item Advancement …found in custom misc. other…made it so PC’s now can use this rather than just DM … this script is also below for DM

if(sTag=="kpb_timetool")
{
 AssignCommand(oUser, ActionStartConversation(oUser, "kpb_timetool", TRUE));
}

else if(sTag==“OtherItemsYouWantToActivate”)
{
ExecuteScript(“sTag”,oUser);
}

//---------------------------------START DLA DM HORSE WIDGETS-----------------------------

if (GetTag(oItem) == "horse_dismt2")
{
    AssignCommand(oActivator, ActionStartConversation(oActivator, "horse_dismnt_dla", TRUE));
    return;
}

// Paladin Unsummon//
if (GetTag(oItem) == “horse_unsummon”)
{
object oPaladin = GetItemActivator();
AssignCommand(oPaladin, HorseUnsummonPaladinMount());
return;
}

//---------------------------------START CEP HORSE WIDGETS-------------------------------

///////////////////////////////////////////////////////////////////////////////
// Summon White Pony
///////////////////////////////////////////////////////////////////////////////
if (sItemTag == “SummonHorse”)
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, “henchman_pony”, lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + “'s " + " Pony”);
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
    AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
    AssignCommand(oPc, ActionSpeakString("Invalid Pony"));
}/* end else (valid owyrmling) */
    return;
}

///////////////////////////////////////////////////////////////////////////////
// Summon Spotted Pony
///////////////////////////////////////////////////////////////////////////////
if (sItemTag == “SummonHorse2”)
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, “henchman_ponysp”, lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + “'s " + " Pony”);
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
    AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
    AssignCommand(oPc, ActionSpeakString("Invalid Pony"));
}/* end else (valid owyrmling) */
    return;
}

///////////////////////////////////////////////////////////////////////////////
// Summon Brown Pony
///////////////////////////////////////////////////////////////////////////////
if (sItemTag == “SummonHorse3”)
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, “henchman_ponybn”, lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + “'s " + " Pony”);
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
    AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
    AssignCommand(oPc, ActionSpeakString("Invalid Pony"));
}/* end else (valid owyrmling) */
    return;
}

///////////////////////////////////////////////////////////////////////////////
// Summon Black Horse
///////////////////////////////////////////////////////////////////////////////
if (sItemTag == “SummonHorse4”)
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, “henchman_horsebk”, lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + “'s " + " Horse”);
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
    AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
    AssignCommand(oPc, ActionSpeakString("Invalid Horse"));
}/* end else (valid owyrmling) */
    return;
}

///////////////////////////////////////////////////////////////////////////////
// Summon Brown Horse
///////////////////////////////////////////////////////////////////////////////
if (sItemTag == “SummonHorse5”)
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, “henchman_horse2”, lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + “'s " + " Horse”);
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
    AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
    AssignCommand(oPc, ActionSpeakString("Invalid Horse"));
}/* end else (valid owyrmling) */
    return;
}

///////////////////////////////////////////////////////////////////////////////
// Summon Nightmare
///////////////////////////////////////////////////////////////////////////////
if (sItemTag == “SummonHorse6”)
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, “henchman_horsenm”, lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + “'s " + " Horse”);
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
    AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
    AssignCommand(oPc, ActionSpeakString("Invalid Horse"));
}/* end else (valid owyrmling) */
    return;
}

///////////////////////////////////////////////////////////////////////////////
// Summon White Horse
///////////////////////////////////////////////////////////////////////////////
if (sItemTag == “SummonHorse7”)
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, “henchman_horsewt”, lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + “'s " + " Horse”);
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
    AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
    AssignCommand(oPc, ActionSpeakString("Invalid Horse"));
}/* end else (valid owyrmling) */
    return;
}

///////////////////////////////////////////////////////////////////////////////
// Summon Aurenthil Horse
///////////////////////////////////////////////////////////////////////////////
if (sItemTag == “SummonHorse8”)
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, “henchman_horseau”, lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + “'s " + " Horse”);
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
    AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
    AssignCommand(oPc, ActionSpeakString("Invalid Horse"));
}/* end else (valid owyrmling) */
    return;
}

///////////////////////////////////////////////////////////////////////////////
// CEP widget dismount
///////////////////////////////////////////////////////////////////////////////
if (sItemTag == “horse_dismt”)
{
object oPC = GetItemActivator();
//if (GetTag (GetItemActivated ()) == “horse_dismt”) {zep_Dismount (oPC, “horse_dismt”);}
string sResRef = GetLocalString(oPC,“PONY_ID”);
zep_Dismount (oPC, “horse_dismt”);
SetLocalInt(oPC,“bX3_IS_MOUNTED”,FALSE);
DeleteLocalString(oPC,“X3_HORSE_SCRIPT_DISMOUNT”);
SetLocalInt(oPC, “VAR_HORSEMOUNT”, 0);//horselord class variable

//remove horse support DLA Style
object oRider=GetItemActivator();
DelayCommand(1.0, HORSE_SupportOriginalSpeed(oRider));
DelayCommand(1.0, HORSE_SupportRemoveMountedSkillDecreases(oRider));
DelayCommand(1.0, HORSE_SupportRemoveACBonus(oRider));
DelayCommand(1.0, HORSE_SupportRemoveHPBonus(oRider));

object oTarget;
location lPc = GetLocation(oPC);
location lWyrmling = GetItemActivatedTargetLocation();

object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, sResRef, lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + “'s " + " Horse”);
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
    AddHenchman(oPC, oWyrmling);
}/* end then (valid owyrmling) */
else
{
    AssignCommand(oPC, ActionSpeakString("Invalid Horse/Pony"));
}/* end else (valid owyrmling) */


    return;
}

///////////////////////////////////////////////////////////////////////////////
// Summon CEP/DLA Horse Managemet to dismiss a Horse
///////////////////////////////////////////////////////////////////////////////
if (GetTag(oItem) == “Horse_Management”)
{
AssignCommand(oActivator, ActionStartConversation(oActivator, “horse_magmt”, TRUE));
return;
}
///////////////////////////////////////////////////////////////////////////////
// Summon Pack Camel
///////////////////////////////////////////////////////////////////////////////
if (sItemTag == “SummonCamel”)
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, “henchman_pkcamel”, lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + “'s " + " Camel”);
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
    AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
    AssignCommand(oPc, ActionSpeakString("Invalid Camel"));
}/* end else (valid owyrmling) */
    return;
}

///////////////////////////////////////////////////////////////////////////////
// Summon Pack Horse
///////////////////////////////////////////////////////////////////////////////
if (sItemTag == “SummonpkHorse”)
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, “henchman_pkhorse”, lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + “'s " + " Horse”);
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
    AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
    AssignCommand(oPc, ActionSpeakString("Invalid Horse"));
}/* end else (valid owyrmling) */
    return;
}

///////////////////////////////////////////////////////////////////////////////
// Summon Pack Ox
///////////////////////////////////////////////////////////////////////////////
if (sItemTag == “SummonpkOx”)
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, “henchman_pkox”, lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + “'s " + " Ox”);
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
    AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
    AssignCommand(oPc, ActionSpeakString("Invalid Ox"));
}/* end else (valid owyrmling) */
    return;
}

///////////////////////////////////////////////////////////////////////////////
// Summon Pack Pony
///////////////////////////////////////////////////////////////////////////////
if (sItemTag == “Summonpkpony”)
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, “henchman_pkpony”, lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + “'s " + " Pony”);
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
    AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
    AssignCommand(oPc, ActionSpeakString("Invalid Pony"));
}/* end else (valid owyrmling) */
    return;
}

///////////////////////////////////////////////////////////////////////////////
// Summon CEP Flying System
///////////////////////////////////////////////////////////////////////////////
if (GetTag(oItem) == “fly_widget”)
{
AssignCommand(oActivator, ActionStartConversation(oActivator, “fly_control”, TRUE));
return;
}

//---------------------------------START DLA HORSE WIDGETS-------------------------------
///////////////////////////////////////////////////////////////////////////////
// Summon Walnut Horse Scale Barding
///////////////////////////////////////////////////////////////////////////////
if (sItemTag == “Horse_1”)
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, “dla_hvywarhorse2”, lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + “'s " + " Horse”);
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
    AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
    AssignCommand(oPc, ActionSpeakString("Invalid Horse"));
}/* end else (valid owyrmling) */
  return;
}

///////////////////////////////////////////////////////////////////////////////
// Summon Walnut Horse Leather Barding
///////////////////////////////////////////////////////////////////////////////
else if (sItemTag == “Horse_2”)
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, “dla_hvywarhorse3”, lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + “'s " + " Horse”);
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
    AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
    AssignCommand(oPc, ActionSpeakString("Invalid Horse"));
}/* end else (valid owyrmling) */
  return;
}

///////////////////////////////////////////////////////////////////////////////
// Summon Walnut Horse Red Barding
///////////////////////////////////////////////////////////////////////////////
else if (sItemTag == “Horse_3”)
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, “dla_hvywarhorse4”, lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + “'s " + " Horse”);
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
    AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
    AssignCommand(oPc, ActionSpeakString("Invalid Horse"));
}/* end else (valid owyrmling) */
  return;
}

///////////////////////////////////////////////////////////////////////////////
// Summon Walnut Horse Chain Barding
///////////////////////////////////////////////////////////////////////////////
else if (sItemTag == “Horse_4”)
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, “dla_hvywarhorse”, lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + “'s " + " Horse”);
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
    AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
    AssignCommand(oPc, ActionSpeakString("Invalid Horse"));
}/* end else (valid owyrmling) */
  return;
}

///////////////////////////////////////////////////////////////////////////////
// Summon Walnut Horse
///////////////////////////////////////////////////////////////////////////////
else if (sItemTag == “Horse_5”)
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, “dla_horse001”, lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + “'s " + " Horse”);
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
    AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
    AssignCommand(oPc, ActionSpeakString("Invalid Horse"));
}/* end else (valid owyrmling) */
  return;
}

///////////////////////////////////////////////////////////////////////////////
// Summon Purple Jousting Horse
///////////////////////////////////////////////////////////////////////////////
else if (sItemTag == “Horse_6”)
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, “dla_jousthorse1”, lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + “'s " + " Horse”);
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
    AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
    AssignCommand(oPc, ActionSpeakString("Invalid Horse"));
}/* end else (valid owyrmling) */
  return;
}

///////////////////////////////////////////////////////////////////////////////
// Summon Blue & Gold Jousting Horse
///////////////////////////////////////////////////////////////////////////////
else if (sItemTag == “Horse_7”)
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, “dla_jousthorse2”, lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + “'s " + " Horse”);
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
    AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
    AssignCommand(oPc, ActionSpeakString("Invalid Horse"));
}/* end else (valid owyrmling) */
  return;
}

///////////////////////////////////////////////////////////////////////////////
// Summon Black & White Jousting Horse
///////////////////////////////////////////////////////////////////////////////
else if (sItemTag == “Horse_8”)
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, “dla_jousthorse3”, lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + “'s " + " Horse”);
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
    AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
    AssignCommand(oPc, ActionSpeakString("Invalid Horse"));
}/* end else (valid owyrmling) */
  return;
}

///////////////////////////////////////////////////////////////////////////////
// Summon Red & Gold Jousting Horse
///////////////////////////////////////////////////////////////////////////////
else if (sItemTag == “Horse_9”)
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, “dla_jousthorse4”, lPc, TRUE);

Part 2:



/////////////////////////////////////// name the horse //////////////
         SetName (oWyrmling, GetName(GetItemActivator()) + "'s " + " Horse");
/////////////////////////////////////////////////////////////////////

    if (GetIsObjectValid(oWyrmling))
    {
        AddHenchman(oPc, oWyrmling);
    }/* end then (valid owyrmling) */
    else
    {
        AssignCommand(oPc, ActionSpeakString("Invalid Horse"));
    }/* end else (valid owyrmling) */
      return;
    }
///////////////////////////////////////////////////////////////////////////////
    // Summon Red & Black  Jousting Horse
///////////////////////////////////////////////////////////////////////////////
    else if (sItemTag == "Horse_10")
    {
        object oPc = GetItemActivator();
    location lPc = GetLocation(oPc);
    location lWyrmling = GetItemActivatedTargetLocation();
    object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, "dla_jousthorse5", lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
         SetName (oWyrmling, GetName(GetItemActivator()) + "'s " + " Horse");
/////////////////////////////////////////////////////////////////////

    if (GetIsObjectValid(oWyrmling))
    {
        AddHenchman(oPc, oWyrmling);
    }/* end then (valid owyrmling) */
    else
    {
        AssignCommand(oPc, ActionSpeakString("Invalid Horse"));
    }/* end else (valid owyrmling) */
      return;
    }
///////////////////////////////////////////////////////////////////////////////
    // Summon Gunpowder Grey Horse
///////////////////////////////////////////////////////////////////////////////
    else if (sItemTag == "Horse_11")
    {
        object oPc = GetItemActivator();
    location lPc = GetLocation(oPc);
    location lWyrmling = GetItemActivatedTargetLocation();
    object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, "horse002", lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
         SetName (oWyrmling, GetName(GetItemActivator()) + "'s " + " Horse");
/////////////////////////////////////////////////////////////////////

    if (GetIsObjectValid(oWyrmling))
    {
        AddHenchman(oPc, oWyrmling);
    }/* end then (valid owyrmling) */
    else
    {
        AssignCommand(oPc, ActionSpeakString("Invalid Horse"));
    }/* end else (valid owyrmling) */
      return;
    }
///////////////////////////////////////////////////////////////////////////////
    // Summon Green Jousting Horse
///////////////////////////////////////////////////////////////////////////////
    else if (sItemTag == "Horse_12")
    {
        object oPc = GetItemActivator();
    location lPc = GetLocation(oPc);
    location lWyrmling = GetItemActivatedTargetLocation();
    object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, "jousthorse002", lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
         SetName (oWyrmling, GetName(GetItemActivator()) + "'s " + " Horse");
/////////////////////////////////////////////////////////////////////

    if (GetIsObjectValid(oWyrmling))
    {
        AddHenchman(oPc, oWyrmling);
    }/* end then (valid owyrmling) */
    else
    {
        AssignCommand(oPc, ActionSpeakString("Invalid Horse"));
    }/* end else (valid owyrmling) */
      return;
    }
///////////////////////////////////////////////////////////////////////////////
    // Summon White Jousting Horse
///////////////////////////////////////////////////////////////////////////////
    else if (sItemTag == "Horse_13")
    {
        object oPc = GetItemActivator();
    location lPc = GetLocation(oPc);
    location lWyrmling = GetItemActivatedTargetLocation();
    object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, "jousthorse003", lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
         SetName (oWyrmling, GetName(GetItemActivator()) + "'s " + " Horse");
/////////////////////////////////////////////////////////////////////

    if (GetIsObjectValid(oWyrmling))
    {
        AddHenchman(oPc, oWyrmling);
    }/* end then (valid owyrmling) */
    else
    {
        AssignCommand(oPc, ActionSpeakString("Invalid Horse"));
    }/* end else (valid owyrmling) */
      return;
    }
///////////////////////////////////////////////////////////////////////////////
    // Summon pink & Blue Jousting Horse
///////////////////////////////////////////////////////////////////////////////
    else if (sItemTag == "Horse_14")
    {
        object oPc = GetItemActivator();
    location lPc = GetLocation(oPc);
    location lWyrmling = GetItemActivatedTargetLocation();
    object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, "jousthorse004", lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
         SetName (oWyrmling, GetName(GetItemActivator()) + "'s " + " Horse");
/////////////////////////////////////////////////////////////////////

    if (GetIsObjectValid(oWyrmling))
    {
        AddHenchman(oPc, oWyrmling);
    }/* end then (valid owyrmling) */
    else
    {
        AssignCommand(oPc, ActionSpeakString("Invalid Horse"));
    }/* end else (valid owyrmling) */
      return;
    }
///////////////////////////////////////////////////////////////////////////////
    // Summon White Unicorn
///////////////////////////////////////////////////////////////////////////////
    else if (sItemTag == "Horse_15")
    {
        object oPc = GetItemActivator();
    location lPc = GetLocation(oPc);
    location lWyrmling = GetItemActivatedTargetLocation();
    object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, "cep_unicorn", lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
         SetName (oWyrmling, GetName(GetItemActivator()) + "'s " + " Unicorn");
/////////////////////////////////////////////////////////////////////

    if (GetIsObjectValid(oWyrmling))
    {
        AddHenchman(oPc, oWyrmling);
    }/* end then (valid owyrmling) */
    else
    {
        AssignCommand(oPc, ActionSpeakString("Invalid Unicorn"));
    }/* end else (valid owyrmling) */
      return;
    }
///////////////////////////////////////////////////////////////////////////////
    // Summon Nightmare with Barding
///////////////////////////////////////////////////////////////////////////////
    else if (sItemTag == "Horse_16")
    {
        object oPc = GetItemActivator();
    location lPc = GetLocation(oPc);
    location lWyrmling = GetItemActivatedTargetLocation();
    object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, "dla_nightmare001", lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
         SetName (oWyrmling, GetName(GetItemActivator()) + "'s " + " Nightmare");
/////////////////////////////////////////////////////////////////////

    if (GetIsObjectValid(oWyrmling))
    {
        AddHenchman(oPc, oWyrmling);
    }/* end then (valid owyrmling) */
    else
    {
        AssignCommand(oPc, ActionSpeakString("Invalid Nightmare"));
    }/* end else (valid owyrmling) */
      return;
    }
///////////////////////////////////////////////////////////////////////////////
    // Summon Nightmare Saddled
///////////////////////////////////////////////////////////////////////////////
    else if (sItemTag == "Horse_17")
    {
        object oPc = GetItemActivator();
    location lPc = GetLocation(oPc);
    location lWyrmling = GetItemActivatedTargetLocation();
    object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, "dla_nightmare003", lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
         SetName (oWyrmling, GetName(GetItemActivator()) + "'s " + " Nightmare");
/////////////////////////////////////////////////////////////////////

    if (GetIsObjectValid(oWyrmling))
    {
        AddHenchman(oPc, oWyrmling);
    }/* end then (valid owyrmling) */
    else
    {
        AssignCommand(oPc, ActionSpeakString("Invalid Nightmare"));
    }/* end else (valid owyrmling) */
      return;
    }
///////////////////////////////////////////////////////////////////////////////
    // Summon Dark Unicorn
///////////////////////////////////////////////////////////////////////////////
    else if (sItemTag == "Horse_18")
    {
        object oPc = GetItemActivator();
    location lPc = GetLocation(oPc);
    location lWyrmling = GetItemActivatedTargetLocation();
    object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, "cep_unicorn001", lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
         SetName (oWyrmling, GetName(GetItemActivator()) + "'s " + " Unicorn");
/////////////////////////////////////////////////////////////////////

    if (GetIsObjectValid(oWyrmling))
    {
        AddHenchman(oPc, oWyrmling);
    }/* end then (valid owyrmling) */
    else
    {
        AssignCommand(oPc, ActionSpeakString("Invalid Unicorn"));
    }/* end else (valid owyrmling) */
      return;
    }
/////////////////////END DLA HORSE WIDGETS////////////////////
     //X2 Tag based system code

    ExecuteScript(sItemTag, OBJECT_SELF);

     //object oItem = GetItemActivated();

     // * Generic Item Script Execution Code
     // * If MODULE_SWITCH_EXECUTE_TAGBASED_SCRIPTS is set to TRUE on the module,
     // * it will execute a script that has the same name as the item's tag
     // * inside this script you can manage scripts for all events by checking against
     // * GetUserDefinedItemEventNumber(). See x2_it_example.nss
     if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
     {
        SetUserDefinedItemEventNumber(X2_ITEM_EVENT_ACTIVATE);
        int nRet =   ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
        if (nRet == X2_EXECUTE_SCRIPT_END)
        {
           return;
    }

    //string sTag = GetTag(oItem);
    //:://////////////////////////////////////////////////

    //HorseActivate(GetItemActivated(), GetItemActivator());
    //IsLilarcor();

    /////////////////////////////Begin language changes
    if(GetStringLeft(sItemTag, 8) == "hlslang_")
    {
        int bSpeaking=GetLocalInt(oPC,"pr_speaking");
        if (!bSpeaking)
        {
            string sTag=GetTag(oItem);
            int iLan=GetLanguageNumber(sTag);
            string sSpeaking=GetLanguageName(iLan);
            SetLocalInt(oPC,"pr_language",iLan);
            SetLocalInt(oPC,"pr_speaking",TRUE);
            SendMessageToPC(oPC,sTag);
            FloatingTextStringOnCreature(TMESSAGE_TEXT+"You are now speaking "+sSpeaking+". To return to speaking common, use this widget again."+COLOR_END,oPC,FALSE);
            return;
        }
        DeleteLocalInt(oPC,"pr_speaking");
        DeleteLocalInt(oPC,"pr_language");
        FloatingTextStringOnCreature(TMESSAGE_TEXT+"You are now speaking common."+COLOR_END,oPC,FALSE);
        return;
    }
    //////////////////////////End language changes

    //:://////////////////////////////////////////////////

    ///////////////////////////////////////////////////
    //                     **                        //
    // OnItemActivate Event for the Placeable System //
    //                  by Hunt3R                    //
    //                     **                        //
    ///////////////////////////////////////////////////
    if (sItemTag == "ab_control")
    {
        location lTarget = GetItemActivatedTargetLocation();

        //Comment to myself: "Hm. So the nearest Object to the location MUST be
        //                    an ambient one. Well no other way though..."
        object oAmbObj = GetNearestObjectToLocation(OBJECT_TYPE_PLACEABLE, lTarget);
        string sCheck = GetSubString(GetTag(oAmbObj), 0, 3);
        //Check if oAmbObj has a correct tag with which we can work -
        if (sCheck == "pl_")
        {
            //Start the Ambient Conversation
            DelayCommand(1.0, AssignCommand(oAmbObj, ActionStartConversation(oPC, "amb_dlg", TRUE, FALSE)));
            //Set Custom Token to make conversation more clear
            SetCustomToken(1456, GetName(oAmbObj));
        }
        //if not, tell activator to place his targetlocation nearer to the ambient object
        else
        {
            FloatingTextStringOnCreature("The Ambient Object MUST be the nearest Placeable to the Target Location!", oPC);
        }
    }

    //:://////////////////////////////////////////////////
    /*
        Generic Tag based events for items
     */
    //:://////////////////////////////////////////////////

    /* //* not sure why this section is here. perhaps from pre HotU system???
    if(oItem!=OBJECT_INVALID)
    {
        if(GetStringLength(sItemTag)>16)
        sItemTag=GetStringLeft(sItemTag,16);
        ExecuteScript(sItemTag,oItem);

    */

    if (sItemTag == "dmt_keg")
    {
        location lTarget    = GetItemActivatedTargetLocation();
        float fDistance     = GetDistanceBetweenLocations(GetLocation(oPlayer), lTarget);
        object oKeg         = CreateObject(OBJECT_TYPE_PLACEABLE, "gunpowderkeg", lTarget);

        // Rather cheesy script to try and make the player get closer to where he placed the barrel.
        if (fDistance >= 3.0)
        {
            AssignCommand(oPlayer, ActionMoveToLocation(lTarget, TRUE));
        }
    }
    //* throwing weapon section?
    if(GetStringLowerCase(GetStringLeft(sItemTag,2))=="t_")
    {
        AssignCommand(oPC, ExecuteScript("throwing_main", OBJECT_SELF));
    }
    //* Rogues Garrote
    if(sItemTag =="ROGUE_GARROTE")
    {
        SetLocalInt(GetItemActivator(),"ROGUE_ITEM",1);
        SetLocalObject(GetItemActivator(),"ROGUE_ITEM",GetItemActivatedTarget());
        ExecuteScript("rogue_inc",GetItemActivator());
        return;
    }
    //*  grin_hole_it_xxx
    if (GetStringLeft(sItemTag,12) == "grin_hole_it")
    {
        string sHoleNum = GetStringRight(sItemTag,3);

        DestroyObject(oItem);
        AssignCommand(oPC,ActionMoveToLocation(GetItemActivatedTargetLocation()));
        CreateObject(OBJECT_TYPE_PLACEABLE,"grin_hole_pl_" + sHoleNum,GetItemActivatedTargetLocation());
        CreateObject(OBJECT_TYPE_PLACEABLE,"grin_hole_ex_" + sHoleNum,GetLocation(GetObjectByTag("Grin_Hole_" + sHoleNum)));
    }
    //* Rope section
    if (GetResRef(oItem)=="rope")
    {
        ExecuteScript("rope_use", OBJECT_SELF);
    }
    //* Use Telescope:
    if(sItemTag == "Telescope")
    {
        SetLocalObject(GetModule(), "user", oPC);
        SetLocalObject(GetModule(), "target", oTarget);
        ExecuteScript("use_tscope", OBJECT_SELF);
    }
    //* Use Marked Telescope:
    if(sItemTag == "MarkedTelescope")
    {
        SetLocalObject(GetModule(), "user", oPC);
        SetLocalObject(GetModule(), "target", oTarget);
        ExecuteScript("use_mtscope", OBJECT_SELF);
    }
    //* Gladiator Net?
    if(sItemTag == "it_netfight"  && GetObjectType(oTarget)==OBJECT_TYPE_CREATURE )
         {
          if(GetDistanceBetween(oPC,oTarget) > 10.0)
           {
            //SendMessageToPC(oPC,"Ihr seid zu weit entfernt.");
            SendMessageToPC(oPC,"You are too far away.");
            return;
           }
          ExecuteScript("sp_netfight", OBJECT_SELF);
       }
    //* Panther figurine section
    if(sItemTag == "panthersummoner" && GetLocalInt(oPC, "panthersummoned")==0)
    {
        object oKitty = CreateObject(OBJECT_TYPE_CREATURE, "drizztpanther", GetLocation(oPC), FALSE);
        AddHenchman(oPC, oKitty);
        SetLocalInt(oPC, "panthersummoned", 1);
        return;
    }
    if(sItemTag == "panthersummoner" && GetLocalInt(oPC, "panthersummoned")==1)
    {
        object oKitty = GetAssociate(ASSOCIATE_TYPE_HENCHMAN, oPC);
        if(GetTag(oKitty)=="drizztpanther")
        {
            RemoveSummonedAssociate(oPC, oKitty);
            effect eSummon = EffectVisualEffect(VFX_IMP_UNSUMMON);
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSummon, oKitty, 2.1);
            DestroyObject(oKitty, 2.0);
        }
        SetLocalInt(oPC, "panthersummoned", 0);
        return;
    }

    //*End custom script based events
    //:://////////////////////////////////////////////////
    // * Generic Item Script Execution Code
    // * If MODULE_SWITCH_EXECUTE_TAGBASED_SCRIPTS is set to TRUE on the module,
    // * it will execute a script that has the same name as the item's tag
    // * inside this script you can manage scripts for all events by checking against
    // * GetUserDefinedItemEventNumber(). See x2_it_example.nss
    if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
    {
        SetUserDefinedItemEventNumber(X2_ITEM_EVENT_ACTIVATE);
        int nRet =   ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
        if (nRet == X2_EXECUTE_SCRIPT_END)
        {
           return;
        }

    }
{
///////////////////////////////////////////
 }

     object oUser=GetItemActivator();
     location lLoc=GetItemActivatedTargetLocation();
     string sTag=GetTag(oItem);

     // * Generic Item Script Execution Code
     // * If MODULE_SWITCH_EXECUTE_TAGBASED_SCRIPTS is set to TRUE on the module,
     // * it will execute a script that has the same name as the item's tag
     // * inside this script you can manage scripts for all events by checking against
     // * GetUserDefinedItemEventNumber(). See x2_it_example.nss
     if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
     {
        SetUserDefinedItemEventNumber(X2_ITEM_EVENT_ACTIVATE);
        int nRet =   ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
        if (nRet == X2_EXECUTE_SCRIPT_END)
        {
           return;
        }

     }

    if(sTag=="kpbwand")
    {
        if (GetIsDM(oUser) == TRUE)
        {
        AssignCommand(oUser, ActionStartConversation(oUser, "kpb_wand", TRUE));
        }
        else
        {
        DestroyObject(oItem);
        SendMessageToPC(oUser, "I am not an immortal, and I cannot use that item!");
        }
    }

    if (oItem == GetObjectByTag("kpb_timetool"))
    AssignCommand(oUser, ActionStartConversation(oUser, "kpb_timetool", FALSE));

    if (sItemTag == "BagofCapture")
    {
        ExecuteScript("bagofcapture", oUser);
        return;
  }

    }
{
 /////////////////////Portable items////////////////////
    }
   // Portable Chair
   if(GetTag(oItem)=="p_chair")
   {
       string sPCCDKey = GetPCPublicCDKey(oActivator);
       int iFlag = GetLocalInt(oActivator, "portable_chair" + sPCCDKey);

       if(iFlag == 1)
       {
           removeObject(oActivator, "portable_chair");
       }
       else if(iFlag == 0)
       {
           makeObject(oActivator, "portable_chair");
       }
   }
   // Portable Powder Keg

   if(GetTag(oItem)=="gz_it_pkeg")
   {
       string sPCCDKey = GetPCPublicCDKey(oActivator);
       int iFlag = GetLocalInt(oActivator, "gz_obj_pkeg" + sPCCDKey);

       if(iFlag == 1)
       {
           removeObject(oActivator, "gz_obj_pkeg");
       }
       else if(iFlag == 0)
       {
           makeObject(oActivator, "gz_obj_pkeg");
       }
   }
    // Portable Explosives

   if(GetTag(oItem)=="explosives")
   {
       string sPCCDKey = GetPCPublicCDKey(oActivator);
       int iFlag = GetLocalInt(oActivator, "explosives" + sPCCDKey);

       if(iFlag == 1)
       {
           removeObject(oActivator, "explosives");
       }
       else if(iFlag == 0)
       {
           makeObject(oActivator, "explosives");
       }
   }


   // Portable bench
   if(GetTag(oItem)=="p_bench")
   {
       string sPCCDKey = GetPCPublicCDKey(oActivator);
       int iFlag = GetLocalInt(oActivator, "portable_bench" + sPCCDKey);

       if(iFlag == 1)
       {
           removeObject(oActivator, "portable_bench");
       }
       else if(iFlag == 0)
       {
           makeObject(oActivator, "portable_bench");
      }
  }


 // common storage ring

 if (GetTag(GetItemActivated()) == "CRoS")
  {
   ExecuteScript("cros_onac", OBJECT_SELF);

// jail system
     }
   {
    if ((GetTag(GetItemActivated()) == "IT_IMPRISONMENTSTONE"))
    {
        DMItemTeleportActivated(GetItemActivator(), GetItemActivatedTarget());
    }


        if (GetTag(GetItemActivated()) == "IT_GUARDSTONE")
        {
            ExecuteScript("exe_guardstone", oPC);
            return;
        }
      }
   {
 //staff of dancing
   }
  object oUsed = GetItemActivated();
  if (GetTag(oUsed) == "STAFFOFDANCING")
    {
       object oUser = GetItemActivator();
       if (GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oUser) != oUsed)
       {
            SendMessageToPC(oUser, "You must equip the staff before you can use its special power.");
       }else{
       DestroyObject(oUsed);
       location mySummon = GetLocation(oUser);
       effect eAppear = EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_3);
       object oStaff = CreateObject(OBJECT_TYPE_CREATURE, "eas_staffdance", mySummon, TRUE);
       mySummon = GetLocation(oStaff);
       ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eAppear, mySummon, 1.5);
       SetIsTemporaryFriend(oUser,oStaff,FALSE);
       SetLocalInt(oStaff, "TIMER", 6);
       SetLocalObject(oStaff, "OWNER", oUser);
       }

    }
 }

Could you look it over and see if you can fix this for me please?

How much of this is actually used by you? How much is written by you?

I suggest you read my previous post and modify that script to work only with items you need. One item tag per function.

First, test my script as as it is - see what happens. Then add the boulder you wanted. You have all resources needed in this thread. Then apply the same method to the other activatable items, testing them one by one.

Hi NWNShacker

Thanks for your replies. LOL…that script is a mix bag of me and others who helped me over years. I did most of that stuff (mixing and trial and error and help from people in the community) years ago.

I was hoping you could look at it and add your script to it. Then I would test it.

I had to break it up into two parts because the script was too big to list as one. I tried to add your script to mine and it did not work although it compiled. I do use this script currently in my game…and it works for all my items listed in that script.

I did try your script in a new module and it worked there. So I don’t know what I’m doing wrong when I add it to mine.

Would you be able to clean it up for me? Make it nice and streamlined? It is a mess as is, but works…I would love to have your script in there too for the boulders.

That is something you have to do. You alone know what you want to achieve and have the whole module to test it. The best you can do to clean that up is to start over. It is also the best way to learn how it works.

Below is the basic, streamlined script with boulder throw implemented. Use it as a basis for your new script. Adapt each individual tag from your mix bag as a function and call that function from main when the tag matches.

Read comments in this code, double-click function names (in toolset)

// OnActivateItem script

// this function is called when item with tag
// BOULDER is activated
void ActivateBoulder()
{
    // get all data about the activation event
    object oUser = GetItemActivator();
    object oItem = GetItemActivated();
    object oTarget = GetItemActivatedTarget();
    location lTarget = GetItemActivatedTargetLocation();

    if(GetObjectType(oTarget) != OBJECT_TYPE_CREATURE)
    {
        // if target is not a creature
        FloatingTextStringOnCreature(
            "You could throw this at someone...", oUser);
    }
    else if(GetAbilityScore(oUser, ABILITY_STRENGTH) < 32)
    {
        // if user has less than 32 STR
        FloatingTextStringOnCreature(
            "You are not strong enough to throw this.", oUser);
    }
    else // user has STR >= 32 and is targeting a creature
    {
        // clear all actions of user
        AssignCommand(oUser, ClearAllActions());
        // make user fake-cast the boulder throw "spell"
        AssignCommand(oUser, ActionCastSpellAtObject(
            775, oTarget, METAMAGIC_ANY, TRUE, 0, 0, TRUE));
        // destroy boulder item in user's inventory
        AssignCommand(oUser, ActionDoCommand(DestroyObject(oItem)));
    }
}

// main function - script starts here
void main()
{
    // get tag of activated item
    string sTag = GetTag(GetItemActivated());

    if(sTag == "BOULDER")
    {
        // item with BOULDER tag is activated:
        // call ActivateBoulder() which handles it
        ActivateBoulder();
    }
    else if(sTag == "SOME_THING")
    {
        // some other thing is activated
        // call here function that handles it
        // (add this function yourself)
        //ActivateSomething();
    }
    else if(sTag == "SOME_OTHER_THING")
    {
        // yet another thing is activated
        // call here function that handles it
        // (add this function yourself)
        //ActivateSomethingElse();
    }
    else
    {
        // this happens if nothing from above matches the
        // item's tag - tell PC about it
        FloatingTextStringOnCreature(
            "Activated item with unknown tag " + sTag + "!",
            GetItemActivator());
    }
}

Try implementing something yourself, for example this (easy):

if (GetTag(oItem) == “fly_widget”)
{
AssignCommand(oActivator, ActionStartConversation(oActivator, “fly_control”, TRUE));
return;
}

would go to its own function:

void ActivateFlyWidget() // or whatever name you prefer
{
    object oUser = GetItemActivator();
    AssignCommand(oUser, ActionStartConversation(
        oUser, “fly_control”, TRUE));
}

which you call in main().

Also all that horse-related stuff could be reduced to a single function, dropping size of the script by 50%. But that’s another topic.

1 Like

Hi NWShacker

I really appreciate your help…but honestly…I am no script writer…it is a foreign language to me.

Could you at least add the boulder script you made above to the end of my script from my module. I can’t seem to bridge the last command lines with the beginning of your script. I think it may do with at the top of my script it has this stuff:

//:://////////////////////////////////////////////////
    //:: Prototypes
    object oPC = GetItemActivator();
    object oItem = GetItemActivated();
    object oActivator = GetItemActivator();
    object oTarget = GetItemActivatedTarget();
    location lActivator = GetLocation(oActivator);
    string sItemTag = GetTag(oItem);
    object oPlayer = GetItemActivator();
    string sPlayer = GetPCPlayerName(oPlayer);

whereas yours has this:


    object oUser = GetItemActivator();
    object oItem = GetItemActivated();
    object oTarget = GetItemActivatedTarget();
    location lTarget = GetItemActivatedTargetLocation();

Is there conflicting stuff between the two?

All you have to do is try. You’ll see how easy it becomes after the first step.

If there is any, just change the corresponding variable names in my scripts to the ones you have in yours, i.e. change my oUser to oPC or whatever holds the result of GetItemActivator().

Dude…I seriously have been trying…nothing is working

I know this seems super easy for you…it’s like an engineer trying to explain something to a 3rd grader here. I have messed stuff up badly…tried redoing my script now several times…getting errors all the time. I give up. I guess I’ll just do without. Thanks anyways.

This was my last attempt to blend your script to the end of my script above I posted (parts 1 and 2):


//staff of dancing
   }
  object oUsed = GetItemActivated();
  if (GetTag(oUsed) == "STAFFOFDANCING")
    {
       object oUser = GetItemActivator();
       if (GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oUser) != oUsed)
       {
            SendMessageToPC(oUser, "You must equip the staff before you can use its special power.");
       }else{
       DestroyObject(oUsed);
       location mySummon = GetLocation(oUser);
       effect eAppear = EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_3);
       object oStaff = CreateObject(OBJECT_TYPE_CREATURE, "eas_staffdance", mySummon, TRUE);
       mySummon = GetLocation(oStaff);
       ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eAppear, mySummon, 1.5);
       SetIsTemporaryFriend(oUser,oStaff,FALSE);
       SetLocalInt(oStaff, "TIMER", 6);
       SetLocalObject(oStaff, "OWNER", oUser);
              return;
        }
      }
   {

 // OnActivateItem script

// this function is called when item with tag
// BOULDER is activated
  void ActivateBoulder()
{
    // get all data about the activation event
    object oUser = GetItemActivator();
    object oItem = GetItemActivated();
    object oTarget = GetItemActivatedTarget();
    location lTarget = GetItemActivatedTargetLocation();

    if(GetObjectType(oTarget) != OBJECT_TYPE_CREATURE)
    {
        // if target is not a creature
        FloatingTextStringOnCreature(
            "You could throw this at someone...", oUser);
    }
    else if(GetAbilityScore(oUser, ABILITY_STRENGTH) < 32)
    {
        // if user has less than 32 STR
        FloatingTextStringOnCreature(
            "You are not strong enough to throw this.", oUser);
    }
    else // user has STR >= 32 and is targeting a creature
    {
        // clear all actions of user
        AssignCommand(oUser, ClearAllActions());
        // make user fake-cast the boulder throw "spell"
        AssignCommand(oUser, ActionCastSpellAtObject(
            775, oTarget, METAMAGIC_ANY, TRUE, 0, 0, TRUE));
        // destroy boulder item in user's inventory
        AssignCommand(oUser, ActionDoCommand(DestroyObject(oItem)));
        }

    }
 }

Error. ‘onactivateitem18’ did not compile. onactivateitem18.nss (1258): ERROR:
UNKNOWN STATE IN COMPILER

See I have tried 18 times now…pulling my hair out…ready to throw my laptop on the floor frustrated. UGH!!

Keep correcting stuff …then keep getting ERROR compiled at all sorts of lines on the script. Keep trying to bridge by using these thing-a-ma-jigs…

{
}

Dude…no scripter here…just taking guesses