//private float mPropTimer = 3; public override void Update(float deltaTime) { base.Update(deltaTime); lightTimer -= deltaTime; heavyTimer -= deltaTime; lightTimer = Mathf.ClampLess(lightTimer, -1); heavyTimer = Mathf.ClampLess(heavyTimer, -1); if (!hasWeapon) { return; } nebulaObject.properties.SetProperty((byte)PS.LightShotReady, lightReady); nebulaObject.properties.SetProperty((byte)PS.HeavyShotReady, heavyReady); nebulaObject.properties.SetProperty((byte)PS.LightShotReloadTimer, lightTimer); nebulaObject.properties.SetProperty((byte)PS.HeavyShotReloadTimer, heavyTimer); //if (mPlayer) { // mPropTimer -= deltaTime; // if(mPropTimer < 0) { // mPropTimer = 3; // nebulaObject.properties.SetProperty((byte)PS.Damage, GetDamage(false)); // nebulaObject.properties.SetProperty((byte)PS.CritDamage, GetDamage(true)); // nebulaObject.properties.SetProperty((byte)PS.CritChance, criticalChance); // nebulaObject.properties.SetProperty((byte)PS.OptimalDistance, optimalDistance); // } //} }
//private bool IsHitted(NebulaObject target, ref WeaponHitInfo hit) { // if(hit.normal) { // if(BlockedByDistance(target)) { // hit.Interrupt(ShotState.blockedByDistance); // return false; // } else { // float hitProb = 1.0f - ComputeMissProb(target); // hitProb = Mathf.ClampLess(hitProb, 0.0f); // if (Rand.Float01() <= hitProb) { // hit.Interrupt(ShotState.missed); // return false; // } else { // return true; // } // } // } // return false; //} private void CheckWeaponHit(NebulaObject target, WeaponHitInfo hit) { float hitProb = 1.0f - ComputeMissProb(target); hitProb = Mathf.ClampLess(hitProb, 0.0f); if (Rand.Float01() > hitProb) { hit.Interrupt(ShotState.missed); } }
public void Update(float deltaTime) { if (data.IsEmpty) { return; } // GetExecutor().Update(skills, deltaTime); mTimer -= deltaTime; mTimer = Mathf.ClampLess(mTimer, -1); }
/// <summary> /// Called by ally player target when he is receive damage, and move damage to me if 404 skill active /// </summary> /// <param name="inputDamage"></param> /// <param name="outputDamage"></param> /// <returns></returns> public bool MoveDamageFromAlly(float inputDamage, ref float outputDamage) { outputDamage = inputDamage; if (m404.active) { float eatedDamage = inputDamage * m404.value; outputDamage = Mathf.ClampLess(inputDamage - eatedDamage, 0); nebulaObject.Damagable().SubHealth(eatedDamage); //log.InfoFormat("eat ally damage = {0}", eatedDamage); return(true); } return(false); }
private void GiveExpAndPvpPointsToPlayer(NebulaObject playerObject, NebulaObject owner, float difficulty, float npcLevel, float npcMaxHealth) { int baseExp = 20; float playerLevel = GetLevel(playerObject); float levelRat = npcLevel / playerLevel; float bexp = (difficulty * levelRat * (baseExp)); float hpExp = difficulty * Mathf.ClampLess(npcMaxHealth - 1000, 0f) * 0.01f; if (levelRat < 1.0f) { hpExp *= levelRat; } int exp = (int)Math.Round(bexp + hpExp); s_Log.InfoFormat("sended exp = {0} for bot difficulty = {1}, hp exp bonus = {2}", exp, difficulty, (int)(difficulty * Mathf.ClampLess(npcMaxHealth - 1000, 0f) * 0.01f)); playerObject.GetComponent <PlayerCharacterObject>().AddExp(exp); playerObject.SendMessage(ComponentMessages.OnEnemyDeath, owner); GivePvpPoints(playerObject, owner, npcLevel, (int)playerLevel); }
public override bool TryCast(NebulaObject source, PlayerSkill skill, out Hashtable info) { info = new Hashtable(); var ship = source.PlayerShip(); if (!ship) { return(false); } float hpPc = skill.GetFloatInput("hp_pc"); float maxResist = skill.GetFloatInput("max_resist"); float speedPc = skill.GetFloatInput("speed_pc"); float time = skill.GetFloatInput("time"); var damagable = source.Damagable(); var bonuses = source.Bonuses(); bool mastery = RollMastery(source); if (mastery) { time *= 2; } if (damagable.health < damagable.maximumHealth * hpPc) { float currentResistance = ship.commonResist; float resistanceDifference = Mathf.ClampLess(maxResist - currentResistance, 0f); Buff buff = new Buff(skill.data.Id.ToString(), null, Common.BonusType.increase_resist_on_cnt, time, resistanceDifference); bonuses.SetBuff(buff, source); } Buff speedBuff = new Buff(skill.data.Id.ToString(), null, Common.BonusType.increase_speed_on_pc, time, speedPc); bonuses.SetBuff(speedBuff, source); return(true); }
public virtual Hashtable Heal(NebulaObject targetObject, float healValue, int skillID = -1, bool generateCrit = true) { MakeMeVisible(); WeaponDamage notCritDmg = GetDamage(false); WeaponDamage critDmg = GetDamage(true); float ratio = critDmg.totalDamage / notCritDmg.totalDamage; healValue = Mathf.ClampLess(healValue * (1.0f + cachedBonuses.healingPcBonus) + cachedBonuses.healingCntBonus, 0f); bool isCritHeal = false; if (generateCrit) { if (Rand.Float01() < criticalChance) { isCritHeal = true; healValue *= ratio; } } var targetDamaable = targetObject.Damagable(); targetDamaable.RestoreHealth(nebulaObject, healValue); nebulaObject.SendMessage(ComponentMessages.OnMakeHeal, healValue); StartHealDron(targetDamaable, healValue); if (isCritHeal) { nebulaObject.SendMessage(ComponentMessages.OnCriticalHeal, healValue); } return(ConstructHealMessage(nebulaObject, targetObject, cachedCharacter.workshop, skillID, healValue, isCritHeal)); }
public void ClampLess(float val) { m_RocketDamage = Mathf.ClampLess(m_RocketDamage, val); m_LaserDamage = Mathf.ClampLess(m_LaserDamage, val); m_AcidDamage = Mathf.ClampLess(m_AcidDamage, val); }
protected float GetSpeedWithBonuses(float inputSpeed) { return(Mathf.ClampLess(inputSpeed * (1.0f + bonuses.speedPcBonus) + bonuses.speedCntBonus, 0.0f)); }
public GeneratedSetInfo GenerateSet(int level, Workshop workshop, ShipModelSlotType slotType) { List <ModuleInfo> filteredModules = new List <ModuleInfo>(); var moduleList = resources.ModuleTemplates.ModulesWithSet(workshop, slotType); foreach (var module in moduleList) { foreach (var moduleSet in module.allowedSets) { var setResource = resources.Sets.Set(moduleSet.Trim()); if (setResource.UnlockLevel <= level && setResource.Workshop == workshop) { filteredModules.Add(module); } } } if (filteredModules.Count == 0) { return(new GeneratedSetInfo { setId = string.Empty, moduleTemplateId = string.Empty }); } var targetModule = filteredModules[Rand.Int(0, filteredModules.Count - 1)]; List <ModuleSetData> setList = new List <ModuleSetData>(); foreach (var set in targetModule.allowedSets) { var checkedSet = resources.Sets.Set(set); if (checkedSet.UnlockLevel <= level && checkedSet.Workshop == workshop) { setList.Add(checkedSet); } } var defaultSet = setList.Where(set => set.IsDefault).FirstOrDefault(); if (defaultSet == null) { return(new GeneratedSetInfo { setId = string.Empty, moduleTemplateId = string.Empty }); } List <ModuleSetData> tempList = new List <ModuleSetData>(); foreach (var set in setList) { if (false == set.IsDefault) { tempList.Add(set); } } tempList.Add(defaultSet); float[] weights = new float[tempList.Count]; float acc = 0f; for (int i = 0; i < weights.Length - 1; i++) { weights[i] = tempList[i].DropProb; acc += weights[i]; } weights[weights.Length - 1] = Mathf.ClampLess(1f - acc, 0f); int index = Rand.RandomIndex(weights); ModuleSetData finalSetModule = tempList[index]; return(new GeneratedSetInfo { setId = finalSetModule.Id, moduleTemplateId = targetModule.Id }); }