public KillXp(ServerPlayer a_player, ServerNpc a_npc, float a_xp, float a_time) { this.player = a_player; this.npc = a_npc; this.xp = a_xp; this.deletetime = a_time; }
public KillXp(ServerPlayer a_player, ServerNpc a_npc, float a_xp, float a_time) { player = a_player; npc = a_npc; xp = a_xp; deletetime = a_time; }
/// <summary> /// Creates and adds ServerNpc wrapper to the world /// </summary> /// <param name="characterEntity"></param> /// <returns></returns> public INpc CreateNpc(CharacterEntity characterEntity) { var entity = new ServerNpc(_server, characterEntity); AddEntity(entity); return(entity); }
public void AttackNpc(Vector2 target, NpcSpawn npcSpawn) { SendAttackPacket(_player, target); ServerNpc npc = (ServerNpc)npcSpawn; if (npc == null) { return; } if (_player.InCombat && _player.NpcInCombatWith != npc) { _player.SendChatMessage("You're already fighting something else!"); return; } if (npc.PlayerInCombatWith != null && npc.PlayerInCombatWith != _player) { _player.SendChatMessage($"NPC[{npc.Name}] is already in combat."); return; } if (npc != null && npc.IsAttackable(_player)) { byte damage = (byte)CalculateHitDamage(_player, npc); AddExperience(damage); npc.TakeDamage(damage, _player); if (!npc.Alive) { return; } NpcTakeDamagePacket damagePacket = new NpcTakeDamagePacket { PlayerDoingDamage = _player.Id, NpcSpawnId = npc.SpawnId, Damage = damage, CurrentHealth = npc.CurrentHealth }; ServerPacketHandler.Instance.SendSerializablePacketToRenderedPlayers(PacketType.NpcTakeDamage, damagePacket, DeliveryMethod.ReliableUnordered, npc.CurrentServerPosition); } }
public ServerNpc AddNpc(CharacterEntity charEntity) { charEntity.EntityFactory = _server.EntityFactory; var npc = new ServerNpc(_server, charEntity); var id = charEntity.DynamicId; if (id == 0) { id = DynamicIdHelper.GetNextUniqueId(); npc.DynamicEntity.DynamicId = id; } _server.AreaManager.AddEntity(npc); _npcs.Add(id, npc); charEntity.HealthStateChanged += charEntity_HealthStateChanged; charEntity.NeedSave += charEntity_NeedSave; return(npc); }
private void CalculateXpAndKarma(Transform a_victim, float a_weaponDamage) { if (!(null != a_victim) || !(0f < a_weaponDamage)) { return; } ServerNpc serverNpc = (a_victim.gameObject.layer != 9) ? null : a_victim.GetComponent <ServerNpc>(); if (null == serverNpc) { if (a_victim.gameObject.layer == 13) { ServerPlayer serverPlayer = null; ControlledChar component = a_victim.GetComponent <ControlledChar>(); serverPlayer = ((!(null != component)) ? null : component.GetServerPlayer()); if (serverPlayer == null || serverPlayer.IsSaint()) { return; } if (8f < serverPlayer.m_karma) { float num = a_weaponDamage * 0.5f * (serverPlayer.m_karma / 200f); if (IsSaint()) { num = Mathf.Max(2.5f, num); } ChangeKarmaBy(0f - num); } else if (IsSaint()) { ChangeKarmaBy(-2.5f); } } else if (a_victim.gameObject.layer == 19) { ServerBuilding component2 = a_victim.GetComponent <ServerBuilding>(); if (null != component2 && m_pid != component2.GetOwnerId() && IsSaint()) { ChangeKarmaBy(-2.5f); } } else { if (a_victim.gameObject.layer != 11) { return; } ServerVehicle component3 = a_victim.GetComponent <ServerVehicle>(); if (null != component3 && 0 < component3.GetPassengerCount()) { float num2 = a_weaponDamage * 0.25f; if (IsSaint()) { num2 = Mathf.Max(2.5f, num2); } ChangeKarmaBy(0f - num2); } } return; } int handItem = serverNpc.GetHandItem(); float num3 = Mathf.Min(serverNpc.GetLastHealth(), a_weaponDamage); float num4 = num3 * 0.2f + Items.GetWeaponXpMultiplier(handItem) * (num3 * 0.01f); if (!(0f < num4)) { return; } bool flag = true; for (int i = 0; i < m_killXp.Count; i++) { KillXp killXp = m_killXp[i]; if (killXp.player == null) { KillXp killXp2 = m_killXp[i]; if (serverNpc == killXp2.npc) { KillXp value = m_killXp[i]; value.xp += num4; value.deletetime = Time.time + 20f; m_killXp[i] = value; flag = false; break; } } } if (flag) { KillXp item = new KillXp(null, serverNpc, num4, Time.time + 20f); m_killXp.Add(item); } }
private void Start() { Init(); m_handItemDef = Items.GetItemDef(m_handItemType); m_bodyItemDef = Items.GetItemDef(m_bodyItemType); try { m_jobAi = (JobAI)m_job; } catch { } m_agent = GetComponent <NavMeshAgent>(); m_npc = GetComponent <ServerNpc>(); m_server = (LidServer)Object.FindObjectOfType(typeof(LidServer)); if (!(null != m_npc)) { return; } int num = 0; int a_chance = (int)(100f * m_dropMultiplier); if (m_npc.m_npcType == eCharType.eGasmaskGuy) { m_containerType = 120; if (m_handItemType != 0) { m_itemDrops.Add(new DropItem(m_handItemType, m_handItemType, (int)(15f * m_dropMultiplier), 1, 50)); } if (0 < m_handItemDef.ammoItemType) { m_itemDrops.Add(new DropItem(m_handItemDef.ammoItemType, m_handItemDef.ammoItemType, (int)(80f * m_dropMultiplier), 1, 10)); } if (0 < m_bodyItemType) { m_itemDrops.Add(new DropItem(m_bodyItemType, m_bodyItemType, (int)(5f * m_dropMultiplier), 1, 60)); } m_itemDrops.Add(new DropItem(1, 12, 67)); m_itemDrops.Add(new DropItem(15, 19, 67)); m_itemDrops.Add(new DropItem(254, 254, 20, 1, 5)); num = 12; } else if (m_npc.m_npcType == eCharType.eChicken || m_npc.m_npcType == eCharType.eRaven || m_npc.m_npcType == eCharType.eEagle) { m_itemDrops.Add(new DropItem(4, 4, a_chance)); num = 1; } else if (m_npc.m_npcType == eCharType.eBull || m_npc.m_npcType == eCharType.eCow) { m_itemDrops.Add(new DropItem(4, 4, a_chance, 3, 4)); m_itemDrops.Add(new DropItem(133, 133, a_chance, 3, 6)); num = 2; } else if (m_npc.m_npcType == eCharType.eMutant || m_npc.m_npcType == eCharType.eSurvivorMutant) { m_itemDrops.Add(new DropItem(104, 104, 15, 10, 90)); m_itemDrops.Add(new DropItem(254, 254, 15, 1, 3)); num = ((m_npc.m_npcType != eCharType.eMutant) ? 30 : 15); } else if (m_npc.m_npcType == eCharType.eSpider || m_npc.m_npcType == eCharType.eSpiderPoison) { m_itemDrops.Add(new DropItem(254, 254, 10, 1, 3)); num = ((m_npc.m_npcType != eCharType.eSpider) ? 15 : 3); } else { m_itemDrops.Add(new DropItem(4, 4, a_chance, 1, 3)); m_itemDrops.Add(new DropItem(133, 133, a_chance, 1, 3)); num = 1; } if (0 < num) { int randomType = Items.GetRandomType(150f); int a_max = (!Items.HasCondition(randomType)) ? 1 : Random.Range(1, 30); m_itemDrops.Add(new DropItem(randomType, randomType, num, 1, a_max)); } }
private void Start() { Init(); m_handItemDef = Items.GetItemDef(m_handItemType); m_bodyItemDef = Items.GetItemDef(m_bodyItemType); try { m_jobAi = (JobAI)m_job; } catch { } m_agent = GetComponent <NavMeshAgent>(); m_npc = GetComponent <ServerNpc>(); m_server = (LidServer)Object.FindObjectOfType(typeof(LidServer)); if (!(null != m_npc)) { return; } int num = 0; int a_chance = (int)(100f * m_dropMultiplier); if (m_npc.m_npcType == eCharType.eGasmaskGuy) // Type of enemy/mob/npc { m_containerType = 120; // container used for items dropped if (m_handItemType != 0) { m_itemDrops.Add(new DropItem(m_handItemType, m_handItemType, (int)(15f * m_dropMultiplier), 1, 50)); } if (0 < m_handItemDef.ammoItemType) { m_itemDrops.Add(new DropItem(m_handItemDef.ammoItemType, m_handItemDef.ammoItemType, (int)(80f * m_dropMultiplier), 1, 10)); } if (0 < m_bodyItemType) { m_itemDrops.Add(new DropItem(m_bodyItemType, m_bodyItemType, (int)(5f * m_dropMultiplier), 1, 60)); } m_itemDrops.Add(new DropItem(1, 12, 67)); //Items <--- Really stupid setup imo, Should be using strings globally not numbered id's m_itemDrops.Add(new DropItem(15, 19, 67)); m_itemDrops.Add(new DropItem(254, 254, 20, 1, 5)); num = 12; } else if (m_npc.m_npcType == eCharType.eChicken || m_npc.m_npcType == eCharType.eRaven || m_npc.m_npcType == eCharType.eEagle) // else if for other types { m_itemDrops.Add(new DropItem(4, 4, a_chance)); num = 1; } else if (m_npc.m_npcType == eCharType.eBull || m_npc.m_npcType == eCharType.eCow) { m_itemDrops.Add(new DropItem(4, 4, a_chance, 3, 4)); m_itemDrops.Add(new DropItem(133, 133, a_chance, 3, 6)); num = 2; } else if (m_npc.m_npcType == eCharType.eMutant || m_npc.m_npcType == eCharType.eSurvivorMutant) { m_itemDrops.Add(new DropItem(104, 104, 15, 10, 90)); // first id, second id, chance, min_quality, max_quality <--- Really stupid setup imo, Should be using strings globally not numbered id's m_itemDrops.Add(new DropItem(254, 254, 15, 1, 3)); num = ((m_npc.m_npcType != eCharType.eMutant) ? 30 : 15); } else if (m_npc.m_npcType == eCharType.eSpider || m_npc.m_npcType == eCharType.eSpiderPoison) { m_itemDrops.Add(new DropItem(254, 254, 10, 1, 3)); num = ((m_npc.m_npcType != eCharType.eSpider) ? 15 : 3); } else { m_itemDrops.Add(new DropItem(4, 4, a_chance, 1, 3)); m_itemDrops.Add(new DropItem(133, 133, a_chance, 1, 3)); num = 1; } if (0 < num) { int randomType = Items.GetRandomType(150f); int a_max = (!Items.HasCondition(randomType)) ? 1 : Random.Range(1, 30); m_itemDrops.Add(new DropItem(randomType, randomType, num, 1, a_max)); } }