Author Sticky: Post Working Scripts Here
Pete2 Posted: Monday, 08 July 02:51AM
This script I used for calculating cone based ranges to the scales from the 3rd edition monster compendium. Specifically, I use it on the OnCombatRoundEnd, along with the Bioware code to create some effects not already in the game. My Aurak draconian breathes gas, d20 and blind, half vs fort save DC 17. Anyway the code needed to create the gas effect needs a location and thus, this is what the code is for.

Example (funny gas, paste into event or OnCombatRoundEnd):

NWScript:
//AI based cone edge location getter

    //by Peter J. Kos

    object oObject = GetLastHostileActor();

    float fScale = 5.0; //Distance 3rd edition Aurak Breath    

    vector vObject = GetPosition(oObject);

    vector vCenter = GetPosition(OBJECT_SELF);

    vector vDirection = vObject - vCenter;

    float fDirection = VectorMagnitude(vDirection);

    vDirection = (fScale / fDirection) * vDirection;

    float fDistance = VectorMagnitude(vDirection) / 2.0f;

    vector vTarget = VectorNormalize(vDirection) * fDistance + vCenter;

    location lTargetLocation = Location(GetArea(OBJECT_SELF), vTarget, GetFacing(OBJECT_SELF));

    //CreateObject(OBJECT_TYPE_PLACEABLE, "dl_chair", lTargetLocation, FALSE);

    //The rest of this code I'll include just for laughs, although you can write in your own spell effects and damage.

    ClearAllActions();

    SignalEvent(oObject, EventSpellCastAt(OBJECT_SELF, SPELLABILITY_CONE_ACID));

    ActionCastFakeSpellAtLocation(SPELLABILITY_CONE_ACID, lTargetLocation);