public void attack(Weapon w, Attackable a, bool flatFooted, bool touch) { //function actually attacks AC = getArmorClass(flatFooted, touch, a); rollAttack(); Debug.Log(e.getName()+" attack roll = "+TattackRoll); if(TattackRoll == 1) { //critical miss, add some sort of fumble later Debug.Log(e.getName()+"'s attack critically misses :("); if(transform.gameObject.tag == "Player") { hitter.SetTrigger("playerAttack"); } else if(transform.gameObject.tag == "Fightable") { hitter.SetTrigger("fightableAttack"); } } else if(TattackRoll >= 21 - w.getCriticalRange()) { //critical hit rollAttack(); Debug.Log(e.getName()+" critical roll = "+TattackRoll); if(TattackRoll == 20 || TattackRoll+attackBonus(w) > AC) { Debug.Log(e.getName()+" lands a critical hit!"); for(int i = 0; i < w.getCriticalRolls(); i++) { rollDamage(w.getDamage(), w.getDamageRolls(), a); } } try { hitee = hit.transform.gameObject.GetComponent<Animator>(); if(hit.transform.gameObject.tag == "Player") { hitee.SetTrigger("playerHit"); } } catch (Exception ex) { Debug.Log(ex); } if(transform.gameObject.tag == "Player") { hitter.SetTrigger("playerAttack"); } else if(transform.gameObject.tag == "Fightable") { hitter.SetTrigger("fightableAttack"); } rollDamage(w.getDamage(), w.getDamageRolls(), a); } else if(TattackRoll == 20 || TattackRoll+attackBonus(w) > AC) { //hit try { hitee = hit.transform.gameObject.GetComponent<Animator>(); if(hit.transform.gameObject.tag == "Player") { hitee.SetTrigger("playerHit"); } } catch (Exception ex) { Debug.Log(ex); } if(transform.gameObject.tag == "Player") { hitter.SetTrigger("playerAttack"); } else if(transform.gameObject.tag == "Fightable") { hitter.SetTrigger("fightableAttack"); } rollDamage(w.getDamage(), w.getDamageRolls(), a); } else { if(transform.gameObject.tag == "Player") { hitter.SetTrigger("playerAttack"); } else if(transform.gameObject.tag == "Fightable") { hitter.SetTrigger("fightableAttack"); } } if(w.getTwoAttackRolls()) { rollAttack(); Debug.Log(e.getName()+" attack roll = "+TattackRoll); if(TattackRoll == 1) { Debug.Log(e.getName()+"'s attack critically misses :("); if(transform.gameObject.tag == "Player") { hitter.SetTrigger("playerAttack"); } else if(transform.gameObject.tag == "Fightable") { hitter.SetTrigger("fightableAttack"); } } else if(TattackRoll < 21 - w.getCriticalRange()) { rollAttack(); Debug.Log(e.getName()+" critical roll = "+TattackRoll); if(TattackRoll == 20 || TattackRoll+attackBonus(w) > AC) { Debug.Log(e.getName()+" lands a critical hit!"); if(w.getTwoCriticalRolls()) { for(int i = 0; i < w.getSecondAttackCritical(); i++) { rollDamage(w.getSecondAttackDamage(), w.getDamageRolls(), a); } } else { for(int i = 0; i < w.getCriticalRolls(); i++) { rollDamage(w.getSecondAttackDamage(), w.getDamageRolls(), a); } } } try { hitee = hit.transform.gameObject.GetComponent<Animator>(); if(hit.transform.gameObject.tag == "Player") { hitee.SetTrigger("playerHit"); } } catch (Exception ex) { Debug.Log(ex); } if(transform.gameObject.tag == "Player") { hitter.SetTrigger("playerAttack"); } else if(transform.gameObject.tag == "Fightable") { hitter.SetTrigger("fightableAttack"); } rollDamage(w.getSecondAttackDamage(), w.getDamageRolls(), a); } else if(TattackRoll == 20 || TattackRoll+attackBonus(w) > AC) { try { hitee = hit.transform.gameObject.GetComponent<Animator>(); if(hit.transform.gameObject.tag == "Player") { hitee.SetTrigger("playerHit"); } } catch (Exception ex) { Debug.Log(ex); } if(transform.gameObject.tag == "Player") { hitter.SetTrigger("playerAttack"); } else if(transform.gameObject.tag == "Fightable") { hitter.SetTrigger("fightableAttack"); } rollDamage(w.getSecondAttackDamage(), w.getDamageRolls(), a); } else { if(transform.gameObject.tag == "Player") { hitter.SetTrigger("playerAttack"); } else if(transform.gameObject.tag == "Fightable") { hitter.SetTrigger("fightableAttack"); } } } }