コード例 #1
0
ファイル: NpcMob.cs プロジェクト: natedahl32/EqEmulator-net
        internal void AddLoot(Npc npc)
        {
            Random rand = new Random();

            // Coin
            if (npc.Loot.MinCash > npc.Loot.MaxCash)
                _log.ErrorFormat("{0}'s minCash({1}) > maxCash({2}), please fix.", npc.Name, npc.Loot.MinCash, npc.Loot.MaxCash);
            else if (npc.Loot.MaxCash > 0) {
                uint cash = 0;

                if (npc.Loot.MaxCash == npc.Loot.MinCash)
                    cash = npc.Loot.MaxCash;
                else
                    cash = (uint)rand.Next((int)npc.Loot.MinCash, (int)npc.Loot.MaxCash + 1);

                if (cash != 0) {
                    this.Platinum = cash / 1000;
                    cash -= this.Platinum * 1000;
                    this.Gold = cash / 100;
                    cash -= this.Gold * 100;
                    this.Silver = cash / 10;
                    cash -= this.Silver * 10;
                    this.Copper = cash;
                }
            }

            // Items
            int sumProb = 0, roll = 0, probIter = 0;

            foreach (LootEntry le in npc.Loot.LootEntries) {
                for (int i = 0; i < le.MaxDrops; i++) {
                    if (rand.Next(0, 100) < le.Probability) {
                        sumProb = le.LootDrops.Sum(ld => ld.Probability);     // Get total probability of all loot drops
                        roll = rand.Next(0, sumProb + 1);

                        probIter = 0;
                        foreach (LootDrop ld in le.LootDrops) {
                            probIter += ld.Probability;
                            if (roll < probIter) {
                                InventoryItem invItem = new InventoryItem()
                                {
                                    Charges = ld.ItemCharges,
                                    Color = ld.Item.Color ?? 0,
                                    Item = ld.Item,
                                    ItemID = ld.ItemID,
                                    SlotID = 0
                                };

                                AddItem(invItem, ld.Equipable, false);
                                break;
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: NpcMob.cs プロジェクト: natedahl32/EqEmulator-net
        public NpcMob(int entityId, Npc npcData, int gridId, float x, float y, float z, float heading)
            : base(entityId, npcData.Name, npcData.SurName, npcData.AC, (short)npcData.Attack, (short)npcData.STR, (short)npcData.STA,
                (short)npcData.DEX, (short)npcData.AGI, npcData.INT, npcData.WIS, npcData.CHA, npcData.Hp, npcData.Hp, npcData.Gender,
                (short)npcData.HpRegenRate, (short)npcData.ManaRegenRate, npcData.Race, npcData.NpcClass, npcData.NpcLevel, (BodyType)npcData.BodyType,
                0, x, y, z, heading, npcData.Size, npcData.RunSpeed, 0)
        {
            _npcDbId = npcData.NpcID;
            _gridId = gridId;
            _seeInvis = npcData.SeeInvis;
            _seeInvisToUndead = npcData.SeeInvisUndead;
            _seeHide = npcData.SeeHide;
            _seeImprovedHide = npcData.SeeImprovedHide;
            _texture = npcData.Texture;
            _helmTexture = npcData.HelmTexture;
            _hairColor = (byte)npcData.HairColorLuclin;
            _beardColor = (byte)npcData.BeardColorLuclin;
            _eyeColor1 = (byte)npcData.EyeColorLuclin;
            _eyeColor2 = (byte)npcData.EyeColor2Luclin;
            _hairStyle = (byte)npcData.HairStyleLuclin;
            _luclinFace = (byte)npcData.Face;
            _beard = (byte)npcData.BeardLuclin;
            _aggroRange = npcData.AggroRadius;
            _assistRange = npcData.AggroRadius;
            _findable = npcData.Findable;
            _trackable = npcData.Trackable;
            _accuracy = npcData.Accuracy;
            _attackSpeed = npcData.AttackSpeed;
            _willAggroNPCs = npcData.NpcAggro;
            _meleeTexture1 = npcData.MeleeTexture1;
            _meleeTexture2 = npcData.MeleeTexture2;
            _minDmg = npcData.MinDamage;
            _maxDmg = npcData.MaxDamage;

            // TODO: timers... combat event, swarm, class attack, knight attack, assist, enraged, taunt
            _globalPositionUpdateTimer = new SimpleTimer(GLOBAL_POS_UPDATE_INTERVAL);   // TODO: does this belong in mob?
            _hpUpdateTimer = new SimpleTimer(HP_UPDATE_INTERVAL);

            // Mana regen rate adjustments for lazy db updaters
            _manaRegen = Math.Max(_manaRegen, (short)0);
            if (GetCasterClass() != CasterClass.None && _manaRegen == 0)
                _manaRegen = (short)((this.Level / 10) + 4);

            // TODO: HP regen adjustments (Gives low end mobs no regen if set to 0 in db.  Makes low end mobs more killable)
            _hpRegen = Math.Max(_hpRegen, (short)0);
            if (_hpRegen == 0) {

            }

            // min and max dmg adjustments
            if (_maxDmg == 0) {
                int acAdj = 12;

                if (this.Level >= 66) {
                    if (_minDmg == 0)
                        _minDmg = 200;
                    if (_maxDmg == 0)
                        _maxDmg = ((((99000) * (this.Level - 64)) / 400) * acAdj / 10);
                }
                else if (this.Level >= 60 && this.Level <= 65) {
                    if (_minDmg == 0)
                        _minDmg = (this.Level + (this.Level / 3));
                    if (_maxDmg == 0)
                        _maxDmg = (this.Level * 3) * acAdj / 10;
                }
                else if (this.Level >= 51 && this.Level <= 59) {
                    if (_minDmg == 0)
                        _minDmg = (this.Level + (this.Level / 3));
                    if (_maxDmg == 0)
                        _maxDmg = (this.Level * 3) * acAdj / 10;
                }
                else if (this.Level >= 40 && this.Level <= 50) {
                    if (_minDmg == 0)
                        _minDmg = this.Level;
                    if (_maxDmg == 0)
                        _maxDmg = (this.Level * 3) * acAdj / 10;
                }
                else if (this.Level >= 28 && this.Level <= 39) {
                    if (_minDmg == 0)
                        _minDmg = this.Level / 2;
                    if (_maxDmg == 0)
                        _maxDmg = ((this.Level * 2) + 2) * acAdj / 10;
                }
                else if (this.Level <= 27) {
                    if (_minDmg == 0)
                        _minDmg = 1;
                    if (_maxDmg == 0)
                        _maxDmg = (this.Level * 2) * acAdj / 10;
                }

                int clFact = GetClassLevelFactor();
                _minDmg = (_minDmg * clFact) / 220;
                _maxDmg = (_maxDmg * clFact) / 220;
            }

            // TODO: calc max mana and then set mana

            // Adjust resists if needed
            _mr = npcData.MR < 1 ? (short)((this.Level * 11) / 10) : npcData.MR;
            _cr = npcData.MR < 1 ? (short)((this.Level * 11) / 10) : npcData.CR;
            _dr = npcData.MR < 1 ? (short)((this.Level * 11) / 10) : npcData.DR;
            _fr = npcData.MR < 1 ? (short)((this.Level * 11) / 10) : npcData.FR;
            _pr = npcData.MR < 1 ? (short)((this.Level * 11) / 10) : npcData.PR;

            // TODO: faction

            // TODO: spells

            // TODO: set guard spot?

            if (npcData.Loot != null)
                AddLoot(npcData);   // Give npc some loot

            //_log.DebugFormat("{0} has {1} items - {2} of which are equipped...", npcData.Name, _lootItems.Count, _equipedItems.Count);
            //foreach (KeyValuePair<uint, LootItem> kvp in _equipedItems) {
            //    _log.DebugFormat("slot {0} has itemId {1}", kvp.Key, kvp.Value.ItemID);
            //}

            if (npcData.NpcSpecialAttacks != null)
                ParseSpecialAttacks(npcData.NpcSpecialAttacks);

            StartAI();
        }
コード例 #3
0
 partial void DeleteNpc(Npc instance);
コード例 #4
0
 partial void UpdateNpc(Npc instance);
コード例 #5
0
 partial void InsertNpc(Npc instance);
コード例 #6
0
		private void detach_Npcs(Npc entity)
		{
			this.SendPropertyChanging();
			entity.Loot = null;
		}
コード例 #7
0
		private void attach_Npcs(Npc entity)
		{
			this.SendPropertyChanging();
			entity.Loot = this;
		}