public void On_NPCHurt(NPCHurtEvent he) { try { if (he.Attacker?.baseEntity == TestChicken && he.Victim?.baseEntity == TestChicken) { SetHookWorking("On_NPCHurt"); Broadcast("The chicken hurt itself."); } } catch (Exception ex) { Logger.LogException(ex); } }
public void On_Command(CommandEvent ce) { SetHookWorking("On_Command"); // nch = not called hooks, lets you broadcast them on the server if (ce.Cmd == "nch" && ce.User.Admin) { OutputResults(); } // flush datastore entries, do it before you start testing new changes to hooks if (ce.Cmd == "ftds" && ce.User.Admin) { DataStore.Flush(GetType().ToString()); } // start automated tests if (ce.Cmd == "test" && ce.User.Admin) { Broadcast("Initiating funcionality test."); //Server.Broadcast("#" + NotCalledHooks.Count + " hooks to be tested..."); try { TestChicken = World.SpawnAnimal("chicken", ce.User.X, ce.User.Z) as BaseNPC; TestChicken.Hurt(new HitInfo(TestChicken, TestChicken, DamageType.Bite, 1)); TestChicken.Die(new HitInfo(TestChicken, TestChicken, DamageType.Bite, 999)); TestBot = World.SpawnMapEntity("assets/prefabs/player/player.prefab", ce.User.X, ce.User.Z) as BasePlayer; TestBot.StartSleeping(); TestBot.EndSleeping(); TestBot.Hurt(new HitInfo(TestBot, TestBot, DamageType.Bite, 1)); TestBot.StartWounded(); ce.User.Message("Help up the bot and heal it"); ce.User.Inventory.Add("Medical Syringe", 2); ce.User.basePlayer.Hurt(10f, DamageType.Bite, ce.User.basePlayer); ce.User.Message("Heal yourself too!"); TestBot.UpdateRadiation(0); ce.User.Inventory.Add(new InvItem("Wood", 2000)); ce.User.Inventory.Add(new InvItem("Wooden Door", 1)); ce.User.Inventory.Add(new InvItem("Hammer", 1)); ce.User.Inventory.Add(new InvItem("Lock", 1)); ce.User.Inventory.Add(new InvItem("Code Lock", 1)); ce.User.Inventory.Add(new InvItem("Tool Cupboard", 1)); ce.User.SendConsoleCommand("testing"); } catch (Exception ex) { Logger.LogException(ex); } } }