Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
swtich (controlvariable)
{
case state:
instructions;
break;
default:
break;
}
You only have one case, so I guess you don't really need the break statement and default case. But I don't think I've ever seen a switch work without the case in {}. Still, you might want to add a default case with a command that logs the state of your control variable for debugging purposes.
Secondly, your logic looks a little wierd, I think you want something like:
if (!GetIsObjectValid(oTarget)) return;
if (oTarget==oShield) ...
else if (oTarget==oArmor) ...
else if (oTarget==oWeapon)...
else
{
FloatingTextStringOnCreature("The potion has no effect", oPC, FALSE);
}
A better option might be to test the item type of oTarget and see if it's armor, shield or a weapon. It does get a little messy since each type of weapon has it's own type. You'll also need to discriminate between ranged and melee weapons since ranged weapons don't have enhancement bonuses, they get attack bonuses instead.
you're not applying any effects, nor targeting the appropriate objects.
maybe you missed the point of the original post some how?
#include "x0_i0_position"
#include "x2_inc_switches"
#include "x2_inc_itemprop"
itemproperty DetermineBonus(object oTarget)
{
itemproperty ipBonus;
if (!GetIsObjectValid(oTarget)) return ItemPropertyVisualEffect(ITEM_VISUAL_HOLY);
int iItemType=GetBaseItemType(oTarget);
switch (iItemType)
{
case BASE_ITEM_ARMOR:
case BASE_ITEM_LARGESHIELD:
case BASE_ITEM_SMALLSHIELD:
case BASE_ITEM_TOWERSHIELD:
ipBonus=ItemPropertyACBonus(1);
break;
case BASE_ITEM_HEAVYCROSSBOW:
case BASE_ITEM_LIGHTCROSSBOW:
case BASE_ITEM_LONGBOW:
case BASE_ITEM_SHORTBOW:
case BASE_ITEM_SLING:
ipBonus=ItemPropertyAttackBonus(1);
break;
case BASE_ITEM_BASTARDSWORD:
case BASE_ITEM_BATTLEAXE:
case BASE_ITEM_CLUB:
case BASE_ITEM_DAGGER:
case BASE_ITEM_DART:
case BASE_ITEM_DIREMACE:
case BASE_ITEM_DOUBLEAXE:
case BASE_ITEM_DWARVENWARAXE:
case BASE_ITEM_GREATAXE:
case BASE_ITEM_GREATSWORD:
case BASE_ITEM_HALBERD:
case BASE_ITEM_HANDAXE:
case BASE_ITEM_HEAVYFLAIL:
case BASE_ITEM_KAMA:
case BASE_ITEM_KATANA:
case BASE_ITEM_KUKRI:
case BASE_ITEM_LIGHTFLAIL:
case BASE_ITEM_LIGHTHAMMER:
case BASE_ITEM_LIGHTMACE:
case BASE_ITEM_LONGSWORD:
case BASE_ITEM_MORNINGSTAR:
case BASE_ITEM_QUARTERSTAFF:
case BASE_ITEM_RAPIER:
case BASE_ITEM_SCIMITAR:
case BASE_ITEM_SHORTSPEAR:
case BASE_ITEM_SHORTSWORD:
case BASE_ITEM_SHURIKEN:
case BASE_ITEM_SICKLE:
case BASE_ITEM_THROWINGAXE:
case BASE_ITEM_TRIDENT:
case BASE_ITEM_TWOBLADEDSWORD:
case BASE_ITEM_WARHAMMER:
case BASE_ITEM_WHIP:
ipBonus=ItemPropertyEnhancementBonus(1);
break;
default:
ipBonus=ItemPropertyVisualEffect(ITEM_VISUAL_HOLY);
break;
}
return ipBonus;
}
void main()
{
//major variables
object oPC = OBJECT_SELF;
object oTarget = GetItemActivatedTarget();
effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_POSITIVE);
effect eVis = EffectVisualEffect(VFX_IMP_AC_BONUS);
int nDur = 10;
int nEvent = GetUserDefinedItemEventNumber(); //Which event triggered this
switch (nEvent)
{
case X2_ITEM_EVENT_ACTIVATE:
// * This code runs when the Unique Power property of the item is used
// * Note that this event fires for PCs only
oPC = GetItemActivator(); // The player who activated the item
itemproperty ipBonus=DetermineBonus(oTarget);
if (GetItemPropertyType(ipBonus)==ITEM_PROPERTY_VISUALEFFECT)
{
FloatingTextStringOnCreature("The potion has no effect", oPC, FALSE);
return;
}
else
{
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oPC);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDur, oPC, RoundsToSeconds(nDur));
IPSafeAddItemProperty(oTarget, ipBonus, RoundsToSeconds(nDur), X2_IP_ADDPROP_POLICY_REPLACE_EXISTING, FALSE, TRUE);
return;
}
break;
}
}