IEnumerator UseMoveCo(AtkTurn theturn) { double dam = 0; double origdam = 0; int paracheck = 100; int numhits = 0; bool multihit = false; bool mixedupfail = false; Monster.SubMonster atk = theturn.atk; Monster.SubMonster def = theturn.def; Move.SubMove themove = theturn.atkmove; int typecheck = Types.CheckWeakness(themove.type, def.Type); bool statimmune = false; bool dodamage = themove.dodamage; bool movefailed = false; if (themove.self) { statimmune = true; } if (themove.status == Monster.Status.none) { statimmune = true; } TheQueue.AddQueue(atk.Name + " used " + themove.Name + "!"); //separate if (atk.status.Contains(Monster.Status.paralyze) || atk.status.Contains(Monster.Status.frozen)) { paracheck = (int)UnityEngine.Random.Range((int)0, (int)3); if (paracheck != 0) { TheQueue.AddQueue(atk.Name + "'s status prevented it from moving!"); usingmove = false; yield break; } } else if (atk.status.Contains(Monster.Status.asleep)) { if ((int)UnityEngine.Random.Range((int)0, (int)5) == 0) { TheQueue.AddQueue(atk.Name + " is still sleeping!"); TheQueue.AddQueue(atk.Name + " just woke up"); atk.SetStatus(Monster.Status.none, 1); while (TheQueue.QCount() > 0) { yield return(new WaitForEndOfFrame()); } UpStats(); } else { TheQueue.AddQueue(atk.Name + " is still sleeping!"); usingmove = false; yield break; } } themove.Use(); if (def.status.Contains(Monster.Status.evading)) { if ((themove.dodamage || (!themove.self && themove.status != Monster.Status.none))) { if ((int)UnityEngine.Random.Range((int)0, (int)4) > 0) { TheQueue.AddQueue(def.Name + " evaded the move!"); if (themove.hurtself) { TheQueue.AddQueue(atk.Name + " hurt itself!"); while (TheQueue.QCount() > 0) { yield return(new WaitForEndOfFrame()); } TheQueue.AddQueue("It caused " + themove.hurtselfdam + " damage!"); UpHealth(); atk.Damage(themove.hurtselfdam); if (atk.isDead()) { TheQueue.AddQueue(atk.Name + " died!!!"); } } usingmove = false; yield break; } } } dam = themove.GiveDam(); dam *= (1 + (atk.ATK / 200)); dam = System.Math.Round(dam, 2); //maybe move this switch statement within themove.hit() if (themove.dodamage || !statimmune) { switch (def.thequirk.quirk) { case Monster.QuirkType.none: break; case Monster.QuirkType.bouncer: if (themove.mt == def.thequirk.afmt && themove.dodamage) { TheQueue.AddQueue(def.Name + "'s " + def.thequirk.Name + " caused the move to bounce back!"); //,false); atk.Damage(dam / 2); while (TheQueue.QCount() > 0) { yield return(new WaitForEndOfFrame()); } UpHealth(); dodamage = false; movefailed = true; while (TheQueue.QCount() > 0) { yield return(new WaitForEndOfFrame()); } UpHealth(); TheQueue.AddQueue("It caused " + dam / 2 + " damage!"); //,true); if (!themove.hurtself) { usingmove = false; yield break; } } break; case Monster.QuirkType.dodger: if (themove.mt == def.thequirk.afmt && themove.dodamage) { if ((int)UnityEngine.Random.Range(0, 2) == 0) { break; } else { dodamage = false; movefailed = true; TheQueue.AddQueue(def.Name + "'s " + def.thequirk.Name + " caused them to dodge!"); //,false); if (!themove.hurtself) { usingmove = false; yield break; } } } break; case Monster.QuirkType.givestatus: if (themove.mt == def.thequirk.afmt && themove.dodamage && !atk.status.Contains(def.thequirk.givestatus)) { if (atk.thequirk.quirk == Monster.QuirkType.statimmune) { if (atk.thequirk.givestatus == def.thequirk.givestatus) { break; } else { TheQueue.AddQueue("The move caused a status rebound!"); atk.SetStatus(def.thequirk.givestatus, def.thequirk.statlen); while (TheQueue.QCount() > 0) { yield return(new WaitForEndOfFrame()); } UpStats(); } } else { TheQueue.AddQueue("The move caused a status rebound!"); atk.SetStatus(def.thequirk.givestatus, def.thequirk.statlen); //unless the attacker is immune to this status effect } } break; case Monster.QuirkType.healer: if (def.thequirk.aftype == themove.type && themove.dodamage) { dodamage = false; movefailed = true; TheQueue.AddQueue("The moved caused " + def.Name + " to heal!"); def.Heal(def.thequirk.healhurt); while (TheQueue.QCount() > 0) { yield return(new WaitForEndOfFrame()); } UpHealth(); if (!themove.hurtself) { usingmove = false; yield break; } } break; case Monster.QuirkType.healerMT: if (def.thequirk.afmt == themove.mt && themove.dodamage) { movefailed = true; dodamage = false; //add quirk name TheQueue.AddQueue("The moved caused " + def.Name + " to heal!"); def.Heal(def.thequirk.healhurt); while (TheQueue.QCount() > 0) { yield return(new WaitForEndOfFrame()); } UpHealth(); if (!themove.hurtself) { usingmove = false; yield break; } } break; case Monster.QuirkType.hurter: if (def.thequirk.afmt == themove.mt && themove.dodamage) { //add quirk name TheQueue.AddQueue("The moved caused " + atk.Name + " to take " + def.thequirk.healhurt + " damage!"); atk.Damage(def.thequirk.healhurt); while (TheQueue.QCount() > 0) { yield return(new WaitForEndOfFrame()); } UpHealth(); //if (atkr.isDead()) return; } break; case Monster.QuirkType.hurterT: if (def.thequirk.aftype == themove.type && themove.dodamage) { //add quirk name TheQueue.AddQueue("The moved caused " + atk.Name + " to take damage!"); atk.Damage(def.thequirk.healhurt); while (TheQueue.QCount() > 0) { yield return(new WaitForEndOfFrame()); } UpHealth(); //if (atkr.isDead()) return; } break; case Monster.QuirkType.mtimmune: if (themove.mt == def.thequirk.afmt && themove.dodamage) { movefailed = true; //add quirk name dodamage = false; TheQueue.AddQueue(def.Name + " is immune to this type of move!"); if (!themove.hurtself) { usingmove = false; yield break; } } break; case Monster.QuirkType.statimmune: if (themove.status == def.thequirk.givestatus && !themove.self) { //add quirk name statimmune = true; TheQueue.AddQueue(def.Name + " is immune to " + themove.Name + "'s status effect!"); } break; case Monster.QuirkType.typeimmune: if (themove.type == def.thequirk.aftype && themove.dodamage) { //add quirk name dodamage = false; movefailed = true; TheQueue.AddQueue(def.Name + " is immune to this type!"); if (!themove.hurtself) { usingmove = false; yield break; } } break; } } if (themove.Hit()) { if (dodamage) { dam = themove.GiveDam(); dam *= (1 + (atk.ATK / 200)); //dam = System.Math.Round(dam, 2); if (atk.status.Contains(Monster.Status.doubled)) { dam *= 2; TheQueue.AddQueue(atk.Name + "'s status caused double damage!"); } if (atk.status.Contains(Monster.Status.halved)) { dam *= .5; TheQueue.AddQueue(atk.Name + "'s status caused half damage!"); } if (atk.status.Contains(Monster.Status.high)) { dam *= .7; TheQueue.AddQueue(atk.Name + "'s status caused reduced damage!"); } if (atk.status.Contains(Monster.Status.mixedup)) { if ((int)UnityEngine.Random.Range((int)0, (int)2) == 0) { TheQueue.AddQueue(atk.Name + " hurt itself instead!"); dam = System.Math.Round(dam, 2); atk.Damage(dam / 2); while (TheQueue.QCount() > 0) { yield return(new WaitForEndOfFrame()); } UpHealth(); TheQueue.AddQueue("It did " + dam / 2 + " damage!"); mixedupfail = true; dodamage = false; statimmune = true; } } if (def.status.Contains(Monster.Status.annoyed) && !mixedupfail) { //print("poopoo"); dam *= 1.4; TheQueue.AddQueue(def.Name + "'s status caused increased damage!"); } if (def.status.Contains(Monster.Status.cold) && !mixedupfail) { dam *= 1.4; TheQueue.AddQueue(def.Name + "'s status caused increased damage!"); } if (dodamage) { if (typecheck == 2) { TheQueue.AddQueue("MEGA WEAKNESS! INSTAKILL!"); dam *= 3000; } else if (typecheck == 1) { TheQueue.AddQueue("Super effective!"); dam *= 2; /*if (themove.Crit()) * { * dam *= 2; * TheQueue.AddQueue("Critical hit!"); * }*/ //def.Damage(dam); //TheQueue.AddQueue("It did " + dam + " damage!"); } else if (typecheck == 0) { /*if (themove.Crit()) * { * dam *= 1.5; * TheQueue.AddQueue("Critical hit!"); * }*/ //Damage(dam); //TheQueue.AddQueue("It did " + dam + " damage!"); } else if (typecheck == -1) { TheQueue.AddQueue("Not very effective"); dam /= 1.5; //Damage(dam); //TheQueue.AddQueue("It did " + dam + " damage!"); } else if (typecheck == -2) { movefailed = true; statimmune = true; dodamage = false; mixedupfail = true; TheQueue.AddQueue("The move had no effect!"); } else if (typecheck == -3) { movefailed = true; dodamage = false; mixedupfail = true; TheQueue.AddQueue("The move caused " + dam + " points of healing!"); def.Heal(dam); statimmune = true; } if (!mixedupfail) { dam = Math.Round(dam, 2); origdam = dam; if (themove.multihit && UnityEngine.Random.Range(0, 100f) < themove.MHP) { multihit = true; TheQueue.AddQueue("Multi hit move!"); } if (!multihit) { if (themove.Crit()) { dam *= 1.5; TheQueue.AddQueue("Critical hit!"); } TheQueue.AddQueue("It did " + dam + " damage!"); def.Damage(dam); while (TheQueue.QCount() > 0) { yield return(new WaitForEndOfFrame()); } UnityEngine.Random.InitState((int)System.DateTime.Now.Ticks); UpHealth(); } else if (multihit) { if (themove.Crit()) { dam *= 1.5; TheQueue.AddQueue("Critical hit!"); } TheQueue.AddQueue("First hit did " + dam + " damage!"); def.Damage(dam); while (TheQueue.QCount() > 0) { yield return(new WaitForEndOfFrame()); } UnityEngine.Random.InitState((int)System.DateTime.Now.Ticks); UpHealth(); numhits = 2; dam = origdam * (double)UnityEngine.Random.Range(.9f, 1.1f); dam = Math.Round(dam, 2); if (themove.Crit()) { dam *= 1.5; TheQueue.AddQueue("Critical hit!"); } TheQueue.AddQueue("Second hit did " + dam + " damage!"); def.Damage(dam); while (TheQueue.QCount() > 0) { yield return(new WaitForEndOfFrame()); } UpHealth(); if (themove.maxhits > 2) { for (int i = 3; i <= themove.maxhits; i++) { if (UnityEngine.Random.Range(0, 100f) < themove.MHP) { dam = origdam * (double)UnityEngine.Random.Range(.8f, 1.2f); dam = Math.Round(dam, 2); if (themove.Crit()) { dam *= 1.5; TheQueue.AddQueue("Critical hit!"); } def.Damage(dam); while (TheQueue.QCount() > 0) { yield return(new WaitForEndOfFrame()); } UpHealth(); UnityEngine.Random.InitState((int)System.DateTime.Now.Ticks); numhits = i; TheQueue.AddQueue("Hit " + i + " did " + dam + " damage!"); } else { break; } } } TheQueue.AddQueue(numhits + " hits!"); } } } } if (!def.isDead() && !statimmune && themove.status != Monster.Status.none) { def.SetStatus(themove.status, themove.statlen); } //else if (!def.isDead() && !statimmune && themove.status != Monster.Status.none && def.status != Monster.Status.none && themove.statoverride) //def.SetStatus(themove.status, themove.statlen); else if (!def.isDead() && themove.status != Monster.Status.none && !themove.self && statimmune) { TheQueue.AddQueue(themove.Name + "'s status effect failed!"); } while (TheQueue.QCount() > 0) { yield return(new WaitForEndOfFrame()); } UpStats(); if (themove.hurtself) { TheQueue.AddQueue(atk.Name + " hurt itself!"); TheQueue.AddQueue("It caused " + themove.hurtselfdam + " damage!"); //health bar animation atk.Damage(themove.hurtselfdam); while (TheQueue.QCount() > 0) { yield return(new WaitForEndOfFrame()); } UpHealth(); } else if (themove.healself && !movefailed) { TheQueue.AddQueue(themove.Name + " caused " + atk.Name + " to heal!"); TheQueue.AddQueue(atk.Name + " healed " + themove.hurtselfdam + " health!"); //health bar animation atk.Heal(themove.hurtselfdam); } if (themove.self && !atk.status.Contains(themove.status) && !atk.isDead()) { TheQueue.AddQueue(themove.Name + " gave " + atk.Name + " a status effect!"); atk.SetStatus(themove.status, themove.statlen); statimmune = true; while (TheQueue.QCount() > 0) { yield return(new WaitForEndOfFrame()); } //if(themove.healself) //return; } /*else if (themove.self && atk.status != Monster.Status.none && themove.statoverride && !atk.isDead()) * { * TheQueue.AddQueue(themove.Name + " gave " + atk.Name + " a status effect!"); * atk.SetStatus(themove.status, themove.statlen); * statimmune = true; * }*/ else if (themove.self && atk.status.Contains(themove.status) && !atk.isDead()) { TheQueue.AddQueue(atk.Name + " failed to give itself a status effect!"); } if (def.isDead()) { TheQueue.AddQueue(def.Name + " died!!!"); } if (atk.isDead()) { TheQueue.AddQueue(atk.Name + " died!!!"); } } else { TheQueue.AddQueue(atk.Name + "'s attack missed!"); } //UpStats(); usingmove = false; }
IEnumerator MonTurn(TurnType tt) { switch (tt) { case TurnType.none: break; case TurnType.attack: atkturn.atk = p2mon; atkturn.def = p1mon; atkturn.atkmove = turnmove2; usingmove = true; StartCoroutine("UseMoveCo", atkturn); while (TheQueue.QCount() > 0) { yield return(new WaitForEndOfFrame()); } UpHealth(); break; case TurnType.change: p2mon = changeto2; changeto2 = new Monster.SubMonster(); UpHealth(); TheQueue.AddQueue("P2 has changed m0nst3rz to " + p2mon.Name + "!"); break; } while (TheQueue.QCount() > 0) { yield return(new WaitForEndOfFrame()); } if (!p2mon.isDead()) { p2mon.StatLenUpdate(); while (TheQueue.QCount() > 0) { yield return(new WaitForEndOfFrame()); } UpHealth(); } if (p1mon.isDead() && p2mon.isDead()) { TheQueue.AddQueue("Both m0nst3rz have died!"); player1.moninv.RemoveMonster(p1mon); p1mon = new Monster.SubMonster(); player2.moninv.RemoveMonster(p2mon); p2mon = new Monster.SubMonster(); if (player1.moninv.HasAnActive() && player2.moninv.HasAnActive()) { TheQueue.curdead = true; while (p1mon.Name == "" || p2mon.Name == "") { yield return(new WaitForEndOfFrame()); } } else if (!player1.moninv.HasAnActive() && !player2.moninv.HasAnActive()) { TheQueue.AddQueue("It's a tie!!!"); } else if (!player2.moninv.HasAnActive()) { TheQueue.AddQueue("P1 out of m0nst3rz!"); TheQueue.AddQueue("P2 wins!!!"); } else if (!player1.moninv.HasAnActive()) { TheQueue.AddQueue("P2 out of m0nst3rz!"); TheQueue.AddQueue("P1 wins!!!"); } yield break; } else if (p1mon.isDead()) { player1.moninv.RemoveMonster(p1mon); if (player1.moninv.HasAnActive()) { //player1.moninv.RemoveMonster(p1mon); p1mon = new Monster.SubMonster(); TheQueue.curdead = true; while (p1mon.Name == "") { yield return(new WaitForEndOfFrame()); } } else { //player1.moninv.RemoveMonster(p1mon); p1mon = new Monster.SubMonster(); TheQueue.AddQueue("P1 is out of m0nst3rz!!!"); TheQueue.AddQueue("P2 Wins!"); //TheQueue.gohome = true; //DISCONNECT yield break; } } else if (p2mon.isDead()) { player2.moninv.RemoveMonster(p2mon); if (player2.moninv.HasAnActive()) { //player2.moninv.RemoveMonster(p2mon); p2mon = new Monster.SubMonster(); TheQueue.curdead = true; while (p2mon.Name == "") { yield return(new WaitForEndOfFrame()); } } else { //player1.moninv.RemoveMonster(p1mon); p2mon = new Monster.SubMonster(); TheQueue.AddQueue("P2 is out of m0nst3rz!!!"); TheQueue.AddQueue("P1 Wins!"); //TheQueue.gohome = true; //DISCONNECT yield break; } } if (TheQueue.QCount() == 0) { turn2 = false; } }