public static SpawnHitImpact ( string ImpactName, Vector3 ImpactPosition, int StartFrame, int EndFrame ) : void | ||
ImpactName | string | |
ImpactPosition | Vector3 | |
StartFrame | int | |
EndFrame | int | |
리턴 | void |
/// <summary> /// Handles throwing objects into lava. /// </summary> /// <param name="obj"></param> /// <param name="position"></param> /// Does not include handling of the talismans which use the larger shrine lava trigger. protected override void TileContactEvent(ObjectInteraction obj, Vector3 position) { if (obj.item_id != 456) { Impact.SpawnHitImpact(456, position, 9, 12); if (IsObjectDestroyable(obj)) { ObjectInteraction.DestroyObjectFromUW(obj); } } }
public static void DestroyOrb(ObjectInteraction orbToDestroy) { //Spawn an impact Impact.SpawnHitImpact(Impact.ImpactDamage(), orbToDestroy.GetImpactPoint(), 46, 50); Quest.instance.isOrbDestroyed = true; UWCharacter.Instance.PlayerMagic.MaxMana = UWCharacter.Instance.PlayerMagic.TrueMaxMana; UWCharacter.Instance.PlayerMagic.CurMana = UWCharacter.Instance.PlayerMagic.MaxMana; //000-001-133 The orb is destroyed UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 133)); orbToDestroy.consumeObject(); }
private void ObjectHitsWater(ObjectInteraction obj, Vector3 position) { if (IsObjectDestroyable(obj)) { GameObject splash = Impact.SpawnHitImpact(453, position, splashanimstart(), splashanimstart() + 4); if (ObjectInteraction.PlaySoundEffects) { splash.GetComponent <ObjectInteraction>().aud.clip = MusicController.instance.SoundEffects[MusicController.SOUND_EFFECT_SPLASH_1]; splash.GetComponent <ObjectInteraction>().aud.Play(); } DestroyObject(obj); } }
protected override void TileContactEvent(ObjectInteraction obj, Vector3 position) { if (obj.item_id != 453) { if (IsObjectDestroyable(obj)) { GameObject splash = Impact.SpawnHitImpact(453, position, 36, 40); if (ObjectInteraction.PlaySoundEffects) { splash.GetComponent <ObjectInteraction>().aud.clip = GameWorldController.instance.getMus().SoundEffects[MusicController.SOUND_EFFECT_SPLASH_1]; splash.GetComponent <ObjectInteraction>().aud.Play(); } DestroyObject(obj); } } }
/// <summary> /// NPC hits another NPC /// </summary> /// <param name="targetNPC">Target NP.</param> /// <param name="originNPC">Origin NP.</param> public static void NPC_Hits_NPC(NPC targetNPC, NPC originNPC) { int Defence = targetNPC.GetDefence(); int Attack = originNPC.GetAttack(); int toHit = Mathf.Max(Defence - Attack, 1); int roll = Random.Range(-1, 31); int BaseDamage = Random.Range(1, originNPC.GetDamage() + 1); if (((roll >= toHit) || (roll >= 30)) && (roll > -1)) { targetNPC.ApplyAttack((short)BaseDamage, originNPC.gameObject); Impact.SpawnHitImpact(Impact.ImpactBlood(), targetNPC.GetImpactPoint(), targetNPC.objInt().GetHitFrameStart(), targetNPC.objInt().GetHitFrameEnd()); if (ObjectInteraction.PlaySoundEffects) { originNPC.objInt().aud.clip = GameWorldController.instance.getMus().SoundEffects[MusicController.SOUND_EFFECT_MELEE_HIT_1]; originNPC.objInt().aud.Play(); } } }
/// <summary> /// Detects if a talisman has been thrown into the abyss lava trigger. /// </summary> /// <param name="other">Other.</param> void OnTriggerEnter(Collider other) { if (other.gameObject.GetComponent <ObjectInteraction>() != null) { if (Quest.instance.isGaramonBuried == false) { return; } ObjectInteraction objInt = other.gameObject.GetComponent <ObjectInteraction>(); switch (objInt.item_id) { case Quest.TalismanHonour: case Quest.TalismanBook: case Quest.TalismanCup: case Quest.TalismanRing: case Quest.TalismanShield: case Quest.TalismanSword: case Quest.TalismanTaper: case Quest.TalismanTaperLit: case Quest.TalismanWine: Quest.instance.TalismansRemaining--; break; default: return; } Impact.SpawnHitImpact(Impact.ImpactMagic(), objInt.GetImpactPoint(), 40, 44); objInt.consumeObject(); //Suck the avatar into the ethereal void. if (Quest.instance.TalismansRemaining <= 0) { StartCoroutine(SuckItAvatar()); } } }
public override void onImpact(Transform tf) { base.onImpact(tf); //A big old explosion for (int i = 0; i < 3; i++) { //The flames Impact.SpawnHitImpact(Impact.ImpactMagic(), tf.position + (Random.insideUnitSphere * 0.5f), SecondaryStartFrame, SecondaryEndFrame); } foreach (Collider Col in Physics.OverlapSphere(tf.position, splashDistance)) { if (Col.gameObject != tf.gameObject) { if (Col.gameObject.GetComponent <ObjectInteraction>() != null) { Col.gameObject.GetComponent <ObjectInteraction>().Attack(splashDamage, caster); } if (Col.gameObject.GetComponent <UWCharacter>() != null) { Col.gameObject.GetComponent <UWCharacter>().ApplyDamage(splashDamage, caster); } } } }
protected virtual void Detonate(Collision collision) { HasHit = true; //Code to execute when a projectile hits a spot (for launching AOE effects) spellprop.onImpact(this.transform); ObjectInteraction objInt = collision.gameObject.GetComponent <ObjectInteraction> (); if (objInt != null) //Has the projectile hit anything { //Special code for magic spell direct hits. spellprop.onHit(objInt); //Applies damage objInt.Attack(spellprop.BaseDamage, caster); //Create a impact animation to illustrate the collision if (objInt.GetHitFrameStart() >= 0) { Impact.SpawnHitImpact(Impact.ImpactMagic(), objInt.GetImpactPoint(), objInt.GetHitFrameStart(), objInt.GetHitFrameEnd()); } } else { //Test if this is a player. if (collision.gameObject.GetComponent <UWCharacter> () != null) { int ratio = UWCharacter.Instance.getSpellResistance(spellprop); collision.gameObject.GetComponent <UWCharacter> ().ApplyDamage(spellprop.BaseDamage / ratio); spellprop.onHitPlayer(); } else { //Do a miss impact Impact.SpawnHitImpact(Impact.ImpactDamage(), this.transform.position, spellprop.impactFrameStart, spellprop.impactFrameEnd); } } DestroyProjectile(); }
/// <summary> /// The Projectile hits something. /// </summary> /// <param name="collision">Collision.</param> /// Does not impact the caster /// Calls onImpact /// Calls onHit /// Applys Attack /// Generates an impact effect void OnCollisionEnter(Collision collision) { // if (caster == null) { caster = this.gameObject; } if (collision.gameObject.name == caster.name) { //Prevents the caster from hitting themselves return; } if (HasHit == true) { //Only impact once. return; } else { HasHit = true; //Code to execute when a projectile hits a spot (for launching AOE effects) spellprop.onImpact(this.transform); ObjectInteraction objInt = collision.gameObject.GetComponent <ObjectInteraction>(); if (objInt != null) //Has the projectile hit anything { //Special code for magic spell direct hits. spellprop.onHit(objInt); //Applies damage objInt.Attack(spellprop.BaseDamage, caster); //Create a impact animation to illustrate the collision if (objInt.GetHitFrameStart() >= 0) { Impact.SpawnHitImpact(Impact.ImpactMagic(), objInt.GetImpactPoint(), objInt.GetHitFrameStart(), objInt.GetHitFrameEnd()); } } else { //Test if this is a player. if (collision.gameObject.GetComponent <UWCharacter>() != null) { collision.gameObject.GetComponent <UWCharacter>().ApplyDamage(spellprop.BaseDamage); spellprop.onHitPlayer(); } else { //Do a miss impact Impact.SpawnHitImpact(Impact.ImpactDamage(), this.transform.position, spellprop.impactFrameStart, spellprop.impactFrameEnd); } } ObjectInteraction objIntThis = this.GetComponent <ObjectInteraction>(); if (objIntThis != null) { objIntThis.objectloaderinfo.InUseFlag = 0; //Free up object slot } DestroyObject(this.gameObject); } }
/// <summary> /// Combat calculations for PC hitting an NPC /// </summary> /// <param name="playerUW">Player Character</param> /// <param name="npc">Npc.</param> /// <param name="hit">Hit.</param> public static void PC_Hits_NPC(UWCharacter playerUW, WeaponMelee currentWeapon, string StrikeName, float StrikeCharge, NPC npc, RaycastHit hit) { int attackScore = 0; int flankingbonus = 0; //need to calcu but depending on relative headings between attacker and defender. int magicbonus = 0; //currently unknown what provides this but is calculated by casting/5 + 0xA when set. short MinCharge; short MaxCharge; if (npc != null) { //recalc position to get the correct heading for the flanking bonus npc.objInt().UpdatePosition(); flankingbonus = CalcFlankingBonus(playerUW.currentHeading, npc.objInt().heading); } if (currentWeapon != null) { attackScore = (playerUW.PlayerSkills.GetSkill(Skills.SkillAttack) >> 1) + playerUW.PlayerSkills.GetSkill(currentWeapon.GetSkill()) + (playerUW.PlayerSkills.DEX / 7) + magicbonus + flankingbonus; if (GameWorldController.instance.difficulty == 0) {//bonus of 7 for easy difficulty attackScore += 7; } attackScore += currentWeapon.AccuracyBonus();//Given by the accuracy enchantments. Note in vanilla UW2 accuracy actually increases damage and not attack score. This is fixed here. MinCharge = currentWeapon.GetMinCharge(); MaxCharge = currentWeapon.GetMaxCharge(); } else { //use the unarmed calculations attackScore = (playerUW.PlayerSkills.GetSkill(Skills.SkillAttack) >> 1) + playerUW.PlayerSkills.GetSkill(Skills.SkillUnarmed) + (playerUW.PlayerSkills.DEX / 7) + magicbonus + flankingbonus; if (GameWorldController.instance.difficulty == 0) {//bonus of 7 for easy difficulty attackScore += 7; } MinCharge = WeaponMelee.GetMeleeMinCharge(); MaxCharge = WeaponMelee.GetMeleeMaxCharge(); } //Get base damage int BaseSwingDamage = GetPlayerBaseDamage(currentWeapon, StrikeName); int basePower = (short)(GameWorldController.instance.objDat.critterStats[63].Strength / 9); //the player is actually a critter so power in this case is their STR. int WeaponBonusDamage = 0; if (currentWeapon != null) { WeaponBonusDamage = currentWeapon.DamageBonus(); } else { //unarmed basePower = (short)(GameWorldController.instance.objDat.critterStats[63].Strength / 6); //the player is actually a critter so power in this case is their STR. basePower += (playerUW.PlayerSkills.GetSkill(Skills.SkillUnarmed) / 5); } //scale base damage by charge. Min damage is always 2. short Damage = (short)(basePower + BaseSwingDamage + WeaponBonusDamage); // damage % 6 no of 1D6s to calculate the actual damage and then add the remainder as a final roll 1-remainder Damage = (short)(DamageRoll((short)(Damage / 6), 6) + DamageRoll(1, (short)(Damage % 6))); //Damage is scaled by the amount of weapon charge built up. Damage = CalcAttackChargeDamage((short)StrikeCharge, MinCharge, MaxCharge, Damage); //And a flat flanking bonus Damage += (short)flankingbonus; //Min damage will be 2. Damage = (short)(Mathf.Max(Damage, 2)); Skills.SkillRollResult rollresult = Skills.SkillRoll(attackScore, npc.Defence()); bool CriticalHit = RollForCritDamage(ref Damage, rollresult); switch (rollresult) { case Skills.SkillRollResult.CriticalSuccess: case Skills.SkillRollResult.Success: { Debug.Log("Base Damage = " + ((short)(basePower + BaseSwingDamage + WeaponBonusDamage)) + " Final Damage = " + Damage); if (CriticalHit) { Impact.SpawnHitImpact(Impact.ImpactBlood(), npc.GetImpactPoint() + Vector3.up * 0.1f, npc.objInt().GetHitFrameStart(), npc.objInt().GetHitFrameEnd()); } npc.ApplyAttack(Damage, playerUW.gameObject); Impact.SpawnHitImpact(Impact.ImpactBlood(), npc.GetImpactPoint(), npc.objInt().GetHitFrameStart(), npc.objInt().GetHitFrameEnd()); if (currentWeapon != null) { ///Performs the onHit action of the melee weapon. currentWeapon.onHit(hit.transform.gameObject); } break; } case Skills.SkillRollResult.Failure: npc.ApplyAttack(0, playerUW.gameObject); npc.npc_aud.PlayCombatMissed(); break; case Skills.SkillRollResult.CriticalFailure: { npc.ApplyAttack(0, playerUW.gameObject); npc.npc_aud.PlayCombatMissed(); //Damage weapon short durability = currentWeapon.getDurability(); if (durability <= 30) { currentWeapon.SelfDamage((short)Mathf.Max(0, Random.Range(0, npc.EquipDamage + 1) - durability)); } break; } } }
/// <summary> /// Executes the melee attack after the attack has been released. /// Casts a ray from the centre of the screen in mouselook mode or from the cursor position /// Waits a period of time after the release before casting the ray. /// </summary> public override IEnumerator ExecuteMelee(string StrikeType, float StrikeCharge) { yield return(new WaitForSeconds(0.4f)); Ray ray; if (UWCharacter.Instance.MouseLookEnabled == true) { ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f)); } else { ray = Camera.main.ScreenPointToRay(Input.mousePosition); } RaycastHit hit = new RaycastHit(); if (Physics.Raycast(ray, out hit, weaponRange)) { if (!hit.transform.Equals(this.transform)) { ObjectInteraction objInt = hit.transform.gameObject.GetComponent <ObjectInteraction>(); if (objInt != null) { //Debug.Log("Hitting " + objInt.name); switch (objInt.GetItemType()) { case ObjectInteraction.NPC_TYPE: PC_Hits_NPC(UWCharacter.Instance, currWeapon, CurrentStrike, StrikeCharge, objInt.GetComponent <NPC>(), hit); break; default: Impact.SpawnHitImpact(Impact.ImpactDamage(), (ray.origin + hit.point) / 2f, DamageImpactStart, DamageImpactEnd); objInt.Attack((short)GetPlayerBaseDamage(currWeapon, CurrentStrike), UWCharacter.Instance.gameObject); break; } } else {//Probably hit a wall or tile floor Impact.SpawnHitImpact(Impact.ImpactDamage(), (ray.origin + hit.point) / 2f, DamageImpactStart, DamageImpactEnd); if (currWeapon != null) { short durability = currWeapon.getDurability(); if (durability <= 30) { currWeapon.SelfDamage((short)(Mathf.Max(0, Random.Range(1, durability + 1) - durability))); } } if (ObjectInteraction.PlaySoundEffects) { UWCharacter.Instance.aud.clip = MusicController.instance.SoundEffects[MusicController.SOUND_EFFECT_MELEE_MISS_1]; UWCharacter.Instance.aud.Play(); } } } } else { if (ObjectInteraction.PlaySoundEffects) { UWCharacter.Instance.aud.clip = MusicController.instance.SoundEffects[MusicController.SOUND_EFFECT_MELEE_MISS_1]; UWCharacter.Instance.aud.Play(); } if (currWeapon != null) { currWeapon.onHit(null); } } ///Ends the attack and wait for a period before allowing another action. AttackExecuting = false; UWHUD.instance.window.UWWindowWait(1.0f); }
//Combat calcs /// <summary> /// Combat calculations for PC hitting an NPC /// </summary> /// <param name="playerUW">Player Character</param> /// <param name="npc">Npc.</param> /// <param name="hit">Hit.</param> public static void PC_Hits_NPC(UWCharacter playerUW, WeaponMelee currentWeapon, string StrikeName, float StrikeCharge, NPC npc, RaycastHit hit) { int attackScore = 0; int BaseDamage = GetPlayerBaseDamage(currentWeapon, StrikeName); if (currentWeapon != null) { attackScore = playerUW.PlayerSkills.GetSkill(Skills.SkillAttack) / 2 + playerUW.PlayerSkills.GetSkill(currentWeapon.GetSkill() + 1); attackScore += currentWeapon.AccuracyBonus(); } else { attackScore = playerUW.PlayerSkills.GetSkill(Skills.SkillAttack) / 2 + playerUW.PlayerSkills.GetSkill(Skills.SkillUnarmed); } int toHit = Mathf.Max(npc.GetDefence() - attackScore, 0); //Difficulty is either 1 for standard or 0 for easy. int roll = Mathf.Max(30, Random.Range(-1, 31) + (5 * (1 - GameWorldController.instance.difficulty))); //-1 is critical miss. 30 is always hit int HitRollResult = 0; if (((roll >= toHit) || (roll >= 30)) && (roll > -1)) { short Damage = (short)(Mathf.Max(((float)(BaseDamage)) * (StrikeCharge / 100f), 1)); npc.ApplyAttack(Damage, playerUW.gameObject); HitRollResult = 1; if (roll == 30) { HitRollResult = 2; //crit. apply double damage npc.ApplyAttack(Damage, playerUW.gameObject); } if (roll >= 27) { HitRollResult = 2; //critical } } else { HitRollResult = 0; npc.ApplyAttack(0, playerUW.gameObject); //A zero damage attack to update ai if needed if (currentWeapon != null) { //Apply equipment damage to weapon if NPC Defence is 1.5 times attackscore if ((float)npc.GetDefence() > (float)attackScore * 1.5f) { short durability = currentWeapon.getDurability(); //currentWeapon.WeaponSelfDamage(); if (durability <= 30) { currentWeapon.SelfDamage((short)Mathf.Max(0, Random.Range(0, npc.GetArmourDamage() + 1) - durability)); } } } } ///Creates a blood splatter at the point of impact switch (HitRollResult) { case 0: //Miss //Impact.SpawnHitImpact(hit.transform.name + "_impact", npc.objInt().GetImpactPoint(),46,50); if (ObjectInteraction.PlaySoundEffects) { npc.objInt().aud.clip = GameWorldController.instance.getMus().SoundEffects[MusicController.SOUND_EFFECT_MELEE_MISS_2]; npc.objInt().aud.Play(); } break; case 1: //Hit Impact.SpawnHitImpact(Impact.ImpactBlood(), npc.objInt().GetImpactPoint(), npc.objInt().GetHitFrameStart(), npc.objInt().GetHitFrameEnd()); if (ObjectInteraction.PlaySoundEffects) { npc.objInt().aud.clip = GameWorldController.instance.getMus().SoundEffects[MusicController.SOUND_EFFECT_MELEE_HIT_1]; npc.objInt().aud.Play(); } break; case 2: //Crit Impact.SpawnHitImpact(Impact.ImpactBlood(), npc.objInt().GetImpactPoint(), npc.objInt().GetHitFrameStart(), npc.objInt().GetHitFrameEnd()); Impact.SpawnHitImpact(Impact.ImpactBlood(), npc.objInt().GetImpactPoint() + Vector3.up * 0.1f, npc.objInt().GetHitFrameStart(), npc.objInt().GetHitFrameEnd()); if (ObjectInteraction.PlaySoundEffects) { npc.objInt().aud.clip = GameWorldController.instance.getMus().SoundEffects[MusicController.SOUND_EFFECT_MELEE_HIT_2]; npc.objInt().aud.Play(); } break; } if (currentWeapon != null) { ///Performs the onHit action of the melee weapon. currentWeapon.onHit(hit.transform.gameObject); } }