@Nizidramaniit
Grenades use the CAST SPELL property… so you must create/define any new spell in the spells.2da, which can then make use of the DoGrenade function.
Alternatively, edit one of the existing grenade scripts to intercept the TAG of your item and pass any new DoGrenade properties you need.
E.g. An example of one I have edited (x0_s3_alchem) for my own use …
IMPORTANT: This will NOT compile for anyone as it stands, as it uses my own include, but I hope you get the picture.
//::///////////////////////////////////////////////
//:: Alchemists fire // Rewritten by Lance Botelle for the Althéa Campaign.
//:: x0_s3_alchem
//:: Copyright (c) 2002 Bioware Corp.
//:://////////////////////////////////////////////
/*
Grenade.
Fires at a target. If hit, the target takes
direct damage. If missed, all enemies within
an area of effect take splash damage.
HOWTO:
- If target is valid attempt a hit
- If miss then MISS
- If hit then direct damage
- If target is invalid or MISS
- have area of effect near target
- everyone in area takes splash damage
*/
//:://////////////////////////////////////////////
//:: Created By: Brent
//:: Created On: September 10, 2002
//:://////////////////////////////////////////////
//:: GZ: Can now be used to coat a weapon with fire.
//:: JSH-OEI 12/4/08: Fixed bug where damage bonus wasn't applying to weapon.
#include "X2_I0_SPELLS"
#include "x2_inc_spellhook"
#include "alb_functions_unique"
void AddFlamingEffectToWeapon(object oTarget, float fDuration, int DamageBonus)
{
IPSafeAddItemProperty(oTarget, ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_FIRE, DamageBonus), fDuration, X2_IP_ADDPROP_POLICY_KEEP_EXISTING);
IPSafeAddItemProperty(oTarget, ItemPropertyVisualEffect(ITEM_VISUAL_FIRE), fDuration,X2_IP_ADDPROP_POLICY_KEEP_EXISTING,FALSE,TRUE);
// ALLOW DESCRIPTION UPDATE
DeleteLocalString(oTarget, "ITEMDECS");
}
void main()
{
if (!X2PreSpellCastCode())
{
// If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
return;
}
int nDmg; int nSplashDmg; int nDuration; int DamageBonus;
object oItem = GetSpellCastItem();
object oSource = OBJECT_SELF;
string sTag = GetTag(oItem);
//SendMessageToAllPCs(" 1 >>>> " + sTag);
//SendMessageToAllPCs(" 2 >>>> " + GetFirstName(oSource));
//////////////////////////////////////////////////////////////////////////
// SOURCE CREATED (SCREAT BONUS MODULE2)
//////////////////////////////////////////////////////////////////////////
int iSOURCE = GetLocalInt(oItem, "SCREATWEAPONBONUS");
// ELSE STORED INSIDE ALB_AI_GRENADETHROW SCRIPT FROM NPC THROW
sTag = GetStringLowerCase(sTag);
// FOR TRAPS (RECALL LEVEL FOR OBSIDIAN KLUDGE)
if(sTag == "")
{
int nLevel = GetLocalInt(oSource, "NWN2_PROJECTILE_TRAP_CASTER_LEVEL");
if(nLevel < 6){sTag = "x1_wmgrenade002";}
else if(nLevel < 10){sTag = "n2_it_alch_2";}
else if(nLevel < 15){sTag = "n2_it_alch_3";}
else if(nLevel < 20){sTag = "n2_it_alch_4";}
//SendMessageToAllPCs(" 3 >>>> " + sTag);
}
//SendMessageToAllPCs(" FINAL >>>> " + sTag);
if (sTag == "x1_wmgrenade002"){nDmg = d6(1); nSplashDmg = 1; nDuration = d4(4); DamageBonus = IP_CONST_DAMAGEBONUS_1d4;}
else if (sTag == "n2_it_alch_2"){nDmg = d8(1); nSplashDmg = 2; nDuration = d4(6); DamageBonus = IP_CONST_DAMAGEBONUS_1d6;}
else if (sTag == "n2_it_alch_3"){nDmg = d10(1); nSplashDmg = d4(1); nDuration = d6(6); DamageBonus = IP_CONST_DAMAGEBONUS_1d8;}
else if (sTag == "n2_it_alch_4"){nDmg = d6(2); nSplashDmg = d4(1) + 1; nDuration = d6(8); DamageBonus = IP_CONST_DAMAGEBONUS_1d10;}
effect eVis = EffectVisualEffect(VFX_COM_HIT_FIRE);
// effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_POSITIVE);
object oTarget = GetSpellTargetObject();
int nTarget = GetObjectType(oTarget);
if(nTarget == OBJECT_TYPE_ITEM)
{
if(IPGetIsMeleeWeapon(oTarget) && (GetItemInSlot(INVENTORY_SLOT_RIGHTHAND) == oTarget || GetItemInSlot(INVENTORY_SLOT_LEFTHAND) == oTarget))
{
SignalEvent(OBJECT_SELF, EventSpellCastAt(OBJECT_SELF, GetSpellId(), FALSE));
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, GetItemPossessor(oTarget));
// ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDur, GetItemPossessor(oTarget), RoundsToSeconds(nDuration));
AddFlamingEffectToWeapon(oTarget, RoundsToSeconds(nDuration), DamageBonus);
return;
}
else if(GetItemPossessor(oTarget)!= OBJECT_INVALID)
{
// FloatingTextStrRefOnCreature(100944,OBJECT_SELF); // * Only melee weapons can be coated with alchemist's fire! *
SetNoticeTextAll(CRED + "<<< Only equipped melee weapons can be coated >>>", 1, 1, OBJECT_SELF);
}
}
// ELSE JUST DO GRENADE
else
{
SendMessageToAllPCs(CWHITE + GetFirstName(OBJECT_SELF) + CORCHID + " throws a grenade: Alchemist's fire!");
LBDoGrenade(nDmg, nSplashDmg, VFX_HIT_SPELL_FIRE, VFX_HIT_AOE_FIRE, DAMAGE_TYPE_FIRE, RADIUS_SIZE_MEDIUM, OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE, RACIAL_TYPE_ALL, iSOURCE);
}
}