public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry) { try { LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1)); if (loc == null) { queue.HandleError(entry, "Invalid location!"); return; } EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0)); if (entity == null) { queue.HandleError(entry, "Invalid entity!"); return; } PlayerTag player; if (entity.TryGetPlayer(out player)) { player.Internal.player.gameObject.AddComponent <LaunchComponent>().LaunchPlayer(loc.ToVector3()); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully launched player " + TagParser.Escape(player.ToString()) + " to " + TagParser.Escape(loc.ToString()) + "!"); } return; } ZombieTag zombie; if (entity.TryGetZombie(out zombie)) { zombie.Internal.gameObject.AddComponent <LaunchComponent>().Launch(loc.ToVector3()); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully launched zombie " + TagParser.Escape(zombie.ToString()) + " to " + TagParser.Escape(loc.ToString()) + "!"); } return; } AnimalTag animal; if (entity.TryGetAnimal(out animal)) { animal.Internal.gameObject.AddComponent <LaunchComponent>().Launch(loc.ToVector3()); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully launched animal " + TagParser.Escape(animal.ToString()) + " to " + TagParser.Escape(loc.ToString()) + "!"); } return; } ItemEntityTag item; if (entity.TryGetItem(out item)) { // TODO: Find some way to teleport items, barricades, etc without voiding the InstanceID? } queue.HandleError(entry, "That entity can't be launched!"); } catch (Exception ex) // TODO: Necessity? { queue.HandleError(entry, "Failed to launch entity: " + ex.ToString()); } }
public override TemplateObject Handle(TagData data) { string lname = data.GetModifier(0); LocationTag ltag = LocationTag.For(lname); if (ltag == null) { return(new TextTag("&{NULL}").Handle(data.Shrink())); } return(ltag.Handle(data.Shrink())); }
public override TemplateObject Handle(TagData data) { string lname = data.GetModifier(0); LocationTag ltag = LocationTag.For(TheServer, data, lname); if (ltag == null) { data.Error("Invalid location '" + TagParser.Escape(lname) + "'!"); return(new NullTag()); } return(ltag.Handle(data.Shrink())); }
public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry) { LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1)); if (loc == null) { queue.HandleError(entry, "Invalid location!"); return; } EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0)); if (entity == null) { queue.HandleError(entry, "Invalid entity!"); return; } ZombieTag zombie; if (entity.TryGetZombie(out zombie)) { zombie.Internal.target.position = loc.ToVector3(); zombie.Internal.seeker.canMove = true; zombie.Internal.seeker.canSearch = true; zombie.Internal.path = EZombiePath.RUSH; // TODO: Option for this? if (!zombie.Internal.isTicking) { zombie.Internal.isTicking = true; ZombieManager.tickingZombies.Add(zombie.Internal); } if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully started a zombie walking to " + TagParser.Escape(loc.ToString()) + "!"); } return; } AnimalTag animal; if (entity.TryGetAnimal(out animal)) { animal.Internal.target = loc.ToVector3(); if (!animal.Internal.isTicking) { animal.Internal.isTicking = true; AnimalManager.tickingAnimals.Add(animal.Internal); } if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully started an animal walking to " + TagParser.Escape(loc.ToString()) + "!"); } return; } queue.HandleError(entry, "That entity can't be made to walk!"); }
public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry) { LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1)); if (loc == null) { queue.HandleError(entry, "Invalid location!"); return; } string targetAssetType = entry.GetArgument(queue, 0).ToLower(); EffectAssetTag effectType = EffectAssetTag.For(targetAssetType); if (effectType == null) { queue.HandleError(entry, "Invalid effect type!"); return; } EffectManager.sendEffect(effectType.Internal.id, EffectManager.INSANE, loc.ToVector3()); // TODO: radius option instead of always 512 units (INSANE)! if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Played effect " + TagParser.Escape(effectType.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "!"); } }
public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry) { try { TemplateObject spawned = null; LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1)); if (loc == null) { queue.HandleError(entry, "Invalid location!"); return; } string targetAssetType = entry.GetArgument(queue, 0).ToLowerFast(); EntityType etype = EntityType.ValueOf(targetAssetType); if (etype == null) { queue.HandleError(entry, "Invalid entity type!"); return; } if (etype.Type == EntityAssetType.ZOMBIE) { Vector3 vec3 = loc.ToVector3(); byte reg = 0; // TODO: Optionally specifiable float closest = float.MaxValue; for (int r = 0; r < LevelZombies.zombies.Length; r++) { for (int i = 0; i < LevelZombies.zombies[r].Count; i++) { float dist = (LevelZombies.zombies[r][i].point - vec3).sqrMagnitude; if (dist < closest) { closest = dist; reg = (byte)r; } } } ZombieManager.manager.addZombie(reg, 0, 0, 0, 0, 0, 0, 0, 0, vec3, 0, false); Zombie zombie = ZombieManager.regions[reg].zombies[ZombieManager.regions[reg].zombies.Count - 1]; // TODO: Make this actually work! (See complaints file!) /* * foreach (SteamPlayer player in PlayerTool.getSteamPlayers()) * { * ZombieManager.manager.channel.openWrite(); * ZombieManager.manager.channel.write(reg); * ZombieManager.manager.channel.write((ushort)1); * ZombieManager.manager.channel.write(new object[] * { * zombie.type, * (byte)zombie.speciality, * zombie.shirt, * zombie.pants, * zombie.hat, * zombie.gear, * zombie.move, * zombie.idle, * zombie.transform.position, * MeasurementTool.angleToByte(zombie.transform.rotation.eulerAngles.y), * zombie.isDead * }); * ZombieManager.manager.channel.closeWrite("tellZombies", player.playerID.steamID, ESteamPacket.UPDATE_RELIABLE_CHUNK_BUFFER); * } */ if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully spawned a zombie at " + TagParser.Escape(loc.ToString()) + "! (WARNING: IT WILL BE INVISIBLE CURRENTLY - SEE THE COMPLAINTS FILE)"); } spawned = new ZombieTag(zombie); } else if (etype.Type == EntityAssetType.ANIMAL) { AnimalAssetTag asset = AnimalAssetTag.For(targetAssetType); if (asset == null) { queue.HandleError(entry, "Invalid animal type!"); return; } // TODO: Make this bit optional! RaycastHit rch; while (Physics.Raycast(loc.ToVector3(), new Vector3(0, 1, 0), out rch, 5)) { loc.Y += 3; } // END TODO AnimalManager.manager.addAnimal(asset.Internal.id, loc.ToVector3(), 0, false); Animal animal = AnimalManager.animals[AnimalManager.animals.Count - 1]; foreach (SteamPlayer player in PlayerTool.getSteamPlayers()) { AnimalManager.manager.channel.openWrite(); AnimalManager.manager.channel.write((ushort)1); AnimalManager.manager.channel.write(new object[] { animal.id, animal.transform.position, MeasurementTool.angleToByte(animal.transform.rotation.eulerAngles.y), animal.isDead }); AnimalManager.manager.channel.closeWrite("tellAnimals", player.playerID.steamID, ESteamPacket.UPDATE_RELIABLE_CHUNK_BUFFER); } if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "! (" + animal.gameObject.GetInstanceID() + ")"); } spawned = new AnimalTag(animal); } else if (etype.Type == EntityAssetType.VEHICLE) { VehicleAssetTag asset = VehicleAssetTag.For(targetAssetType); if (asset == null) { queue.HandleError(entry, "Invalid vehicle type!"); return; } // TODO: Make this bit optional! RaycastHit rch; while (Physics.Raycast(loc.ToVector3(), new Vector3(0, 1, 0), out rch, 5)) { loc.Y += 3; } // END TODO VehicleManager.spawnVehicle(asset.Internal.id, loc.ToVector3(), Quaternion.identity); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "!"); } // TODO: Get the vehicle entity! } else if (etype.Type == EntityAssetType.WORLD_OBJECT) { WorldObjectAssetTag asset = WorldObjectAssetTag.For(targetAssetType); if (asset == null) { queue.HandleError(entry, "Invalid world object type!"); return; } LevelObjects.addObject(loc.ToVector3(), Quaternion.identity, Vector3.one, asset.Internal.id, asset.Internal.name, asset.Internal.GUID, ELevelObjectPlacementOrigin.MANUAL); // TODO: Network! entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "! (WARNING: IT WILL BE INVISIBLE CURRENTLY - SEE THE COMPLAINTS FILE)"); // TODO: Get the world entity! } else if (etype.Type == EntityAssetType.ITEM) { ItemAssetTag asset = ItemAssetTag.For(targetAssetType); if (asset == null) { queue.HandleError(entry, "Invalid item type!"); return; } byte x; byte y; if (Regions.tryGetCoordinate(loc.ToVector3(), out x, out y)) { Item item = new Item(asset.Internal.id, 1, asset.Internal.quality); ItemData data = new ItemData(item, ++ItemManager.instanceCount, loc.ToVector3(), Dedicator.isDedicated); ItemManager.regions[x, y].items.Add(data); ItemModelTracker.Track(data, loc.ToVector3()); ItemManager.manager.channel.send("tellItem", ESteamCall.CLIENTS, x, y, ItemManager.ITEM_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[] { x, y, item.id, item.amount, item.quality, item.state, loc.ToVector3() }); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "!"); } // TODO: Get the item entity! } else { queue.HandleError(entry, "Trying to spawn item outside any valid item regions!"); } } else if (etype.Type == EntityAssetType.BARRICADE) { ItemAssetTag asset = ItemAssetTag.For(targetAssetType.Substring("barricade_".Length)); if (asset == null || !(asset.Internal is ItemBarricadeAsset)) { queue.HandleError(entry, "Invalid item barricade type!"); return; } Barricade barric = new Barricade(asset.Internal.id); BarricadeManager.dropBarricade(barric, null, loc.ToVector3(), 0f, 0f, 0f, CSteamID.Nil.m_SteamID, CSteamID.Nil.m_SteamID); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "!"); } // TODO: Get the game object! } else if (etype.Type == EntityAssetType.STRUCTURE) { ItemAssetTag asset = ItemAssetTag.For(targetAssetType.Substring("structure_".Length)); if (asset == null || !(asset.Internal is ItemStructureAsset)) { queue.HandleError(entry, "Invalid item structure type!"); return; } StructureManager.dropStructure(new Structure(asset.Internal.id), loc.ToVector3(), 0f, 0f, 0f, CSteamID.Nil.m_SteamID, CSteamID.Nil.m_SteamID); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "!"); } // TODO: Get the game object! } else { queue.HandleError(entry, "Invalid or unspawnable entity type!"); return; } if (spawned != null) { queue.SetVariable("spawned", spawned); } } catch (Exception ex) // TODO: Necessity? { queue.HandleError(entry, "Failed to spawn entity: " + ex.ToString()); } }
public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry) { try { LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1)); if (loc == null) { queue.HandleError(entry, "Invalid location!"); return; } EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0)); if (entity == null) { queue.HandleError(entry, "Invalid entity!"); return; } PlayerTag player; if (entity.TryGetPlayer(out player)) { player.Internal.player.sendTeleport(loc.ToVector3(), 0); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully teleported a player to " + TagParser.Escape(loc.ToString()) + "!"); } return; } ZombieTag zombie; if (entity.TryGetZombie(out zombie)) { zombie.Internal.transform.position = loc.ToVector3(); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully teleported a zombie to " + TagParser.Escape(loc.ToString()) + "!"); } return; } AnimalTag animal; if (entity.TryGetAnimal(out animal)) { animal.Internal.transform.position = loc.ToVector3(); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully teleported an animal to " + TagParser.Escape(loc.ToString()) + "!"); } return; } ItemEntityTag item; if (entity.TryGetItem(out item)) { // TODO: Find some way to teleport items, barricades, etc without voiding the InstanceID? /* * Transform transform = item.Internal.transform.parent; * byte x; * byte y; * if (Regions.tryGetCoordinate(transform.position, out x, out y)) * { * ItemRegion region = ItemManager.regions[x, y]; * for (byte i = 0; i < region.models.Count; i+) * { * if (region.models[i] == transform) * { * ItemManager.regions[x, y].items.RemoveAt(i); * ItemModelTracker.Untrack(x, y, i); * ItemManager.manager.channel.send("tellTakeItem", ESteamCall.CLIENTS, x, y, ItemManager.ITEM_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[] * { * x, * y, * loc.ToVector3() * }); * // Then respawn item at new location * break; * } * } * } */ } queue.HandleError(entry, "That entity can't be teleported!"); } catch (Exception ex) // TODO: Necessity of this? { queue.HandleError(entry, "Failed to teleport entity: " + ex.ToString()); } }