Hi, there. I'm very new to scripting and I've been sort of learning on my own while I build my module. At first I was just goofing off, but now I'm fairly serious about building the world.
Some of the things I've been trying to implement are a bit harder for me to comprehend, and I've only just started to get a handle on local integers.
With that being said, I'm trying to set up a script that uses local integers to handle a torch that burns for awhile, speaking a floating string to let you know how much longer it will last. When it reaches the integer demanded, it should unequip and destroy the torch.
It's nothing fancy, and I know that there are some burning torches scripts on the vault, but I'd really rather use my own scripts for as far as that can take me.
If there are any scriptors out there who have the time to take a look at my script and help me out, I'd really appreciate it, though I apologize that my scripting is a bit sloppy.
I can't seem to get the script to work at all and there are all sorts of problems with it.
A copy of my modified OnEquipItem script
--------------------------------
//::///////////////////////////////////////////////
//:: Example XP2 OnItemEquipped
//:: x2_mod_def_equ
//:: © 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*
Put into: OnEquip Event
*/
//:://////////////////////////////////////////////
//:: Created By: Georg Zoeller
//:: Created On: 2003-07-16
//:://////////////////////////////////////////////
//:: Modified By: Deva Winblood
//:: Modified On: April 15th, 2008
//:: Added Support for Mounted Archery Feat penalties
//:://////////////////////////////////////////////
#include "x2_inc_switches"
#include "x2_inc_intweapon"
#include "x3_inc_horse"
void main()
{
object oItem = GetPCItemLastEquipped();
object oPC = GetPCItemLastEquippedBy();
// -------------------------------------------------------------------------
// Intelligent Weapon System
// -------------------------------------------------------------------------
if (IPGetIsIntelligentWeapon(oItem))
{
IWSetIntelligentWeaponEquipped(oPC,oItem);
// prevent players from reequipping their weapon in
if (IWGetIsInIntelligentWeaponConversation(oPC))
{
object oConv = GetLocalObject(oPC,"X2_O_INTWEAPON_SPIRIT");
IWEndIntelligentWeaponConversation(oConv, oPC);
}
else
{
//------------------------------------------------------------------
// Trigger Drain Health Event
//------------------------------------------------------------------
if (GetLocalInt(oPC,"X2_L_ENSERRIC_ASKED_Q3")==1)
{
ExecuteScript ("x2_ens_dodrain",oPC);
}
else
{
IWPlayRandomEquipComment(oPC,oItem);
}
}
}
// -------------------------------------------------------------------------
// Mounted benefits control
// -------------------------------------------------------------------------
if (GetWeaponRanged(oItem))
{
SetLocalInt(oPC,"bX3_M_ARCHERY",TRUE);
HORSE_SupportAdjustMountedArcheryPenalty(oPC);
}
// -------------------------------------------------------------------------
// 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_EQUIP);
int nRet = ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
if (nRet == X2_EXECUTE_SCRIPT_END)
{
return;
}
}
{
object oItem = GetPCItemLastEquipped();
if (GetTag(oItem) == "NW_IT_TORCH001")
if (!GetIsPC(oPC)) return;
if (GetLocalInt(oPC, "burningtorch")== 6)
{
SetLocalInt(oPC, "burningtorch", 3);
}
if (GetLocalInt(oPC, "burningtorch")== 5)
{
SetLocalInt(oPC, "burningtorch", 2);
}
if (GetLocalInt(oPC, "burningtorch")== 4)
{
SetLocalInt(oPC, "burningtorch", 1);
}
if (GetLocalInt(oPC, "burningtorch")== 3)
{
FloatingTextStringOnCreature("You light a torch.", oPC);
}
if (GetLocalInt(oPC, "burningtorch")== 2)
{
FloatingTextStringOnCreature("Your torch dims a little.", oPC);
}
if (GetLocalInt(oPC, "burningtorch")== 1)
{
FloatingTextStringOnCreature("Your torch is almost spent.", oPC);
}
if (GetLocalInt(oPC, "burningtorch")== 7)
{
AssignCommand(oPC, ActionUnequipItem(GetItemPossessedBy(OBJECT_SELF, "nw_burning_torch")));
}
if (GetLocalInt(oPC, "burningtorch")== 7)
{
oItem = GetItemPossessedBy(oPC, "nw_burning_torch");
}
if (GetIsObjectValid(oItem))
DestroyObject(oItem);
if (GetLocalInt(oPC, "burningtorch")== 7)
{
FloatingTextStringOnCreature("Your torch goes out.", oPC);
}
if (GetLocalInt(oPC, "burningtorch")== 0)
{
SetLocalInt(oPC, "burningtorch", 3);
}
DelayCommand(100.0, SetLocalInt(oPC, "burningtorch", 2));
DelayCommand(100.0, SetLocalInt(oPC, "burningtorch", 1));
DelayCommand(100.0, SetLocalInt(oPC, "burningtorch", 7));
}
}
----------------------------------------------
A copy of my modified OnUnEquipItem script.
------------------------------------------------
//::///////////////////////////////////////////////
//:: Example XP2 OnItemEquipped
//:: x2_mod_def_unequ
//:: © 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*
Put into: OnUnEquip Event
*/
//:://////////////////////////////////////////////
//:: Created By: Georg Zoeller
//:: Created On: 2003-07-16
//:://////////////////////////////////////////////
//:: Modified By: Deva Winblood
//:: Modified On: April 15th, 2008
//:: Added Support for Mounted Archery Feat penalties
//:://////////////////////////////////////////////
#include "x2_inc_switches"
#include "x2_inc_intweapon"
#include "x3_inc_horse"
void main()
{
object oItem = GetPCItemLastUnequipped();
object oPC = GetPCItemLastUnequippedBy();
// -------------------------------------------------------------------------
// Intelligent Weapon System
// -------------------------------------------------------------------------
if (IPGetIsIntelligentWeapon(oItem))
{
IWSetIntelligentWeaponEquipped(oPC,OBJECT_INVALID);
IWPlayRandomUnequipComment(oPC,oItem);
}
// -------------------------------------------------------------------------
// Mounted benefits control
// -------------------------------------------------------------------------
if (GetWeaponRanged(oItem))
{
DeleteLocalInt(oPC,"bX3_M_ARCHERY");
HORSE_SupportAdjustMountedArcheryPenalty(oPC);
}
// -------------------------------------------------------------------------
// 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_UNEQUIP);
int nRet = ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
if (nRet == X2_EXECUTE_SCRIPT_END)
{
return;
}
}
{
object oItem = GetPCItemLastUnequipped();
oItem = GetPCItemLastUnequipped();
if (GetTag(oItem) == "nw_burning_torch")
if (!GetIsPC(oPC)) return;
if (GetLocalInt(oPC, "burningtorch")== 3)
{
SetLocalInt(oPC, "burningtorch", 6);
}
if (GetLocalInt(oPC, "burningtorch")== 2)
{
SetLocalInt(oPC, "burningtorch", 5);
}
if (GetLocalInt(oPC, "burningtorch")== 1)
{
SetLocalInt(oPC, "burningtorch", 4);
}
FloatingTextStringOnCreature("You douse your torch.", oPC);
}
}
Modifié par Herrlichkeit, 31 mai 2011 - 12:15 .