public override void Update1200() { var currentTime = MyAPIGateway.Session.GameDateTime; foreach (var npcGroup in npcGroups) { if (npcGroup.GroupSpawnTime + convoyExpiryTime < currentTime) { ModLog.DebugError("NPC group expired! Ordering to disband for passing time limit of " + convoyExpiryTime, npcGroup.GetPosition()); npcGroup.Expire(); } } }
private void SpawnUndergroundDefense(IMyPlayer player) { var playerPos = player.GetPosition(); var playerNaturalGravity = marsPlanet.GetGravityAtPoint(playerPos); var vng = playerNaturalGravity; vng.Normalize(); var surface = marsPlanet.GetClosestSurfacePointGlobal(player.GetPosition()); var belowsurface = Vector3D.Distance(playerPos, surface); // ModLog.Info("Below Surface=" + belowsurface.ToString("0.00")); var up = 50 + belowsurface; // 150m above the surface // var up = 150 + belowsurface; // 150m above the surface var locationToSpawn = playerPos + vng * -up; var naturalGravityAtSpawn = marsPlanet.GetGravityAtPoint(locationToSpawn); // DuckUtils.AddGpsToAllPlayers("Location to Spawn", "Above player", locationToSpawn); var spawnLocation = MyAPIGateway.Entities.FindFreePlace(locationToSpawn, 10, 20, 5, 10); if (spawnLocation.HasValue) { PrefabGrid bomb = PrefabGrid.GetBomb(); DuckUtils.SpawnInGravity(spawnLocation.Value, naturalGravityAtSpawn, RemoteControl.OwnerId, bomb.PrefabName, bomb.InitialBeaconName); //DEBUG // DuckUtils.AddGpsToAllPlayers("Bomb Spawn", "bomb for player", spawnLocation.Value); // ModLog.Info("Spawning Bomb!"); } else { ModLog.DebugError("Couldn't spawn bomb!", locationToSpawn); } }
private void SpawnHelperPatrol(IMyPlayer player) { var playerPos = player.GetPosition(); var playerNaturalGravity = marsPlanet.GetGravityAtPoint(playerPos); var perpendicularDistance = MyUtils.GetRandomPerpendicularVector(ref playerNaturalGravity) * 400; //4km away NOTE: since mars NG is not 1.0, it's NOT 4km var locationToSpawnPatrol = playerPos + perpendicularDistance + playerNaturalGravity * -200f; // 2km up var naturalGravityAtSpawn = marsPlanet.GetGravityAtPoint(locationToSpawnPatrol); var spawnLocation = MyAPIGateway.Entities.FindFreePlace(locationToSpawnPatrol, 10, 20, 5, 10); // ModLog.Info("Spawning helper patrol. perpD=" + perpendicularDistance.ToString("N2")); if (spawnLocation.HasValue) { PrefabGrid backup = PrefabGrid.GetBackup(heatSystem.GenerateBackupShipSize()); DuckUtils.SpawnInGravity(spawnLocation.Value, naturalGravityAtSpawn, RemoteControl.OwnerId, backup.PrefabName, backup.InitialBeaconName); } else { ModLog.DebugError("Couldn't spawn backup!", locationToSpawnPatrol); } }
private void SpawnHelperPatrol(IMyPlayer player) { var playerPos = player.GetPosition(); var playerNaturalGravity = marsPlanet.GetGravityAtPoint(playerPos); //TODO does perpendicularDistance maybe need to be normalised? // TODO: use faction info from faction definition. var perpendicularDistance = MyUtils.GetRandomPerpendicularVector(ref playerNaturalGravity) * 400; //4km away var locationToSpawnPatrol = playerPos + perpendicularDistance + playerNaturalGravity * -200f; // 2km up var naturalGravityAtSpawn = marsPlanet.GetGravityAtPoint(locationToSpawnPatrol); var spawnLocation = MyAPIGateway.Entities.FindFreePlace(locationToSpawnPatrol, 10, 20, 5, 10); if (spawnLocation.HasValue) { PrefabGrid backup = faction.Ships.GetBackupShip(); DuckUtils.SpawnInGravity(spawnLocation.Value, naturalGravityAtSpawn, RemoteControl.OwnerId, // TODO: use faction info from faction definition. backup.PrefabName, backup.InitialBeaconName); } else { ModLog.DebugError("Couldn't spawn backup!", locationToSpawnPatrol); } }