#include "x2_inc_toollib" #include "prc_x2_itemprop" // * Shortcut function to upgrade the enhancement bonus of a weapon by the // * number specified in nUpgradeBy. If the resulting new enhancement bonus // * would be out of bounds (>+20), it will be set to +20 // * The enhancement bonus will upgrade any permanent existing enhancement bonus // * for its duration. Optional you can assing nVFX to be added to the weapon // * for the same duration. void GZIPTemporaryUpgradeWeaponEnhancementBonus(object oWeapon, int nUpgradeBy, float fDuration, int nVfx = -1); // ---------------------------------------------------------------------------- // Shortcut function to upgrade the enhancement bonus of a weapon by the // number specified in nUpgradeBy. If the resulting new enhancement bonus // would be out of bounds (>+20), it will be set to +20 // The enhancement bonus will upgrade any permanent existing enhancement bonus // for its duration. Optional you can assing nVFX to be added to the weapon // for the same duration // ---------------------------------------------------------------------------- void GZIPTemporaryUpgradeWeaponEnhancementBonus(object oWeapon, int nUpgradeBy, float fDuration, int nVfx = -1) { itemproperty ip = GetFirstItemProperty(oWeapon); int nCurrent = IPGetWeaponEnhancementBonus(oWeapon); int nNew = nCurrent + nUpgradeBy; if (nNew <1 ) { nNew = 1; } else if (nNew >20) { nNew = 20; } ip = ItemPropertyEnhancementBonus(nNew); AddItemProperty(DURATION_TYPE_TEMPORARY,ip,oWeapon,fDuration); if (nVfx > 0) { ip = ItemPropertyVisualEffect(nVfx); AddItemProperty(DURATION_TYPE_TEMPORARY,ip,oWeapon,fDuration); } } //sTag = the tag of the weapon which you have equip to get a warning when enemies are around //fDistance = is the maximum distance in metres the enemies have to be from the pc before the weapon begins to glow //eVisual = the visual effect that will be applied to the pc when an enemy is within fDistance //sWarning = the warningmessage the pc gets when an enemy is around void GlowingWeapon(string sTag, float fDistance, effect eVisual, string sWarning); void GlowingWeapon(string sTag, float fDistance, effect eVisual, string sWarning) { object oPC; oPC = GetFirstPC(); object oItem = GetObjectByTag("glow"); while(GetIsObjectValid(oPC) == TRUE) { if(GetDistanceBetween(GetNearestCreature(CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY, oPC), oPC) < fDistance && GetTag(GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC)) == sTag && GetIsObjectValid(GetNearestCreature(CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY, oPC)) == TRUE) { GZIPTemporaryUpgradeWeaponEnhancementBonus(oItem, 1, RoundsToSeconds(1), ITEM_VISUAL_HOLY); AssignCommand(oPC, SpeakString(sWarning)); } if(GetDistanceBetween(GetNearestCreature(CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY, oPC), oPC) < fDistance && GetTag(GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC)) == sTag && GetIsObjectValid(GetNearestCreature(CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY, oPC)) == TRUE) { GZIPTemporaryUpgradeWeaponEnhancementBonus(oItem, 1, RoundsToSeconds(1), ITEM_VISUAL_HOLY); AssignCommand(oPC, SpeakString(sWarning)); } oPC = GetNextPC(); } }