public static uint _SpawnObject(string sResRef, int nObjectType, uint oWP, NWLocation lLoc, int nFlags, int nAlternate, CLRScriptBase s) { // if the object is not being spawned at it's waypoint location, we need to make sure // the actual spawn-in location isn't violating the "in PC sight" guidelines. if ((nAlternate != CLRScriptBase.FALSE) && ((nFlags & _SPAWN_FLAGS_IN_PC_SIGHT) == 0)) { uint oNeighbor = s.GetNearestCreatureToLocation(CLRScriptBase.CREATURE_TYPE_PLAYER_CHAR, CLRScriptBase.PLAYER_CHAR_IS_PC, lLoc, 1, -1, -1, -1, -1); if (s.GetIsObjectValid(oNeighbor) == CLRScriptBase.FALSE && (s.GetDistanceBetweenLocations(lLoc, s.GetLocation(oNeighbor)) <= PC_PERCEPTION_RANGE)) { // ACR_GetPCVisualRange() )) { return CLRScriptBase.OBJECT_INVALID; } if (GetPrespawnPrediction(s) == CLRScriptBase.FALSE) { uint oTestWP = s.GetNearestObjectToLocation(CLRScriptBase.OBJECT_TYPE_WAYPOINT, lLoc, 1); int nWP_Index = 1; while ((oTestWP != CLRScriptBase.OBJECT_INVALID) && (s.GetDistanceBetweenLocations(lLoc, s.GetLocation(oTestWP)) <= PC_PERCEPTION_RANGE)) { // ACR_GetPC_VisualRange() )) { if (s.GetTag(oTestWP) == "ACR_SA_WP") { return CLRScriptBase.OBJECT_INVALID; } else { nWP_Index = nWP_Index + 1; oTestWP = s.GetNearestObjectToLocation(CLRScriptBase.OBJECT_TYPE_WAYPOINT, lLoc, nWP_Index); } } } } uint oSpawned = s.CreateObject(nObjectType, sResRef, lLoc, nFlags & _SPAWN_FLAGS_WITH_ANIMATION, ""); // Check to make sure it spawned ok, print an error and exit if not. if (s.GetIsObjectValid(oSpawned) == CLRScriptBase.FALSE) { return CLRScriptBase.OBJECT_INVALID; } // If it should be in stealth mode, place it there. if ((nFlags & _SPAWN_IN_STEALTH) == _SPAWN_IN_STEALTH) { s.SetActionMode(oSpawned, CLRScriptBase.ACTION_MODE_STEALTH, 1); } // If it should be in detect mode, place it there. if ((nFlags & _SPAWN_IN_DETECT) == _SPAWN_IN_DETECT) { s.SetActionMode(oSpawned, CLRScriptBase.ACTION_MODE_DETECT, 1); } // If this creature should buff himself, do it. if ((nFlags & _SPAWN_BUFFED) == _SPAWN_BUFFED) { ActivateLongTermBuffs(oSpawned, s); } // Play the spawn animation. s.PlayAnimation(s.GetLocalInt(oWP, _WP_SPAWN_ANIMATION), 1.0f, 0.0f); // Play the spawn in VFX. s.ApplyEffectAtLocation(CLRScriptBase.DURATION_TYPE_INSTANT, s.EffectVisualEffect(s.GetLocalInt(oWP, _WP_SPAWN_IN_VFX), CLRScriptBase.FALSE), s.GetLocation(oSpawned), 0.0f); // Play the spawn in SFX. s.AssignCommand(oSpawned, delegate { s.PlaySound(s.GetLocalString(oWP, _WP_SPAWN_IN_SFX), CLRScriptBase.FALSE); }); // Determine facing. if ((nFlags & _SPAWN_FLAGS_RANDOM_FACING) == _SPAWN_FLAGS_RANDOM_FACING) { // Spawn facing is random. s.AssignCommand(oSpawned, delegate { s.SetFacing(new Random().Next() * 360.0f, CLRScriptBase.FALSE); }); } // Colorize name if needed. if (s.GetLocalString(oSpawned, ACR_COLOR_NAME) != "") { s.SetFirstName(oSpawned, "<C='" + s.GetLocalString(oSpawned, ACR_COLOR_NAME) + "'>" + s.GetName(oSpawned) + "</C>"); s.SetLastName(oSpawned, ""); } // Run the spawn-in scripts, if any. int i = 1; while (true) { string sScript = s.GetLocalString(oWP, _WP_SPAWN_IN_SCRIPT_ARRAY + s.IntToString(i)); if (sScript == "") { break; } s.ExecuteScript(sScript, oSpawned); i++; } _AddObjectToSpawnPoint(oWP, oSpawned, s); return oSpawned; }
public static void SetLocalArrayObject(uint oObject, string sVarName, int nIndex, uint oValue, CLRScriptBase s) { s.SetLocalObject(oObject, sVarName + s.IntToString(nIndex), oValue); }