protected virtual NPCInst SpawnCharacter(ArenaClient client, WorldInst world, PosAng spawnPoint) { // only spawn if player has joined the game mode and chosen a class if (client == null || !client.GMJoined || client.GMClass == null) { return(null); } // get rid of old character if there is one client.KillCharacter(); NPCInst npc = CreateNPC(client.GMClass, (int)client.GMTeamID, client.CharInfo); npc.Spawn(world, spawnPoint.Position, spawnPoint.Angles); client.SetControl(npc); // start the warm up phase as soon as the first player joins if (Phase == GamePhase.None && players.Count(p => p.IsCharacter) == 1) { SetPhase(GamePhase.WarmUp); phaseTimer.SetInterval(Scenario.WarmUpDuration); phaseTimer.SetCallback(Fight); phaseTimer.Restart(); } return(npc); }
static void SetWorldGlobals(WorldInst world, GameScenario scenario) { if (scenario.WorldTimeScale > 0) { world.Clock.SetTime(scenario.WorldTime, scenario.WorldTimeScale); world.Clock.Start(); } else { world.Clock.SetTime(scenario.WorldTime, 1); world.Clock.Stop(); } if (scenario.WorldBarrier >= 0) { world.Barrier.StopTimer(); if (scenario.WorldBarrier > 0) { world.Barrier.SetNextWeight(0, scenario.WorldBarrier); } } if (scenario.WorldWeather >= 0) { world.Weather.StopRainTimer(); if (scenario.WorldWeather > 0) { world.Weather.SetNextWeight(0, scenario.WorldWeather); } } }
public override void Spawn(WorldInst world, Vec3f pos, Angles ang) { pBeforeSpawn(); base.Spawn(world, pos, ang); pAfterSpawn(); OnSpawn?.Invoke(this); }
private void CreateTestWorld() { var world = new WorldInst(RpConfig.Default.DefaultSpawnWorld); world.Create(); world.Clock.SetTime(new WorldTime(0, 8), 15.0f); world.Clock.Stop(); WorldInst.List.Add(world); }
protected override NPCInst SpawnCharacter(ArenaClient client, WorldInst world, PosAng spawnPoint) { NPCInst pc = base.SpawnCharacter(client, world, spawnPoint); pc.AllowHitTarget.Add(OnAllowHit); pc.DropUnconsciousOnDeath = true; pc.UnconsciousDuration = -1; return(pc); }
public static void Load(WorldInst world) { if (!File.Exists(world.Path)) { Logger.LogWarning("Battle Royale World '{0}' not found!", world.Path); } using (FileStream fs = new FileStream(world.Path, FileMode.Open, FileAccess.Read, FileShare.Read)) using (StreamReader sr = new StreamReader(fs)) { string line; while ((line = sr.ReadLine()) != null) { Action <WorldInst, PosAng> spawnFunc; if (line.StartsWith(ZENVobSpotString)) { spawnFunc = SpawnSomething; } else if (line.StartsWith(ZENItemString)) { spawnFunc = SpawnItem; } else { continue; } for (int i = 0; i < 5; i++) { line = sr.ReadLine(); } if (line == null || !line.StartsWith(ZENPositionString)) { continue; } if (!ReadPosition(line, out Vec3f pos)) { continue; } if (pos.GetLength() < 8500) { continue; } spawnFunc(world, new PosAng(pos, Angles.TwoPI * Randomizer.GetFloat())); for (int i = 0; i < 19; i++) { sr.ReadLine(); } } } }
public override void Spawn(WorldInst world, Vec3f pos, Angles ang) { if (ModelDef.Visual != "HUMANS.MDS" && ModelDef.Visual != "ORC.MDS" && ModelDef.Visual != "DRACONIAN.MDS") { SetFightMode(true); } base.Spawn(world, pos, ang); OnSpawn?.Invoke(this); }
public virtual void Despawn() { if (!this.IsSpawned) { return; } WorldInst oldWorld = this.World; BaseInst.Despawn(); OnDespawn?.Invoke(this, oldWorld); }
static void SpawnSomething(WorldInst world, PosAng posAng) { float prob = Randomizer.GetFloat(); if (prob < BRScenario.VobSpotNPCProb) { SpawnNPC(world, posAng); } else if (prob < BRScenario.VobSpotNPCProb + BRScenario.VobSpotItemProb) { SpawnItem(world, posAng); } }
public static GameMode InitScenario(GameScenario scenario) { if (scenario == null) { return(null); } if (IsActive) { NextScenarioIndex = GameScenario.Scenarios.IndexOf(scenario); ActiveMode.FadeOut(); return(null); } Log.Logger.Log("Init game scenario " + scenario.Name); if (++NextScenarioIndex >= GameScenario.Count) { NextScenarioIndex = 0; } var mode = scenario.GetMode(); ActiveMode = mode; var world = new WorldInst(null) { Path = scenario.WorldPath }; world.Create(); SetWorldGlobals(world, scenario); mode.World = world; if (!string.IsNullOrWhiteSpace(scenario.SpawnWorld)) { var spawnWorld = new WorldInst(null) { Path = scenario.SpawnWorld }; spawnWorld.Create(); SetWorldGlobals(spawnWorld, scenario); mode.SpawnWorld = spawnWorld; } mode.Start(scenario); return(mode); }
partial void pSpawn(WorldInst world, Vec3f pos, Angles ang) { // create arrow trail var ai = oCAIArrow.Create(); var gVob = this.BaseInst.gVob; gVob.SetSleeping(true); gVob.SetAI(ai); ai.CreateTrail(gVob); gVob.SetSleeping(false); // play shooting sound SoundHandler.PlaySound3D(sfx_shoot, this.BaseInst); }
static void SpawnItem(WorldInst world, PosAng posAng) { var item = BRScenario.Items.GetRandom(); ItemDef def = ItemDef.Get(item.Definition); if (def == null) { return; } ItemInst inst = new ItemInst(def); inst.SetAmount(item.Amount); inst.Spawn(world, posAng.Position, posAng.Angles); }
static void SpawnNPC(WorldInst world, PosAng posAng) { var npc = BRScenario.NPCs.GetRandom(); NPCDef def = NPCDef.Get(npc.Definition); if (def == null) { return; } NPCInst inst = new NPCInst(def); inst.BaseInst.SetNeedsClientGuide(true); inst.TeamID = 1; posAng.Position.Y += 50; inst.Protection = npc.Protection; inst.Damage = npc.Damage; inst.Spawn(world, posAng.Position, posAng.Angles); var agent = CreateAgent(); agent.Add(inst); }
public void SetToSpectator(WorldInst world, Vec3f pos, Angles ang) { this.BaseClient.SetToSpectate(world.BaseWorld, pos, ang); Menus.PlayerInventory.Menu.Close(); }
public override void Spawn(WorldInst world, Vec3f pos, Angles ang) { base.Spawn(world, pos, ang); pSpawn(world, pos, ang); }
partial void pSpawn(WorldInst world, Vec3f pos, Angles ang);
public SpawnPoint(WorldInst world, Vec3f point, Angles rotation) { World = world ?? throw new ArgumentNullException(nameof(world)); Point = point; Rotation = rotation; }
void RemoveVobHandler(BaseVobInst vob, WorldInst world) { RemoveVob((T)vob); }
partial void pSetToSpectator(WorldInst world, Vec3f pos, Angles ang);
public WorldInstEffectHandler(string objName, List <Effect> effects, WorldInst host) : base(objName, effects, host) { }
public WorldInstEffectHandler(List <Effect> effects, WorldInst host) : this("WorldEffectHandler (default)", effects, host) { }
public void SetToSpectator(WorldInst world, Vec3f pos, Angles ang) { this.baseClient.SetToSpectate(world.BaseWorld, pos, ang); pSetToSpectator(world, pos, ang); }
public virtual void Spawn(WorldInst world, Vec3f pos, Angles ang) { this.BaseInst.Spawn(world.BaseWorld, pos, ang); }
public void Spawn(WorldInst world) { this.Spawn(world, this.GetPosition(), this.GetAngles()); }
public static void StartHorde(HordeDef def) { if (def == null) { return; } Log.Logger.Log("horde init"); ArenaClient.ForEach(c => { var client = (ArenaClient)c; client.HordeScore = 0; client.HordeDeaths = 0; client.HordeKills = 0; client.HordeClass = null; }); players.ForEach(c => c.Spectate()); players.Clear(); if (activeWorld != null) { activeWorld.BaseWorld.ForEachVob(v => v.Despawn()); } var stream = ArenaClient.GetScriptMessageStream(); stream.Write((byte)ScriptMessages.HordeStart); stream.Write(def.Name); ArenaClient.ForEach(c => c.SendScriptMessage(stream, NetPriority.Low, NetReliability.ReliableOrdered)); activeDef = def; activeWorld = WorldInst.List.Find(w => w.Path == def.WorldPath); spawnBarriers.Clear(); foreach (var bar in activeDef.SpawnBarriers) { if (!bar.AddAfterEvent) { spawnBarriers.Add(CreateBarrier(bar)); } } ActiveStands.Clear(); for (int i = 0; i < activeDef.Stands.Length; i++) { var stand = activeDef.Stands[i]; StandInst inst = new StandInst() { Index = i, Stand = stand, }; if (stand.Boss != null) { inst.Boss = SpawnEnemy(stand.Boss, stand.Position); inst.Boss.CanGetHit += BossProtection; } inst.Barriers = new List <VobInst>(stand.Barriers.Length); foreach (var bar in stand.Barriers) { if (!bar.AddAfterEvent) { inst.Barriers.Add(CreateBarrier(bar)); } } ActiveStands.Add(inst); } foreach (var hi in activeDef.Items) { ItemInst item = new ItemInst(ItemDef.Get(hi.ItemDef)); item.Spawn(activeWorld, hi.Position, hi.Angles); } standEnemyCount = 0; ActiveStandInst = null; gameTimer.SetInterval(30 * TimeSpan.TicksPerSecond); gameTimer.SetCallback(Start); gameTimer.Stop(); SetPhase(HordePhase.WarmUp); }
partial void pSetToSpectator(WorldInst world, Vec3f pos, Angles ang) { Menus.PlayerInventory.Menu.Close(); }
protected NPCInst SpawnCharacter(ArenaClient client, WorldInst world, Vec3f position, float range) { return(SpawnCharacter(client, world, new PosAng(position, Randomizer.GetYaw()), range)); }
protected NPCInst SpawnCharacter(ArenaClient client, WorldInst world, PosAng spawnPoint, float range) { return(SpawnCharacter(client, world, new PosAng(Randomizer.GetVec3fRad(spawnPoint.Position, range), spawnPoint.Angles))); }