I am planning to add an underwater area to my module, however I am having some problems making potions of water breathing. I made the potions, and then I gave them the property: cast spell: unique power self only. I made some tag based scripts to run when the potions were activated. The tag script I made is an on activate script. It uses variables to determine when to run the damage script.
The damage script I made is an on enter script that does damage if the player has not drank a potion. However the potions did not work at all. There were no visual effects, and I took damage when entering the area trigger. I tried making a new item that wasn't a potion, and it worked fine.
My question is: How do I get an activate item script to work with a potion?
These are the scripts I used. I know using two scripts for activate item is not very efficient, but that is the way I know for now.
The event script:
#include "x2_inc_switches"
void main()
{
int nEvent =GetUserDefinedItemEventNumber();
switch (nEvent)
{
case X2_ITEM_EVENT_ACTIVATE:
ExecuteScript("ac_"+GetTag(GetItemActivated()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_EQUIP:
ExecuteScript("eq_"+GetTag(GetPCItemLastEquipped()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_UNEQUIP:
ExecuteScript("ue_"+GetTag(GetPCItemLastUnequipped())
, OBJECT_SELF); break;
case X2_ITEM_EVENT_ACQUIRE:
ExecuteScript("aq_"+GetTag(GetModuleItemAcquired()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_UNACQUIRE:
ExecuteScript("ua_"+GetTag(GetModuleItemLost()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_SPELLCAST_AT:
ExecuteScript("sp_"+GetTag(GetModuleItemLost()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_ONHITCAST:
ExecuteScript("on_"+GetTag(GetSpellCastItem()),
OBJECT_SELF); break;
}
}
This is my potion script. It adds a spell immunity so that it will show an icon to show that the potion effects are still active.
void main()
{
object oPC;
oPC = GetItemActivator();
int nInt;
nInt = GetLocalInt(oPC, "sot_waterbreath");
nInt += 1;
SetLocalInt(oPC, "sot_waterbreath", nInt);
object oTarget;
oTarget = oPC;
effect eEffect;
eEffect = EffectSpellImmunity(SPELL_COMBUST);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 180.0f);
//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_FNF_SMOKE_PUFF), oTarget);
else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SMOKE_PUFF), GetLocation(oTarget));
nInt = GetLocalInt(oPC, "sot_waterbreath");
nInt -= 1;
DelayCommand(180.0, SetLocalInt(oPC, "sot_waterbreath", nInt));
}
This is the script I used to cause damage to the player when not drinking a potion. There is a helm of water breathing too, which works fine, but it is a quest item and will not always be available. I made this script as an on enter script to test the items, however I think a heartbeat script for the area would be a better idea.
void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
if (GetTag(GetItemInSlot(INVENTORY_SLOT_HEAD, oPC)) == "sot_WaterBreathHelm")
return;
if (GetLocalInt(oPC, "sot_waterbreath")!= 0)
return;
effect eEffect;
eEffect = EffectDamage(100, DAMAGE_TYPE_DIVINE, DAMAGE_POWER_ENERGY);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oPC);
object oTarget;
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
int nInt;
nInt = GetObjectType(oTarget);
if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_PULSE_WATER), oTarget);
else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_PULSE_WATER), GetLocation(oTarget));
FloatingTextStringOnCreature("You are drowning!", oPC);
}
I made these scripts with the script generator, so there is probably some things that are not needed. Will these scripts work with potions, or should I just use items instead? I could not make an area heartbeat script with the script generator, so I could use some help with that.
I also encountered a problem with them not working in combat. Is it possible to modify the scripts to bypass the module on activate item script?
I looked at some of the script tutorials, but none of them mentioned potions or area heartbeat scripts.
Any help would be greatly appreciated.
Thank you.
Modifié par Sadira of Tyr, 19 juin 2011 - 06:51 .