Gaming
 

Firebomb

From NWNWiki

[edit] Firebomb

[edit] What it does

If a PC approaches an object, a "bomb" goes off at a target elsewhere in the vicinity, damaging those nearby. This seemed useful to me because I wanted to simulate a terrorist act without actually hurting the PCs.


[edit] Script Notes

The process involves creating an invisible object (flag it as "plot," and make sure it is not useable), placing the script in the object's OnHeartbeat, and creating a waypoint "Bullseye" to act as the target point. This last part is not strictly necessary if the invisible object is flagged "plot," but if you want the effect to go off further away from the object, this might be useful. If there are any placeables in the area you want to destroy as well, be sure to change their factions from hostile to something else, or change the faction of the invisible object, or disable the PvP safety.

I have done some testing, and Delayed Blast Fireball gives the best effect. Feel free to mess around with it if you want a stinking cloud or some such.

//Sets up a counter so that the bomb only fires once
int nAlreadyFired = GetLocalInt(OBJECT_SELF,"COUNTER");
void main()
{
    //Check to see whether there is a PC nearby
    object oNear = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_IS_PC);
    //Be sure to set the distance to your liking, but
    //remember that too close may fry the PC
    if (GetDistanceToObject(oNear) < 15.0f)
        {
        if (nAlreadyFired == 0)
            {
            //Cast the spell at the Bullseye waypoint
            object oTarget = GetWaypointByTag("Bullseye");
            ActionCastSpellAtObject(SPELL_DELAYED_BLAST_FIREBALL,oTarget,METAMAGIC_NONE,TRUE);
            //Create a short-lived followup fire and
            //leave a scorchmark
            object fire = CreateObject(OBJECT_TYPE_PLACEABLE,"plc_flamelarge",GetLocation(oTarget));
            DestroyObject(fire,IntToFloat(d10() + 10));
            object scorch = CreateObject(OBJECT_TYPE_PLACEABLE,"plc_weathmark",GetLocation(oTarget));
            //Update the counter to ensure bomb does not go
            //off again on next heartbeat.
            SetLocalInt(OBJECT_SELF,"COUNTER",nAlreadyFired +1);
            }
        }
}