private void IOnTakeDamage(EntityEffectFluid effect, EntityStats target, EntityEffectSourceData source) { if (effect == null || target == null || source?.Value == 0) { return; } var entity = target.GetComponent <AIEntity>(); if (entity != null) { Interface.CallHook("OnEntityTakeDamage", entity, source); return; } var networkView = target.GetComponent <uLinkNetworkView>(); if (networkView == null) { return; } var session = GameManager.Instance.GetSession(networkView.owner); if (session != null) { Interface.CallHook("OnPlayerTakeDamage", session, source); } }
private void IOnTakeDamage(EntityEffectFluid effect, EntityStats target, EntityEffectSourceData source) { if (effect == null || target == null || source == null || source.Value.Equals(0f)) { return; } AIEntity entity = target.GetComponent <AIEntity>(); if (entity != null) { Interface.CallHook("OnEntityTakeDamage", entity, source); return; } #if ITEMV2 HNetworkView networkView = target.networkView; #else uLink.NetworkView networkView = target.uLinkNetworkView(); #endif if (networkView != null) { PlayerSession session = GameManager.Instance.GetSession(networkView.owner); if (session != null) { Interface.CallHook("OnPlayerTakeDamage", session, source); } } }
public override void InitState(EntityStats receiver, EntityStats applier = null) { StateStack ss = receiver.GetStack(this); if (ss == null) { ss = new StateStack(this, stunDuration, 1); receiver.states.Add(ss); } else { ss.ResetTimer(); } /* receiver.canMove = false; * SkillUser su = receiver.GetComponent<SkillUser>(); * if(su){ * su.canCastSkills = false; * } */ SkillUser su = receiver.GetComponent <SkillUser>(); if (su) { su.canCastSkills = false; } receiver.stunned = true; }
public override void Run(Projectile projectile) { if (Time.time - equipTimeInstant >= duration) { entityStats.GetComponent <WeaponInventory>().SetWeapon(preClassWeapon); } }
public override void ConcludeState(EntityStats receiver) { receiver.stunned = false; SkillUser su = receiver.GetComponent <SkillUser>(); if (su) { su.canCastSkills = true; } }
private object IOnEntityEffect(StandardEntityFluidEffect effect, EntityEffectSourceData sourceData, float relativeValue) { if (sourceData == null || effect.ResolveTargetType() != EntityFluidEffectKeyDatabase.Instance?.Health) { return(null); } EntityStats stats = effect.EntityStats; if (stats == null) { return(null); } float newValue = Mathf.Clamp(effect.Value + relativeValue, effect.MinValue, effect.MaxValue); float updatedValue = newValue - effect.Value; sourceData.Value = updatedValue; AIEntity entity = stats.GetComponent <AIEntity>(); if (entity != null) { if (updatedValue > 0) { return(Interface.CallHook("OnEntityHeal", entity, sourceData)); } else if (updatedValue < 0) { return(Interface.CallHook("OnEntityTakeDamage", entity, sourceData)); } return(null); } HNetworkView networkView = stats.networkView; if (networkView != null) { PlayerSession session = GameManager.Instance.GetSession(stats.networkView.owner); if (session != null) { if (updatedValue > 0) { return(Interface.CallHook("OnPlayerHeal", session, sourceData)); } else if (updatedValue < 0) { return(Interface.CallHook("OnPlayerTakeDamage", session, sourceData)); } } } return(null); }
private void LocalAlert(EntityStats es) { if (currentTarget != null && currentTarget.tag == "Player") { switch (es.tag) { case "Enemy": es.GetComponent <EnemyMovement>().currentTarget = currentTarget; break; default: break; } } }
public void OnAdd(EntityStats owner) { PlayerStats player = owner.GetComponent <PlayerStats>(); /* General entity stats */ switch (type) { case ENT_ATTR.MOVESPEED: if (isAdditive) { owner.movementSpeed += value; } else { owner.movementSpeed *= value; } return; case ENT_ATTR.MAX_HP: if (isAdditive) { owner.maxHP += value; } else { owner.maxHP *= value; } return; case ENT_ATTR.ARMOR_STATIC: if (isAdditive) { owner.armorStatic += value; } else { owner.armorStatic *= value; } return; case ENT_ATTR.ARMOR_MULT: if (isAdditive) { owner.armorMult += value; } else { owner.armorMult *= value; } return; case ENT_ATTR.INVULNERABLE: owner.invulnerable = true; return; case ENT_ATTR.STUN: if (player) { player.lockAction(); } else { StateMovement stateMove = owner.GetComponent <StateMovement>(); if (stateMove) { stateMove.StunState(); } } return; } /* Player specific stats */ if (player) { switch (type) { case ENT_ATTR.MAX_STAMINA: if (isAdditive) { player.staminaMax += value; } else { player.staminaMax *= value; } return; case ENT_ATTR.ULTSTATUS: player.pbase.classUlt.activate(); return; } } }
public void OnRemove(EntityStats owner) { PlayerStats player = owner.GetComponent <PlayerStats>(); /* General entity stats */ switch (type) { case ENT_ATTR.MOVESPEED: if (isAdditive) { owner.movementSpeed -= value; } else { owner.movementSpeed /= value; } return; case ENT_ATTR.MAX_HP: if (isAdditive) { owner.maxHP -= value; } else { owner.maxHP /= value; } return; case ENT_ATTR.ARMOR_STATIC: if (isAdditive) { owner.armorStatic -= value; } else { owner.armorStatic /= value; } return; case ENT_ATTR.ARMOR_MULT: if (isAdditive) { owner.armorMult -= value; } else { owner.armorMult /= value; } return; case ENT_ATTR.INVULNERABLE: if (isAdditive) { owner.RemoveAttributesByType(ENT_ATTR.POISON); } owner.invulnerable = false; return; case ENT_ATTR.STUN: if (player) { player.unlockAction(); } else { StateMovement stateMove = owner.GetComponent <StateMovement>(); if (stateMove) { stateMove.RestoreState(); } } return; } /* Player specific stats */ if (player) { switch (type) { case ENT_ATTR.MAX_STAMINA: if (isAdditive) { player.staminaMax -= value; } else { player.staminaMax /= value; } return; case ENT_ATTR.ULTSTATUS: player.pbase.classUlt.deactivate(); return; } } }
//Return true if results in death public virtual bool TakeDamage(float amount, EntityStats source, bool tickDamage = false, string killerNameOverride = "") { // Invulnerability avoids damage altogether if (invulnerable) { return(false); } //player damage call damageReturnCall(); bool isPlayer = false; //damage scaling is not stored as it can update float multiplier = 1; float realDmg = amount; if (!tickDamage) { realDmg = Mathf.Max((amount - armorStatic), Mathf.Min(1, amount)) * Mathf.Max(1 - armorMult, 0); } if (transform.tag == "Player") { multiplier = Mathf.Min(1 + transform.GetComponent <PlayerStats>().dungeonLevel * 0.1f, 2); realDmg *= multiplier; PlayerPrefs.SetFloat("Hurt", PlayerPrefs.GetFloat("Hurt") + realDmg); isPlayer = true; //print("player hit"); } else { if (source is PlayerStats) { PlayerStats pStats = (PlayerStats)source; multiplier = 1 / (1 + .3f * pStats.dungeonLevel); realDmg *= multiplier; } PlayerPrefs.SetInt("Damage", PlayerPrefs.GetInt("Damage") + (int)realDmg); } //Debug.Log("Vlaue: " + realDmg); bool died = false; currentHP -= realDmg; if (currentHP <= 0) { currentHP = 0; RemoveAllAttributes(); Die(); died = true; if (source) { source.OnKill(this); //if is not the player if (isPlayer) { string killerName = source.displayName.Length > 0 ? source.displayName : source.name; if (killerName.Contains("(Clone)")) { PlayerPrefs.SetString("Killer", killerName.Substring(0, killerName.Length - 7)); } else { PlayerPrefs.SetString("Killer", killerName); } } else { PlayerPrefs.SetInt("Kills", PlayerPrefs.GetInt("Kills") + 1); } //is ranged weapon on player if (lastHitAmmoAddition != 0) { source.GetComponent <PlayerStats>().replenishAmmo(lastHitAmmoAddition); } } if (killerNameOverride != "") { PlayerPrefs.SetString("Killer", killerNameOverride); } } updateHealthBar(); return(died); }