Hey, so this is my basic idea that works - obviously for only one option:
// Spawn a raven at the end of the spell projectile
void main()
{
string sResRef0 = "fx_amb_raven";// ResRef of creature to spawn
string sResRef1 = "fx_ambpeck_raven";
location lLoc = GetSpellTargetLocation();
object oRaven = CreateObject(OBJECT_TYPE_PLACED_EFFECT, sResRef1, lLoc);
}
I would like to see the resref0 and resref1 be randomly selected only once for the placement at lLoc.
lLoc is in reality a spell impact location duplicated on 16 iPoints. The script that manages that is this:
// Trigger the raven spell to fire the
// flying raven projectile from a random
// point at the edge of the area
#include "x0_i0_position"
location RandomSource(object oTrigger);
void main()
{
int iSpellID = 1302;// Row number in spells.2DA
object oTrigger = GetExitingObject();
object oPC = GetFirstPC();
if (!GetFactionEqual(oTrigger, oPC))
return;// Abort if not a faction member
location lTarget = GetRandomLocation(GetArea(oTrigger), oTrigger, 5.0);
lTarget = CalcSafeLocation(oTrigger, lTarget, 5.0, TRUE, FALSE);
vector vPosition = GetPositionFromLocation(lTarget);
location lSource = RandomSource(oTrigger);
object oSource = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_ipoint ",lSource);
float fDirection = GetFacing(oSource);
//lTarget = Location(GetArea(oTrigger), vPosition, fDirection);
int nWp_Raven_Number = 1;
while(oPC != OBJECT_INVALID && nWp_Raven_Number < 16)
{
object oTarget = GetWaypointByTag("wp_raven_" + IntToString(nWp_Raven_Number));
location lTarget = GetLocation(oTarget);
AssignCommand(oSource, ActionCastSpellAtLocation(iSpellID, lTarget, METAMAGIC_NONE, TRUE, PROJECTILE_PATH_TYPE_BALLISTIC_THROWN));
nWp_Raven_Number += 1;
}
DestroyObject(oSource, 10.0);
}
location RandomSource(object oTrigger)
{
object oArea = GetArea(oTrigger);
vector vPosition = GetPosition(oTrigger);
float fZ = vPosition.z + 20.0 + IntToFloat(Random(10));
float fX;
float fY;
int nHeight = GetAreaSize(AREA_HEIGHT, oArea);
int nWidth = GetAreaSize(AREA_WIDTH, oArea);
float fXMax = IntToFloat(nWidth * 5);
float fYMax = IntToFloat(nHeight * 5);
if (d2(1) == 1)// X axis
{
fY = 1.0;
if(d2(1) == 2) fY = fYMax - 1.0;
fX = IntToFloat(Random(FloatToInt(fXMax)));
}
else// Y axis
{
fX = 1.0;
if(d2(1) == 2) fX = fXMax - 1.0;
fY = IntToFloat(Random(FloatToInt(fYMax)));
}
vector vSource = Vector(fX, fY, fZ);
location lSource = Location(oArea, vSource, 0.0);
return lSource;
}
so determining the impact placed effect resref of either resref0 or resref1 needs to be determined somewhat randomly, as I know random is not truly random.
This is a puzzle and I am having trouble with managing the logic and the associated math that goes with it.
Does anyone know how to solve this?