TurnUndead is a little more complicated that just applying the effect of turning. So I lifted the vanilla script from “nw_s2_turndead” and edited it a little. I made the level of the bomb 6. You can change those numbers at the top if you wish. I also made it not effect other things, like planars. I think in that section, you can change the number for bonus turning types to 1 or TRUE.
Truth-be-told - this compiled, but I have not tried it out. If I get a chance, I will run it. Oh, I also put in the DoGrenade function which targets an area. This is from the Fire or Acid bomb script.
Edit - I was able to test my original attempt and fixed a pile of errors. The below worked and provides feedback when something is turned. This would be saved as the tag-based “bone_bomb” script.
#include "x2_inc_switches"
#include "x0_i0_spells"
void TurnUndead(object oPC, location lLoc)
{
//SendMessageToPC(oPC, "Turning Undead with Bone Bomb");
int nTotalLevel = 6;//GetHitDice(OBJECT_SELF);
int nTurnLevel = 6;//nClericLevel;
int nClassLevel = 6;//nClericLevel;
int nTurnCheck = d20();//
//SendMessageToPC(oPC, "nTurnCheck = "+IntToString(nTurnCheck));
int nTurnHD = d6(2);
//Flags for bonus turning types
int nElemental = 0;//GetHasFeat(FEAT_AIR_DOMAIN_POWER) + GetHasFeat(FEAT_EARTH_DOMAIN_POWER) + GetHasFeat(FEAT_FIRE_DOMAIN_POWER) + GetHasFeat(FEAT_WATER_DOMAIN_POWER);
int nVermin = 0;//GetHasFeat(FEAT_PLANT_DOMAIN_POWER);// + GetHasFeat(FEAT_ANIMAL_COMPANION);
int nConstructs = 0;//GetHasFeat(FEAT_DESTRUCTION_DOMAIN_POWER);
int nGoodOrEvilDomain = 0;//GetHasFeat(FEAT_GOOD_DOMAIN_POWER) + GetHasFeat(FEAT_EVIL_DOMAIN_POWER);
int nPlanar = 0;//GetHasFeat(854);
//Determine the maximum HD of the undead that can be turned.
if(nTurnCheck <= 0)
{
nTurnLevel -= 4;
}
else if(nTurnCheck >= 1 && nTurnCheck <= 3)
{
nTurnLevel -= 3;
}
else if(nTurnCheck >= 4 && nTurnCheck <= 6)
{
nTurnLevel -= 2;
}
else if(nTurnCheck >= 7 && nTurnCheck <= 9)
{
nTurnLevel -= 1;
}
else if(nTurnCheck >= 10 && nTurnCheck <= 12)
{
//Stays the same
}
else if(nTurnCheck >= 13 && nTurnCheck <= 15)
{
nTurnLevel += 1;
}
else if(nTurnCheck >= 16 && nTurnCheck <= 18)
{
nTurnLevel += 2;
}
else if(nTurnCheck >= 19 && nTurnCheck <= 21)
{
nTurnLevel += 3;
}
else if(nTurnCheck >= 22)
{
nTurnLevel += 4;
}
//SendMessageToPC(oPC, "nTurnLevel = "+IntToString(nTurnLevel));
//Gets all creatures in a 20m radius around the caster and turns them or not. If the creatures
//HD are 1/2 or less of the nClassLevel then the creature is destroyed.
int nCnt = 1;
int nHD, nRacial, nHDCount, bValid, nDamage;
nHDCount = 0;
effect eVis = EffectVisualEffect(VFX_IMP_SUNSTRIKE);
effect eVisTurn = EffectVisualEffect(VFX_DUR_MIND_AFFECTING_FEAR);
effect eDamage;
effect eTurned = EffectTurned();
effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_NEGATIVE);
effect eLink = EffectLinkEffects(eVisTurn, eTurned);
eLink = EffectLinkEffects(eLink, eDur);
effect eDeath = SupernaturalEffect(EffectDeath(TRUE));
effect eImpactVis = EffectVisualEffect(VFX_FNF_LOS_HOLY_30);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eImpactVis, GetLocation(OBJECT_SELF));
//Get nearest enemy within 10m (30ft)
object oBoom = CreateObject(OBJECT_TYPE_WAYPOINT, "nw_waypoint001", lLoc);
object oTarget = GetNearestCreature(CREATURE_TYPE_IS_ALIVE, TRUE , oBoom, nCnt,CREATURE_TYPE_PERCEPTION , PERCEPTION_SEEN);
while(GetIsObjectValid(oTarget) && nHDCount < nTurnHD && GetDistanceToObject(oTarget) <= 10.0)
{
//SendMessageToPC(oPC, GetName(oTarget)+" attempted to be turned.");
if(!GetIsFriend(oTarget))
{
nRacial = GetRacialType(oTarget);
if (nRacial == RACIAL_TYPE_OUTSIDER )
{
if (nPlanar)
{
//Planar turning decreases spell resistance against turning by 1/2
nHD = GetHitDice(oTarget) + (GetSpellResistance(oTarget) /2) + GetTurnResistanceHD(oTarget);
}
else
{
nHD = GetHitDice(oTarget) + (GetSpellResistance(oTarget) + GetTurnResistanceHD(oTarget) );
}
}
else //(full turn resistance)
{
nHD = GetHitDice(oTarget) + GetTurnResistanceHD(oTarget);
}
if(nHD <= nTurnLevel && nHD <= (nTurnHD - nHDCount))
{
//Check the various domain turning types
if(nRacial == RACIAL_TYPE_UNDEAD)
{
bValid = TRUE;
}
else if (nRacial == RACIAL_TYPE_VERMIN && nVermin > 0)
{
bValid = TRUE;
}
else if (nRacial == RACIAL_TYPE_ELEMENTAL && nElemental > 0)
{
bValid = TRUE;
}
else if (nRacial == RACIAL_TYPE_CONSTRUCT && nConstructs > 0)
{
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELLABILITY_TURN_UNDEAD));
nDamage = d3(nTurnLevel);
eDamage = EffectDamage(nDamage, DAMAGE_TYPE_MAGICAL);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
DelayCommand(0.01, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oTarget));
nHDCount += nHD;
}
else if (nRacial == RACIAL_TYPE_OUTSIDER && (nGoodOrEvilDomain+nPlanar > 0) )
{
bValid = TRUE;
}
// * if wearing gauntlets of the lich,then can be turned
else if (GetIsObjectValid(GetItemPossessedBy(oTarget, "x2_gauntletlich")) == TRUE)
{
if (GetTag(GetItemInSlot(INVENTORY_SLOT_ARMS)) == "x2_gauntletlich")
{
bValid = TRUE;
}
}
//Apply results of the turn
if( bValid == TRUE)
{
SendMessageToPC(oPC, GetName(oTarget)+" was turned by the bomb!");
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
if (nPlanar>0 && nRacial == RACIAL_TYPE_OUTSIDER)
{
effect ePlane = EffectVisualEffect(VFX_IMP_DIVINE_STRIKE_HOLY);
ApplyEffectToObject(DURATION_TYPE_INSTANT, ePlane, oTarget);
}
//if(IntToFloat(nClassLevel)/2.0 >= IntToFloat(nHD))
//{
if((nClassLevel/2) >= nHD)
{
if (nPlanar>0 && nRacial == RACIAL_TYPE_OUTSIDER)
{
effect ePlane2 = EffectVisualEffect(VFX_IMP_UNSUMMON);
ApplyEffectToObject(DURATION_TYPE_INSTANT, ePlane2, oTarget);
}
effect ePlane2 = EffectVisualEffect(VFX_IMP_DIVINE_STRIKE_HOLY);
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(oBoom, SPELLABILITY_TURN_UNDEAD));
//Destroy the target
DelayCommand(0.1f, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDeath, oTarget));
}
else
{
//Turn the target
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(oBoom, SPELLABILITY_TURN_UNDEAD));
AssignCommand(oTarget, ActionMoveAwayFromObject(oBoom, TRUE));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, RoundsToSeconds(nClassLevel + 5));
}
nHDCount = nHDCount + nHD;
}
}
bValid = FALSE;
}
nCnt++;
oTarget = GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE, oBoom, nCnt,CREATURE_TYPE_PERCEPTION , PERCEPTION_SEEN);
}
DestroyObject(oBoom, 1.0);//cleanup the target object
}
// The individual event handlers.
void OnActivate(object oItem, object oTarget, location lTarget, object oActivator);
// The main function.
void main()
{
int nEvent = GetUserDefinedItemEventNumber();
// Spells might continue to their spell scripts. All other events are
// completely handled by this script.
if ( nEvent != X2_ITEM_EVENT_SPELLCAST_AT )
SetExecutedScriptReturnValue();
// Determine which event triggered this script's execution.
switch ( nEvent )
{
// Item was activated ("activate item" or "unique power").
case X2_ITEM_EVENT_ACTIVATE:
OnActivate(GetItemActivated(), GetItemActivatedTarget(),
GetItemActivatedTargetLocation(), GetItemActivator());
break;
}
}
// -----------------------------------------------------------------------------
// oItem was activated ("activate item" or "unique power").
// Run by the module.
void OnActivate(object oItem, object oTarget, location lTarget, object oActivator)
{
object oPC = oActivator;
location lLoc = lTarget;//GetItemActivatedTargetLocation();
object oItemActivate = oTarget;//GetItemActivatedTarget();
TurnUndead(oPC, lLoc);//GetSpellTargetLocation());
DelayCommand(0.3, DoGrenade(d6(1),1, VFX_IMP_FLAME_M, VFX_FNF_FIREBALL,DAMAGE_TYPE_FIRE,RADIUS_SIZE_MEDIUM, OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE));
DelayCommand(0.3, ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectAreaOfEffect(AOE_PER_FOGFIRE), GetSpellTargetLocation(), RoundsToSeconds(5)));
effect eBombFX = EffectVisualEffect(VFX_FNF_MYSTICAL_EXPLOSION);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eBombFX, lLoc);
effect eDamage = EffectDamage(d6(), DAMAGE_TYPE_FIRE, DAMAGE_POWER_NORMAL);
effect eHurt = EffectVisualEffect(VFX_COM_HIT_FIRE);
DelayCommand(0.3, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oItemActivate));
DelayCommand(0.3, ApplyEffectToObject(DURATION_TYPE_INSTANT, eHurt, oItemActivate));
}