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); } }
public void Progress(float a_deltaTime) { if (!IsSpawned()) { return; } DatabaseItem itemFromPos = m_inventory.GetItemFromPos(0f, 0f); ItemDef itemDef = Items.GetItemDef(itemFromPos.type); bool flag = itemDef.buildingIndex > 0; if (!IsDead()) { UpdateConditions(a_deltaTime); CalculateEnergyHealthKarma(a_deltaTime); if (m_attackBtnPressed) { if (m_server.IsInSpecialArea(GetPosition(), eAreaType.noPvp) || (flag && !Buildings.IsHarmless(itemDef.buildingIndex) && m_server.IsInSpecialArea(GetPosition(), eAreaType.noBuilding))) { if (Time.time > m_nextForbiddenEventTime) { m_server.SendSpecialEvent(this, eSpecialEvent.forbidden); m_nextForbiddenEventTime = Time.time + 1f; } } else if (null == m_vehicle) { TryAttack(itemFromPos.type, itemDef); } } HandleRotation(); DatabaseItem itemFromPos2 = m_inventory.GetItemFromPos(0f, 3f); ItemDef itemDef2 = Items.GetItemDef(itemFromPos2.type); float num = (!Items.IsShoes(itemFromPos2.type)) ? 0f : itemDef2.healing; num -= ((!HasCondition(eCondition.pain)) ? 0f : 0.2f); m_char.AddSpeed(num); if (Items.IsShoes(itemFromPos2.type) && m_isMoving && null == m_vehicle) { DamageItem(0f, 3f); } } m_char.m_isWalking = (IsAttacking() || itemDef.buildingIndex > 0); if (m_respawnTime > 0f && Time.time > m_respawnTime) { Respawn(); m_respawnTime = -1f; } int num2 = 0; bool flag2; while (true) { if (num2 >= m_killXp.Count) { return; } float time = Time.time; KillXp killXp = m_killXp[num2]; flag2 = (time > killXp.deletetime); KillXp killXp2 = m_killXp[num2]; if (null != killXp2.npc) { KillXp killXp3 = m_killXp[num2]; if (killXp3.npc.GetHealth() == 0f) { break; } } KillXp killXp4 = m_killXp[num2]; if (killXp4.player != null) { KillXp killXp5 = m_killXp[num2]; if (killXp5.player.IsDead()) { break; } } if (flag2) { break; } num2++; } if (!flag2) { KillXp killXp6 = m_killXp[num2]; AddXp((int)killXp6.xp); } m_killXp.RemoveAt(num2); }