Asking about a conditional in a weird place amongst a spell impact : my logic is lapsing

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?

I’m not sure if I understand clearly what’s the problem here.
If you simply need to select which raven spawns randomly, then all you have to do is change the first script to this

void main()
{
	string sRAVEN = "fx_amb_raven";
	if (d20() > 10) sRAVEN = "fx_ambpeck_raven";
	location lLoc = GetSpellTargetLocation();
	object oRaven = CreateObject(OBJECT_TYPE_PLACED_EFFECT, sRAVEN, lLoc);
}

The second script seems very convoluted, and honestly I’m not even sure what it’s trying to achieve, I will just assume that it works for the intended purposes and that the issue here is just that the same type of raven kept spawning because of the first script.

Thanks! I see it now.

I am fairly certain the second script creates a random spawn point above and off to a random side from the oPC. I appears to work as the projectile models always come from a different compass point from above the PC.

Ya so I was WAAAAY over complicating it - I will not even try to show my symphony of error.
This is what I’ve decided to go with - it seems to distribute the different resrefs more evenly.


void main()
{
	string sResRef = "fx_amb_raven"; // ResRef of creature to spawn
	if (d20() % 2) sResRef = "fx_ambpeck_raven";
	location lLoc = GetSpellTargetLocation();
	object oRaven = CreateObject(OBJECT_TYPE_PLACED_EFFECT, sResRef, lLoc);
}