Beispiel #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);
        }
Beispiel #2
0
        static void SpawnPlayer(ArenaClient client)
        {
            var     charInfo = client.CharInfo;
            NPCInst npc      = new NPCInst(NPCDef.Get(charInfo.BodyMesh == HumBodyMeshs.HUM_BODY_NAKED0 ? "maleplayer" : "femaleplayer"))
            {
                UseCustoms     = true,
                CustomBodyTex  = charInfo.BodyTex,
                CustomHeadMesh = charInfo.HeadMesh,
                CustomHeadTex  = charInfo.HeadTex,
                CustomVoice    = charInfo.Voice,
                CustomFatness  = charInfo.Fatness,
                CustomScale    = new Vec3f(charInfo.BodyWidth, 1.0f, charInfo.BodyWidth),
                CustomName     = charInfo.Name
            };

            foreach (string e in client.HordeClass.Equipment)
            {
                ItemInst item = new ItemInst(ItemDef.Get(e));
                npc.Inventory.AddItem(item);
                npc.EffectHandler.TryEquipItem(item);
            }

            if (client.HordeClass.NeedsBolts)
            {
            }

            npc.Inventory.AddItem(new ItemInst(ItemDef.Get("hptrank")));

            Vec3f  spawnPos = Randomizer.GetVec3fRad(activeDef.SpawnPos, activeDef.SpawnRange);
            Angles spawnAng = Randomizer.GetYaw();

            //npc.TeamID = 0;
            npc.Spawn(activeWorld, spawnPos, spawnAng);
            client.SetControl(npc);
        }
Beispiel #3
0
        static NPCInst SpawnEnemy(HordeEnemy enemy, Vec3f spawnPoint, float spawnRange = 100)
        {
            NPCInst npc = new NPCInst(NPCDef.Get(enemy.NPCDef));

            if (enemy.WeaponDef != null)
            {
                ItemInst item = new ItemInst(ItemDef.Get(enemy.WeaponDef));
                npc.Inventory.AddItem(item);
                npc.EffectHandler.TryEquipItem(item);
            }

            if (enemy.ArmorDef != null)
            {
                ItemInst item = new ItemInst(ItemDef.Get(enemy.ArmorDef));
                npc.Inventory.AddItem(item);
                npc.EffectHandler.TryEquipItem(item);
            }

            npc.SetHealth(enemy.Health, enemy.Health);

            Vec3f  spawnPos = Randomizer.GetVec3fRad(spawnPoint, spawnRange);
            Angles spawnAng = Randomizer.GetYaw();

            //npc.TeamID = 1;
            npc.BaseInst.SetNeedsClientGuide(true);
            npc.Spawn(activeWorld, spawnPos, spawnAng);
            return(npc);
        }
Beispiel #4
0
        protected virtual NPCInst SpawnNPC(NPCClass classDef, Vec3f pos, Angles ang, float posOffset = 100, int teamID = 1, bool giveAI = true)
        {
            NPCInst npc = CreateNPC(classDef, teamID);

            Vec3f spawnPos = posOffset > 0 ? Randomizer.GetVec3fRad(pos, posOffset) : pos;

            npc.BaseInst.SetNeedsClientGuide(giveAI);
            npc.Spawn(World, spawnPos, ang);
            return(npc);
        }
Beispiel #5
0
        public void FMSpawn()
        {
            if (GameMode.IsActive)
            {
                GameMode.ActiveMode.Leave(this);
            }

            KillCharacter();
            SetTeamID(TeamIdent.FFAPlayer);

            NPCDef  def = NPCDef.Get(charInfo.BodyMesh == HumBodyMeshs.HUM_BODY_NAKED0 ? "maleplayer" : "femaleplayer");
            NPCInst npc = new NPCInst(def)
            {
                UseCustoms             = true,
                CustomBodyTex          = charInfo.BodyTex,
                CustomHeadMesh         = charInfo.HeadMesh,
                CustomHeadTex          = charInfo.HeadTex,
                CustomVoice            = charInfo.Voice,
                CustomFatness          = charInfo.Fatness,
                CustomScale            = new Vec3f(charInfo.BodyWidth, 1.0f, charInfo.BodyWidth),
                CustomName             = charInfo.Name,
                DropUnconsciousOnDeath = true,
                UnconsciousDuration    = 15 * TimeSpan.TicksPerSecond,
            };

            ItemDef.ForEach(itemDef =>
            {
                var item = new ItemInst(itemDef);
                npc.Inventory.AddItem(item);
                if (string.Equals(itemDef.CodeName, "ItMw_1h_Bau_Mace", StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(itemDef.CodeName, "ITAR_Prisoner", StringComparison.OrdinalIgnoreCase))
                {
                    npc.EffectHandler.TryEquipItem(item);
                }
                else if (itemDef.ItemType == ItemTypes.AmmoBow || itemDef.ItemType == ItemTypes.AmmoXBow)
                {
                    item.SetAmount(100);
                }
            });

            if (npc.ModelDef.TryGetOverlay("1HST1", out ScriptOverlay ov))
            {
                npc.ModelInst.ApplyOverlay(ov);
            }
            if (npc.ModelDef.TryGetOverlay("2HST1", out ov))
            {
                npc.ModelInst.ApplyOverlay(ov);
            }

            var pair = spawnPositions.GetRandom();

            npc.Spawn(WorldInst.List[0], pair.Item1, pair.Item2);
            this.SetControl(npc);
            npc.AllowHitAttacker.Add(DuelMode.CheckHitDetection);
        }
Beispiel #6
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);
        }
Beispiel #7
0
        public static NPCInst CreateDummyInst(NPCDef npcDef, string name, Types.Vec3f spawnPosition, Random random)
        {
            random = random ?? new Random();

            int guild      = random.Next(0, 2);
            int armorType  = random.Next(0, 4);
            int meleeType  = random.Next(0, 4);
            int rangedType = random.Next(0, 2);

            NPCInst npcInst = null;

            npcInst = new NPCInst(npcDef);
            npcInst.SetObjName(name);
            npcInst.BaseInst.SetNeedsClientGuide(true);

            ItemInst      armor = null, weapon = null, rangeWeapon = null, ammo = null;
            int           ammoAmount;
            ScriptOverlay overlay       = null;
            bool          overlayExists = false;

            armor = new ItemInst(ItemDef.Get <ItemDef>(ArmorCodes[random.Next(0, ArmorCodes.Count)]));

            // melee weapon
            if (random.Next(0, 2) == 0)
            {
                // 1H-weapon
                weapon        = new ItemInst(ItemDef.Get <ItemDef>(WeaponCodes_1H[random.Next(0, WeaponCodes_1H.Count)]));
                overlayExists = npcInst.ModelDef.TryGetOverlay("1HST2", out overlay);
            }
            else
            {
                // 2H-weapon
                weapon        = new ItemInst(ItemDef.Get <ItemDef>(WeaponCodes_2H[random.Next(0, WeaponCodes_2H.Count)]));
                overlayExists = npcInst.ModelDef.TryGetOverlay("2HST1", out overlay);
            }

            // ranged weapon
            if (random.Next(0, 2) == 0)
            {
                // bow
                rangeWeapon = new ItemInst(ItemDef.Get <ItemDef>(WeaponCodes_Bow[random.Next(0, WeaponCodes_Bow.Count)]));
                ammo        = new ItemInst(ItemDef.Get <ItemDef>(AmmoCodes_Bow[random.Next(0, AmmoCodes_Bow.Count)]));
            }
            else
            {
                // crossbow
                rangeWeapon = new ItemInst(ItemDef.Get <ItemDef>(WeaponCodes_Crossbow[random.Next(0, WeaponCodes_Crossbow.Count)]));
                ammo        = new ItemInst(ItemDef.Get <ItemDef>(AmmoCodes_Crossbow[random.Next(0, AmmoCodes_Crossbow.Count)]));
            }

            ammoAmount = random.Next(10, 500 + 1);
            ammo.BaseInst.SetAmount(ammoAmount);

            npcInst.Inventory.AddItem(weapon);
            npcInst.EffectHandler.TryEquipItem(weapon); // 1 = DrawnWeapon

            npcInst.Inventory.AddItem(rangeWeapon);
            npcInst.EffectHandler.TryEquipItem(rangeWeapon);

            npcInst.Inventory.AddItem(ammo);
            npcInst.EffectHandler.TryEquipItem(ammo);

            npcInst.Inventory.AddItem(armor);
            npcInst.EffectHandler.TryEquipItem(armor);

            if (overlayExists)
            {
                npcInst.ModelInst.ApplyOverlay(overlay);
            }

            npcInst.Spawn(WorldSystem.WorldInst.List[0], spawnPosition, Types.Angles.Null);

            return(npcInst);
        }