Пример #1
0
        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);
        }
Пример #2
0
        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);
                }
            }
        }
Пример #3
0
        public override void Spawn(WorldInst world, Vec3f pos, Angles ang)
        {
            pBeforeSpawn();
            base.Spawn(world, pos, ang);
            pAfterSpawn();

            OnSpawn?.Invoke(this);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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();
                        }
                    }
                }
        }
Пример #7
0
        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);
        }
Пример #8
0
        public virtual void Despawn()
        {
            if (!this.IsSpawned)
            {
                return;
            }

            WorldInst oldWorld = this.World;

            BaseInst.Despawn();
            OnDespawn?.Invoke(this, oldWorld);
        }
Пример #9
0
        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);
            }
        }
Пример #10
0
        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);
        }
Пример #11
0
        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);
        }
Пример #12
0
        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);
        }
Пример #13
0
        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);
        }
Пример #14
0
 public void SetToSpectator(WorldInst world, Vec3f pos, Angles ang)
 {
     this.BaseClient.SetToSpectate(world.BaseWorld, pos, ang);
     Menus.PlayerInventory.Menu.Close();
 }
Пример #15
0
 public override void Spawn(WorldInst world, Vec3f pos, Angles ang)
 {
     base.Spawn(world, pos, ang);
     pSpawn(world, pos, ang);
 }
Пример #16
0
 partial void pSpawn(WorldInst world, Vec3f pos, Angles ang);
Пример #17
0
 public SpawnPoint(WorldInst world, Vec3f point, Angles rotation)
 {
     World    = world ?? throw new ArgumentNullException(nameof(world));
     Point    = point;
     Rotation = rotation;
 }
Пример #18
0
 void RemoveVobHandler(BaseVobInst vob, WorldInst world)
 {
     RemoveVob((T)vob);
 }
Пример #19
0
 partial void pSetToSpectator(WorldInst world, Vec3f pos, Angles ang);
Пример #20
0
 public WorldInstEffectHandler(string objName, List <Effect> effects, WorldInst host)
     : base(objName, effects, host)
 {
 }
Пример #21
0
 public WorldInstEffectHandler(List <Effect> effects, WorldInst host)
     : this("WorldEffectHandler (default)", effects, host)
 {
 }
Пример #22
0
 public void SetToSpectator(WorldInst world, Vec3f pos, Angles ang)
 {
     this.baseClient.SetToSpectate(world.BaseWorld, pos, ang);
     pSetToSpectator(world, pos, ang);
 }
Пример #23
0
 public virtual void Spawn(WorldInst world, Vec3f pos, Angles ang)
 {
     this.BaseInst.Spawn(world.BaseWorld, pos, ang);
 }
Пример #24
0
 public void Spawn(WorldInst world)
 {
     this.Spawn(world, this.GetPosition(), this.GetAngles());
 }
Пример #25
0
        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);
        }
Пример #26
0
 partial void pSetToSpectator(WorldInst world, Vec3f pos, Angles ang)
 {
     Menus.PlayerInventory.Menu.Close();
 }
Пример #27
0
 protected NPCInst SpawnCharacter(ArenaClient client, WorldInst world, Vec3f position, float range)
 {
     return(SpawnCharacter(client, world, new PosAng(position, Randomizer.GetYaw()), range));
 }
Пример #28
0
 protected NPCInst SpawnCharacter(ArenaClient client, WorldInst world, PosAng spawnPoint, float range)
 {
     return(SpawnCharacter(client, world, new PosAng(Randomizer.GetVec3fRad(spawnPoint.Position, range), spawnPoint.Angles)));
 }