I'm trying to make an on enter script that spawns rocks at certain waypoints. There are several of the waypoints in the area, and I would like the script to check each waypoint, and have a 5% chance of spawning a rock. However the script is not working as it should, and not spawning any rocks, even if I set the percentage to 99%.
Here is the script. Any help would be appreciated.
void main()
{
object oRock;
// Get the creature who triggered this event.
object oPC = GetEnteringObject();
// Only fire for (real) PCs.
if ( !GetIsPC(oPC) || GetIsDMPossessed(oPC) )
return;
// Only fire once.
if ( GetLocalInt(OBJECT_SELF, "RoseSpawnSilver") == 1 )
return;
SetLocalInt(OBJECT_SELF, "RoseSpawnSilver", 1);
string sAreaTag = GetTag(GetArea(oPC));
if (sAreaTag == "McGrukkMines1A")
{
// If the PC's total level is at least 10.
if ( GetHitDice(oPC) >= 10 )
{
oRock == GetFirstObjectInArea(OBJECT_SELF);
{
if ( (GetIsObjectValid(oRock)) && (GetObjectType(oRock) == OBJECT_TYPE_WAYPOINT) )
{
if ( GetTag(oRock) == "WP_ROSE_ROCK" )
{
// If success on a 5% chance.
if ( Random(100) < 5 )
{
CreateObject(OBJECT_TYPE_PLACEABLE, "cnrrocksilv", GetLocation(oRock));
}
}
}
oRock == GetNextObjectInArea(OBJECT_SELF);
}
}
}
}