def goalie(me, my_teammate, opponent1, opponent2, ball, strategy, one_v_one=False): global _ball_defend_position, _offensive, _defensive, _neutral global _recently_kicked, _kicker_wait_counter, _KICKER_WAIT_MAX # This prevents the goalie from kicking the ball too often _kicker_wait_counter = _kicker_wait_counter + 1 if _kicker_wait_counter >= _KICKER_WAIT_MAX: _recently_kicked = False _kicker_wait_counter = 0 # First, check to see if the ball is close enough to actuate the kicker, and kick it away (x_pos, y_pos) = Utilities.get_front_of_robot(me) distance_from_kicker_to_ball = Utilities.get_distance_between_points( x_pos, y_pos, ball.xhat, ball.yhat) if (distance_from_kicker_to_ball <= Constants.kickable_distance and not Utilities.is_ball_behind_robot(me, ball)): if not _recently_kicked: print "GOALIE KICKING BALL AWAY" Skills.kick() _recently_kicked = True if Utilities.is_ball_behind_robot(me, ball): return Skills.avoid_own_goal(me, ball) elif strategy == _offensive and Utilities.am_i_closest_teammate_to_ball( me, my_teammate, ball) and Utilities.am_i_closer_to_ball_than_opponents( me, opponent1, opponent2, ball): return Skills.attack_ball(me, ball) # Goalie is always defending the goal in an arc else: theta_c = Utilities.get_angle_between_points( Constants.goal_position_home[0], Constants.goal_position_home[1], ball.xhat_future, ball.yhat_future) # theta_c_future = Utilities.get_angle_between_points(Constants.goal_position_home[0], Constants.goal_position_home[1], ball.xhat_future, ball.yhat_future) theta_c_deg = Utilities.rad_to_deg(theta_c) x_c = Constants.goal_position_home[ 0] + Constants.goalie_radius * np.cos(theta_c) y_c = Constants.goal_position_home[ 1] + Constants.goalie_radius * np.sin(theta_c) #Updating global variable that will predict where the ball will intersect with the "goalie arc" and maintain that position if abs(ball.xhat_future) > abs(x_c): if _ball_defend_position is None: _ball_defend_position = ball else: _ball_defend_position = None if _ball_defend_position is not None: y_c = _ball_defend_position.yhat_future return (x_c, y_c, theta_c_deg)
def Eleven(Unit): u = Unit uHP = WSD[Unit].HP uENE = WSD[Unit].ENE uSTR = WSD[Unit].STR uSPR = WSD[Unit].SPR uSKL = WSD[Unit].SKL uABL = WSD[Unit].ABL uAGI = WSD[Unit].AGI uEVA = WSD[Unit].EVA uTGH = WSD[Unit].TGH uRES = WSD[Unit].RES uLCK = WSD[Unit].LCK uPAR = WSD[Unit].PAR uMAR = WSD[Unit].MAR uWT = WSD[Unit].ArmorWT choice = input( "Select something!\n [St]atcheck!\n [TT] Tin Talis!\n [I]nventory!\n ") if choice == "ST" or choice == "St" or choice == "st": print("-----------------") print("HP:", uHP) print("ENE:", uENE) print("STR:", uSTR) print("SPR:", uSPR) print("SKL:", uSKL) print("ABL:", uABL) print("AGI:", uAGI) print("EVA:", uEVA) print("TGH:", uTGH) print("RES:", uRES) print("LCK:", uLCK) print("PAR:", uPAR) print("MAR:", uMAR) print("WT:", uWT) print("-----------------") if choice == "TT" or choice == "tt": choice = input( "Select an action!\n [Q]uick!\n [N]ormal!\n [H]ard!\n ==SKILLS==\n [FB] Flame Blast!\n [WG] Water Grenade!\n [SB] Stun Bolt!\n " ) if choice == "Q" or choice == "q": AttacksOO.Talis("NormalTinTalis3", "Eleven", Lightning, 1, 0, 0).QATK elif choice == "N" or choice == "n": AttacksOO.Talis("NormalTinTalis3", "Eleven", Lightning, 1, 0, 0).NATK elif choice == "H" or choice == "h": AttacksOO.Talis("NormalTinTalis3", "Eleven", Lightning, 1, 0, 0).HATK elif choice == "FB" or choice == "Fb" or choice == "fb": Skills.OffenseSpell("NormalTinTalis3", "Eleven", Flame, 1, 0, 0).FlameBlast elif choice == "WG" or choice == "Wg" or choice == "wg": AttacksOO.OffenseSpell("NormalTinTalis3", "Eleven", Water, 1, 0, 0).WaterGrenade elif choice == "SB" or choice == "Sb" or choice == "sb": Skills.OffenseSpell("NormalTinTalis3", "Eleven", Lightning, 1, 0, 0).StunBolt
def defender(me, my_teammate, opponent1, opponent2, ball, strategy, one_v_one=False): global _offensive, _defensive, _neutral if strategy == _offensive: dist_to_maintain = 0.85 elif strategy == _defensive: dist_to_maintain = 0.65 else: dist_to_maintain = 0.25 if strategy == _defensive: return Plays.stay_open_for_pass(me, my_teammate, ball) if Utilities.am_i_closest_teammate_to_ball(me, my_teammate, ball): if Utilities.am_i_closer_to_ball_than_opponents( me, opponent1, opponent2, ball): if Utilities.is_ball_behind_robot(me, ball): return Skills.avoid_own_goal(me, ball) else: return Skills.clear_ball_from_half(me, ball) else: # I am in charge of stealing the ball if Utilities.is_ball_behind_robot(me, ball): return Skills.avoid_own_goal(me, ball) else: closest_opp = Utilities.get_closest_opponent_to_ball( opponent1, opponent2, ball) return Plays.steal_ball_from_opponent(me, closest_opp, ball) ## My teammate is closer to the ball else: if Utilities.am_i_too_close_to_teammate(me, my_teammate): return Skills.give_my_teammate_some_space(me, my_teammate) else: if Utilities.is_ball_behind_robot(me, ball): return Skills.avoid_own_goal(me, ball) elif strategy == _offensive: if me.ally1: # call Utilities.are_both_opponents_attacking_goal? return Plays.stay_open_for_pass(me, my_teammate, ball) else: # ally2 return Plays.stay_between_points_at_distance( Constants.goal_position_home[0], Constants.goal_position_home[1], ball.xhat, ball.yhat, dist_to_maintain) else: # strategy is defensive return Plays.stay_between_points_at_distance( Constants.goal_position_home[0], Constants.goal_position_home[1], ball.xhat, ball.yhat, dist_to_maintain)
def steal_ball_from_opponent(me, opponent, ball): """ Using xhat_future and yhat_future to predict where the ball will be, and put itself in front of the opponent, facing opponent's goal, ready to kick the ball towards their goal """ global _steal_ball_state global _wait_steal_timer, _WAIT_STEAL_MAX # WE ARE USING FUTURE POSITIONS SO WE WILL BE WHERE THE BALL IS HOPEFULLY BEFORE THE OPPONENT theta_des = Utilities.get_angle_between_points(ball.xhat, ball.yhat, opponent.xhat, opponent.yhat) x_des = ball.xhat - Constants.steal_ball_dist * np.cos(theta_des) y_des = ball.yhat - Constants.steal_ball_dist * np.sin(theta_des) # but we need the kicker to get the current position so it will kick correctly (x, y) = Utilities.get_front_of_robot(me) distance_from_kicker_to_ball = Utilities.get_distance_between_points( x, y, ball.xhat, ball.yhat) ######################### ### transition states ### ######################### if _steal_ball_state == ShootState.setup: opp_dist_from_ball = Utilities.get_distance_between_points( opponent.xhat, opponent.yhat, ball.xhat_future, ball.yhat_future) if Utilities.robot_close_to_point(me, x_des, y_des, theta_des): _wait_steal_timer = _wait_steal_timer + 1 if (opp_dist_from_ball >= Constants.steal_ball_dist or _wait_steal_timer >= _WAIT_STEAL_MAX): _wait_steal_timer = 0 _steal_ball_state = ShootState.attack elif _steal_ball_state == ShootState.attack: if distance_from_kicker_to_ball <= Constants.kickable_distance: _steal_ball_state = ShootState.shoot elif _steal_ball_state == ShootState.shoot: if distance_from_kicker_to_ball > Constants.kickable_distance: _steal_ball_state = ShootState.setup else: _steal_ball_state = ShootState.setup ############################### ### Moore Outputs in states ### ############################### if _steal_ball_state == ShootState.setup: return (x_des, y_des, theta_des) elif _steal_ball_state == ShootState.attack: return Skills.attack_ball(me, ball) elif _steal_ball_state == ShootState.shoot: Skills.kick() return Skills.attack_ball(me, ball) else: return (me.xhat, me.yhat, Utilities.rad_to_deg(me.thetahat))
def StClips(Unit): u = Unit uHP = WSD[Unit].HP uENE = WSD[Unit].ENE uSTR = WSD[Unit].STR uSPR = WSD[Unit].SPR uSKL = WSD[Unit].SKL uABL = WSD[Unit].ABL uAGI = WSD[Unit].AGI uEVA = WSD[Unit].EVA uTGH = WSD[Unit].TGH uRES = WSD[Unit].RES uLCK = WSD[Unit].LCK uPAR = WSD[Unit].PAR uMAR = WSD[Unit].MAR uWT = WSD[Unit].ArmorWT choice = input( "Select something!\n [St]atcheck!\n [At]tack!\n [I]nventory!\n [Sk]illcheck!\n " ) if choice == "ST" or choice == "St" or choice == "st": print("-----------------") print("HP:", uHP) print("ENE:", uENE) print("STR:", uSTR) print("SPR:", uSPR) print("SKL:", uSKL) print("ABL:", uABL) print("AGI:", uAGI) print("EVA:", uEVA) print("TGH:", uTGH) print("RES:", uRES) print("LCK:", uLCK) print("PAR:", uPAR) print("MAR:", uMAR) print("WT:", uWT) print("-----------------") elif choice == "AT" or choice == "At" or choice == "at": choice = input("Which weapon?\n [1] Festive Firwood Mechgun+2!\n ") if choice == "1": choice = input( "[Q]uick!\n [N]ormal!\n [H]ard!\n [Dr]izzle!\n [Bl]itz!\n ") if choice == "AT" or choice == "At" or choice == "at": Attacks.MechgunManiac("StClips", "FestiveWoodMechgun2", "Earth") elif choice == "DR" or choice == "Dr" or choice == "dr": Skills.DrizzleManiac("StClips", "FestiveWoodMechgun2", "Earth") elif choice == "BL" or choice == "Bl" or choice == "bl": Skills.BlitzManiac("StClips", "FestiveWoodMechgun2", "Earth") elif choice == "I" or choice == "i": choice = input("Select an item!\n ") elif choice == "SK" or choice == "Sk" or choice == "sk": Check.Skillcheck("StClips", 2).Choice
def Hellhound(Monster): u = Monster uHP = WSD[Monster].HP uENE = WSD[Monster].ENE uSTR = WSD[Monster].STR uSPR = WSD[Monster].SPR uSKL = WSD[Monster].SKL uABL = WSD[Monster].ABL uAGI = WSD[Monster].AGI uEVA = WSD[Monster].EVA uTGH = WSD[Monster].TGH uRES = WSD[Monster].RES uLCK = WSD[Monster].LCK uPAR = WSD[Monster].PAR uMAR = WSD[Monster].MAR uWT = WSD[Monster].ArmorWT choice = input( "Select an action type!\n [St]atcheck!\n [At]tacks!\n [Sk]ills!") if choice == "ST" or choice == "St" or choice == "st": print("-----------------") print("HP:", uHP) print("ENE:", uENE) print("STR:", uSTR) print("SPR:", uSPR) print("SKL:", uSKL) print("ABL:", uABL) print("AGI:", uAGI) print("EVA:", uEVA) print("TGH:", uTGH) print("RES:", uRES) print("LCK:", uLCK) print("PAR:", uPAR) print("MAR:", uMAR) print("WT:", uWT) print("-----------------") if choice == "AT" or choice == "At" or choice == "at": choice = input("Select an attack!\n [CL] Claws!\n [Te]eth!\n ") if choice == "CL" or choice == "cl" or choice == "Claws" or choice == "claws": Attacks.Claw("Hellhound", "NormalBronzeClaw3", "Flame") elif choice == "Te" or choice == "TE" or choice == "te": AttacksOO.Weaponless("Hellhound", Flame, 1, 0, 0).SavageBite elif choice == "SK" or choice == "Sk" or choice == "sk": choice = input( "Select a Skill! \n [FB] Fire Breath!\n [SB] Savage Bite!\n [BS] Bodyslam!\n " ) if choice == "FB" or choice == "fb": Skills.BreathAttack("Hellhound", "Flame") elif choice == "SB" or choice == "sb": Skills.SavageBite("Hellhound") elif choice == "BS" or choice == "bs": Skills.Bodyslam("Hellhound")
def attacker(me, my_teammate, opponent1, opponent2, ball, strategy, one_v_one=False): global _offensive, _defensive, _neutral middle_of_goal = 0 goal_target = 0.6 if Utilities.am_i_closest_teammate_to_ball(me, my_teammate, ball): if Utilities.am_i_closer_to_ball_than_opponents(me, opponent1, opponent2, ball): if Utilities.is_ball_behind_robot(me, ball): return Skills.avoid_own_goal(me, ball) if me.ally1 or one_v_one: if ball.yhat > 0: return Plays.shoot_on_goal(me, ball, goal_target, opponent1, opponent2) else: return Plays.shoot_on_goal(me, ball, -goal_target, opponent1, opponent2) else: # I am ally2 if strategy == _offensive: if (opponent1.xhat < me.xhat and opponent2.xhat < me.xhat): return Plays.shoot_on_goal(me, ball, middle_of_goal, opponent1, opponent2) else: # return Plays.shoot_on_goal(me, ball, middle_of_goal, opponent1, opponent2) return Plays.pass_to_teammate(me, my_teammate, ball) # passes to teammate_future_position else: #Defensive if ball.yhat > 0: return Plays.shoot_on_goal(me, ball, goal_target, opponent1, opponent2) else: return Plays.shoot_on_goal(me, ball, -goal_target, opponent1, opponent2) else: #Basically, we don't have possession and I should be the one to steal the ball if Utilities.is_ball_behind_robot(me, ball): return Skills.avoid_own_goal(me, ball) else: closest_opp = Utilities.get_closest_opponent_to_ball(opponent1, opponent2, ball) return Plays.steal_ball_from_opponent(me, closest_opp, ball) else: #My teammate is closer to the ball than me. if Utilities.am_i_too_close_to_teammate(me, my_teammate): return Skills.give_my_teammate_some_space(me, my_teammate) elif Utilities.is_ball_behind_robot(me, ball): return Skills.avoid_own_goal(me, ball) else: # offensive only if we are behind in points if strategy == _offensive: if me.ally1: return Plays.stay_open_for_pass(me, my_teammate, ball) else: # I am ally2 return Plays.stay_at_midfield_follow_ball(me, opponent1, opponent2, ball) # The secondary robot will always stay at midfield else: return Plays.stay_at_midfield_follow_ball(me, opponent1, opponent2, ball)
def Wander(Unit): u = Unit uHP = WSD[Unit].HP uENE = WSD[Unit].ENE uSTR = WSD[Unit].STR uSPR = WSD[Unit].SPR uSKL = WSD[Unit].SKL uABL = WSD[Unit].ABL uAGI = WSD[Unit].AGI uEVA = WSD[Unit].EVA uTGH = WSD[Unit].TGH uRES = WSD[Unit].RES uLCK = WSD[Unit].LCK uPAR = WSD[Unit].PAR uMAR = WSD[Unit].MAR uWT = WSD[Unit].ArmorWT choice = input( "Select something!\n [St]atcheck!\n [At]tack!\n [Su]pport Magic!\n [I]nventory!\n " ) if choice == "ST" or choice == "St" or choice == "st": print("-----------------") print("HP:", uHP) print("ENE:", uENE) print("STR:", uSTR) print("SPR:", uSPR) print("SKL:", uSKL) print("ABL:", uABL) print("AGI:", uAGI) print("EVA:", uEVA) print("TGH:", uTGH) print("RES:", uRES) print("LCK:", uLCK) print("PAR:", uPAR) print("MAR:", uMAR) print("WT:", uWT) print("-----------------") elif choice == "At" or choice == "at" or choice == "AT": choice = input("Which weapon?\n [1] Copper Rod!\n ") if choice == "1": choice = input( "Select an action!\n [Q]uick!\n [N]ormal!\n [H]ard!\n ") if choice == "Q" or choice == "q": AttacksOO.Rod("NormalCopperRod0", "Wander", Flame, 0.5, 0, 0).QATK elif choice == "N" or choice == "n": AttacksOO.Rod("NormalCopperRod0", "Wander", Flame, 0.5, 0, 0).NATK elif choice == "H" or choice == "h": AttacksOO.Rod("NormalCopperRod0", "Wander", Flame, 0.5, 0, 0).HATK elif choice == "SU" or choice == "Su" or choice == "su": choice = input( "Select a Support Spell!\n [HR] Healthy Ray!\n [HG] Healthy Glow!\n [RR] torative Ray!\n " ) if choice == "HR" or choice == "Hr" or choice == "hr": AttacksOO.SupportSpell("NormalCopperRod0", "Wander").HealthyRay elif choice == "HG" or choice == "Hg" or choice == "hg": AttacksOO.SupportSpell("NormalCopperRod0", "Wander").HealthyGlow elif choice == "RR" or choice == "Rr" or choice == "rr": Skills.RestorativeRay("Wander", "NormalCopperRod0")
def copyConstructor(self, theOrig): self.myName = theOrig.myName self.myStats = dict(theOrig.myStats) self.myStatMods = dict(theOrig.myStatMods) self.mySize = theOrig.mySize self.myBA = theOrig.myBA self.myFortBase = theOrig.myFortBase self.myRefBase = theOrig.myRefBase self.myWillBase = theOrig.myWillBase self.setSaves(theOrig.myFortTot, theOrig.myRefTot, theOrig.myWillTot) self.myFullHealth = theOrig.myFullHealth self.myAC = ArmorClass(theOrigAC=theOrig.myAC) self.mySkills = Skills.SkillList(theOrigList=theOrig.mySkills) # To Do: Check and ensure deep copying. self.myNotes = TempDict(theOrig.myNotes)
def pass_to_teammate(me, my_teammate, ball): (x_pos, y_pos) = Utilities.get_front_of_robot(me) dist_to_ball = Utilities.get_distance_between_points( x_pos, y_pos, ball.xhat, ball.yhat) desired_setup = Skills.go_behind_ball_facing_target( ball, Constants.distance_behind_ball_for_kick, my_teammate.xhat_future, my_teammate.yhat_future) if Utilities.robot_close_to_point(me, *desired_setup): if dist_to_ball <= Constants.kickable_distance: Skills.kick() return Skills.attack_ball_towards_point(me, ball, my_teammate.xhat_future, my_teammate.yhat_future) else: return desired_setup
def __init__(self, key): self.key = key self.merc_class_skill_list = [] skill_source = csv.DictReader(open(BaseStats.MERC_CLASS_CSV)) for row in skill_source: if len(row["Key"]) == 0: continue elif self.key == row["Key"]: self.merc_class_skill_list.append(Skills.Skill(row["Skill1"])) self.merc_class_skill_list.append(Skills.Skill(row["Skill2"])) self.merc_class_skill_list.append(Skills.Skill(row["Skill3"])) self.merc_class_phys_res = int(row["ResAmountResPhys"]) self.merc_class_chem_res = int(row["ResAmountResChem"]) self.merc_class_therm_res = int(row["ResAmountResThermo"]) self.merc_class_dodge = int(row["AmountDodgeChance"]) self.merc_weapon_type = row["ClassWeapon"] self.merc_talisman_cap = int(row["TalismanAmount"])
def goalie(me, my_teammate, opponent1, opponent2, ball, strategy, one_v_one=False): global _ball_defend_position, _offensive, _defensive, _neutral global _recently_kicked, _kicker_wait_counter, _KICKER_WAIT_MAX # This prevents the goalie from kicking the ball too often _kicker_wait_counter = _kicker_wait_counter + 1 if _kicker_wait_counter >= _KICKER_WAIT_MAX: _recently_kicked = False _kicker_wait_counter = 0 # First, check to see if the ball is close enough to actuate the kicker, and kick it away (x_pos, y_pos) = Utilities.get_front_of_robot(me) distance_from_kicker_to_ball = Utilities.get_distance_between_points(x_pos, y_pos, ball.xhat, ball.yhat) if (distance_from_kicker_to_ball <= Constants.kickable_distance and not Utilities.is_ball_behind_robot(me, ball)): if not _recently_kicked: print "GOALIE KICKING BALL AWAY" Skills.kick() _recently_kicked = True if Utilities.is_ball_behind_robot(me, ball): return Skills.avoid_own_goal(me, ball) elif strategy == _offensive and Utilities.am_i_closest_teammate_to_ball(me, my_teammate, ball) and Utilities.am_i_closer_to_ball_than_opponents(me, opponent1, opponent2, ball): return Skills.attack_ball(me, ball) # Goalie is always defending the goal in an arc else: theta_c = Utilities.get_angle_between_points(Constants.goal_position_home[0], Constants.goal_position_home[1], ball.xhat_future, ball.yhat_future) # theta_c_future = Utilities.get_angle_between_points(Constants.goal_position_home[0], Constants.goal_position_home[1], ball.xhat_future, ball.yhat_future) theta_c_deg = Utilities.rad_to_deg(theta_c) x_c = Constants.goal_position_home[0] + Constants.goalie_radius*np.cos(theta_c) y_c = Constants.goal_position_home[1] + Constants.goalie_radius*np.sin(theta_c) #Updating global variable that will predict where the ball will intersect with the "goalie arc" and maintain that position if abs(ball.xhat_future) > abs(x_c): if _ball_defend_position is None: _ball_defend_position = ball else: _ball_defend_position = None if _ball_defend_position is not None: y_c = _ball_defend_position.yhat_future return (x_c, y_c, theta_c_deg)
def Liveflame(Monster): u = Monster uHP = WSD[Monster].HP uENE = WSD[Monster].ENE uSTR = WSD[Monster].STR uSPR = WSD[Monster].SPR uSKL = WSD[Monster].SKL uABL = WSD[Monster].ABL uAGI = WSD[Monster].AGI uEVA = WSD[Monster].EVA uTGH = WSD[Monster].TGH uRES = WSD[Monster].RES uLCK = WSD[Monster].LCK uPAR = WSD[Monster].PAR uMAR = WSD[Monster].MAR uWT = WSD[Monster].ArmorWT choice = input( "Select an action type!\n [St]atcheck!\n [Br]eath Attack!\n [Fl]ameblast!\n [Bo]dyslam!\n " ) if choice == "ST" or choice == "St" or choice == "st": print("-----------------") print("HP:", uHP) print("ENE:", uENE) print("STR:", uSTR) print("SPR:", uSPR) print("SKL:", uSKL) print("ABL:", uABL) print("AGI:", uAGI) print("EVA:", uEVA) print("TGH:", uTGH) print("RES:", uRES) print("LCK:", uLCK) print("PAR:", uPAR) print("MAR:", uMAR) print("WT:", uWT) print("-----------------") elif choice == "BR" or choice == "br" or choice == "Br": Skills.BreathAttack("Liveflame", "Flame") elif choice == "FL" or choice == "fl" or choice == "Fl": Skills.FlameBlast("Liveflame", "NormalIvoryRod1") elif choice == "BO" or choice == "bo" or choice == "Bo": Skills.Bodyslam("Liveflame")
def Jel(Monster, Element): u = Monster uELM = Element uHP = WSD[Monster].HP uENE = WSD[Monster].ENE uSTR = WSD[Monster].STR uSPR = WSD[Monster].SPR uSKL = WSD[Monster].SKL uABL = WSD[Monster].ABL uAGI = WSD[Monster].AGI uEVA = WSD[Monster].EVA uTGH = WSD[Monster].TGH uRES = WSD[Monster].RES uLCK = WSD[Monster].LCK uPAR = WSD[Monster].PAR uMAR = WSD[Monster].MAR uWT = WSD[Monster].ArmorWT choice = input( "Select an action type!\n [St]atcheck!\n [Bo]dyslam!\n [Br]eathattack!\n " ) if choice == "ST" or choice == "St" or choice == "st": print("-----------------") print("HP:", uHP) print("ENE:", uENE) print("STR:", uSTR) print("SPR:", uSPR) print("SKL:", uSKL) print("ABL:", uABL) print("AGI:", uAGI) print("EVA:", uEVA) print("TGH:", uTGH) print("RES:", uRES) print("LCK:", uLCK) print("PAR:", uPAR) print("MAR:", uMAR) print("WT:", uWT) print("-----------------") elif choice == "BO" or choice == "Bo" or choice == "bo": Skills.Bodyslam(Monster, Element) elif choice == "BR" or choice == "Br" or choice == "br": Skills.BreathAttack(Monster, Element)
def defender(me, my_teammate, opponent1, opponent2, ball, strategy, one_v_one=False): global _offensive, _defensive, _neutral if strategy == _offensive: dist_to_maintain = 0.85 elif strategy == _defensive: dist_to_maintain = 0.65 else: dist_to_maintain = 0.25 if strategy == _defensive: return Plays.stay_open_for_pass(me, my_teammate, ball) if Utilities.am_i_closest_teammate_to_ball(me, my_teammate, ball): if Utilities.am_i_closer_to_ball_than_opponents(me, opponent1, opponent2, ball): if Utilities.is_ball_behind_robot(me, ball): return Skills.avoid_own_goal(me, ball) else: return Skills.clear_ball_from_half(me, ball) else: # I am in charge of stealing the ball if Utilities.is_ball_behind_robot(me, ball): return Skills.avoid_own_goal(me, ball) else: closest_opp = Utilities.get_closest_opponent_to_ball(opponent1, opponent2, ball) return Plays.steal_ball_from_opponent(me, closest_opp, ball) ## My teammate is closer to the ball else: if Utilities.am_i_too_close_to_teammate(me, my_teammate): return Skills.give_my_teammate_some_space(me, my_teammate) else: if Utilities.is_ball_behind_robot(me, ball): return Skills.avoid_own_goal(me, ball) elif strategy == _offensive: if me.ally1: # call Utilities.are_both_opponents_attacking_goal? return Plays.stay_open_for_pass(me, my_teammate, ball) else: # ally2 return Plays.stay_between_points_at_distance(Constants.goal_position_home[0], Constants.goal_position_home[1], ball.xhat, ball.yhat, dist_to_maintain) else: # strategy is defensive return Plays.stay_between_points_at_distance(Constants.goal_position_home[0], Constants.goal_position_home[1], ball.xhat, ball.yhat, dist_to_maintain)
def handle_events(frame_time): # 입력신호를 관리하는 함수 global Cat_Units # 전역으로 선언된 리스트를 사용할 것을 명시 global Enemy_Units # 전역으로 선언된 리스트를 사용할 것을 명시 global Laser_Beam global Skill_Button global BGM global Back_Ground events = get_events() for event in events: if event.type == SDL_QUIT: GameFrameWork.quit() # 게임을 중단 elif event.type == SDL_KEYDOWN: if event.key == SDLK_ESCAPE: # ESC 키 입력 시 GameFrameWork.quit() # 게임을 중단 elif event.key == SDLK_1 and Number_1.state == Number_1.CHARGE_FULL: # 1번 입력 시 Cat_Units.append(Cats.BasicCat()) # 리스트에 기본 고양이 객체 추가 Number_1.start() # SDLK_1번 입력 시 Unit_Buttons.Number1 객체에 신호를 주면 # 그때부터 유닛의 생성 쿨타임을 Frame_time으로 계산해서 # (유닛 생성 쿨타임 - frame_time) / 유닛 생성 쿨타임 의 공식으로 # 100%, 66%, 33% 마다 쿨타임 이미지를 적용 elif event.key == SDLK_2 and Number_2.state == Number_2.CHARGE_FULL: # 2번 입력 시 Cat_Units.append(Cats.TankCat()) # 리스트에 벽 고양이 객체 추가 Number_2.start() elif event.key == SDLK_3 and Number_3.state == Number_3.CHARGE_FULL: # 3번 입력 시1 Cat_Units.append(Cats.AxeCat()) # 리스트에 전사 고양이 객체 추가 Number_3.start() elif event.key == SDLK_4 and Number_4.state == Number_4.CHARGE_FULL: # 4번 입력 시 Cat_Units.append(Cats.GrossCat()) # 각선미 고양이 객체 생성 Number_4.start() elif event.key == SDLK_5 and Number_5.state == Number_5.CHARGE_FULL: # 5번 입력 시 Cat_Units.append(Cats.CowCat()) # 황소 고양이 객체 생성 Number_5.start() elif event.key == SDLK_6 and Number_6.state == Number_6.CHARGE_FULL: # 6번 입력 시 Cat_Units.append(Cats.UFOCat()) # 물고기 고양이 객체 생성 Number_6.start() elif event.key == SDLK_7 and Number_7.state == Number_7.CHARGE_FULL: # 7번 입력 시 Cat_Units.append(Cats.FishCat()) # 천사 고양이 객체 생성 Number_7.start() elif event.key == SDLK_8 and Number_8.state == Number_8.CHARGE_FULL: # 8번 입력 시 Cat_Units.append(Cats.LizardCat()) # 도마뱀 고양이 객체 생성 Number_8.start() elif event.key == SDLK_9 and Number_9.state == Number_9.CHARGE_FULL: # 9번 입력 시 Cat_Units.append(Cats.TitanCat()) # 거인 고양이 객체 생성 Number_9.start() elif event.key == SDLK_q and Skill_Button.state == Skill_Button.CHARGE_FULL: Cat_Skills.append(Skills.LaserBeam()) My_Castle.state = My_Castle.CHARGE Skill_Button.start()
def Jinglejel(Jel): choice = input( "Select an Action!\n [ST] Statcheck!\n [BS] Bodyslam!\n [WG] Water Grenade!\n [SC] Snowball Cannon!\n " ) u = Jel uSTR = u + "STR" uSPR = u + "SPR" uSKL = u + "SKL" uABL = u + "ABL" uAGI = u + "AGI" uEVA = u + "EVA" uTGH = u + "TGH" uRES = u + "RES" uLCK = u + "LCK" uPAR = u + "PAR" uMAR = u + "MAR" if choice == "ST" or choice == "st": print("These are the stats for", u, "as they currently stand!") print("\n-----------------") print("Strength:", (WSD[uSTR])) print("Spirit:", (WSD[uSPR])) print("Skill:", (WSD[uSKL])) print("Ability:", (WSD[uABL])) print("Agility:", (WSD[uAGI])) print("Evasion:", (WSD[uEVA])) print("Toughness:", (WSD[uTGH])) print("Resistance:", (WSD[uRES])) print("Luck:", (WSD[uLCK])) print("Physical Resist: ", (WSD[uPAR])) print("Magical Resist: ", (WSD[uMAR])) print("-----------------\n") if choice == "BS" or choice == "bs" or choice == "Bodyslam" or choice == "bodyslam": Attacks.Bodyslam("Jinglejel") elif choice == "WG" or choice == "wg": Skills.WaterGrenade("Jinglejel", "NormalIvoryWand3") elif choice == "SC" or choice == "sc": Skills.WaterGrenade("Jinglejel", "NormalIvoryRod10")
def Norwolf(Norwolf): choice = input( "Select an Action!\n [ST] Statcheck!\n [FC] Frost Claws!\n [BA] Breath Attack!\n [SB] Savage Bite!\n " ) u = Norwolf uSTR = u + "STR" uSPR = u + "SPR" uSKL = u + "SKL" uABL = u + "ABL" uAGI = u + "AGI" uEVA = u + "EVA" uTGH = u + "TGH" uRES = u + "RES" uLCK = u + "LCK" uPAR = u + "PAR" uMAR = u + "MAR" if choice == "ST" or choice == "st": print("These are the stats for", u, "as they currently stand!") print("\n-----------------") print("Strength:", (WSD[uSTR])) print("Spirit:", (WSD[uSPR])) print("Skill:", (WSD[uSKL])) print("Ability:", (WSD[uABL])) print("Agility:", (WSD[uAGI])) print("Evasion:", (WSD[uEVA])) print("Toughness:", (WSD[uTGH])) print("Resistance:", (WSD[uRES])) print("Luck:", (WSD[uLCK])) print("Physical Resist: ", (WSD[uPAR])) print("Magical Resist: ", (WSD[uMAR])) print("-----------------\n") elif choice == "FC" or choice == "fc": Attacks.Claw("Norwolf", "BoneLeatherClaw2", "Aqua") elif choice == "BA" or choice == "ba": Skills.BreathAttack("Norwolf", "Aqua") elif choice == "SB" or choice == "sb": Skills.SavageBite("Norwolf")
def __init__(self, theName='Tabor', theStr=10, theDex=10, theCon=10, theInt=10, theWis=10, theCha=10, theBA=0, theFullHealth=10, theFortBase=0, theRefBase=0, theWillBase=0, theSize=0, theFortTot=None, theRefTot=None, theWillTot=None, theArmorB=0, theShieldB=0, theACTot=None, theACTouch=None, theACFlat=None, theOrigChar=None): ''' Constructor ''' if theOrigChar == None: self.myName = theName self.myStats = {'Str': theStr, 'Dex': theDex, 'Con': theCon, 'Int': theInt, 'Wis': theWis, 'Cha': theCha} self.myStatMods = {'Str': self.calcMod(theStr), 'Dex': self.calcMod(theDex), 'Con': self.calcMod(theCon), 'Int': self.calcMod(theInt), 'Wis': self.calcMod(theWis), 'Cha': self.calcMod(theCha)} self.mySize = theSize self.myBA = theBA self.myFortBase = theFortBase self.myRefBase = theRefBase self.myWillBase = theWillBase self.setSaves(theFortTot, theRefTot, theWillTot) self.myFullHealth = theFullHealth self.myAC = ArmorClass(theArmor=theArmorB, theShield=theShieldB, theSize=self.mySize, theTotal=theACTot, theTouch=theACTouch, theFlat=theACFlat) self.mySkills = Skills.SkillList(self) self.myNotes = TempDict() else: self.copyConstructor(theOrigChar) self.myCurrentHealth = self.myFullHealth self.myCMB = self.myBA + self.myStatMods['Str'] - self.mySize self.myCMD = self.myBA + self.myStatMods['Str'] + self.myStatMods['Dex'] - self.mySize + 10 self.myMeleeAtk = self.myBA + self.myStatMods['Str'] + self.mySize self.myRangeAtk = self.myBA + self.myStatMods['Dex'] + self.mySize
def NextPress(save=1): if RaceWindow: RaceWindow.Unload() if CharGen: GemRB.SetNextScript("Skills") return # find the index past the last set stat last = RacialEnemies.index(0) if save: # save, but note that racial enemies are stored in many stats pc = GemRB.GameGetSelectedPCSingle() newHated = GemRB.GetVar("HatedRace") GemRB.SetPlayerStat(pc, RacialStats[last], newHated) # open up the next levelup window import Skills Skills.OpenSkillsWindow(0) return
def Snowgunner(Snowman): choice = input( "Select an Action!\n [ST] Statcheck!\n [PB] Pistol Blaster!\n [CL] Claw Attacks!\n [BA] Breath Attack!\n " ) u = Snowman uSTR = u + "STR" uSPR = u + "SPR" uSKL = u + "SKL" uABL = u + "ABL" uAGI = u + "AGI" uEVA = u + "EVA" uTGH = u + "TGH" uRES = u + "RES" uLCK = u + "LCK" uPAR = u + "PAR" uMAR = u + "MAR" if choice == "ST" or choice == "st": print("These are the stats for", u, "as they currently stand!") print("\n-----------------") print("Strength:", (WSD[uSTR])) print("Spirit:", (WSD[uSPR])) print("Skill:", (WSD[uSKL])) print("Ability:", (WSD[uABL])) print("Agility:", (WSD[uAGI])) print("Evasion:", (WSD[uEVA])) print("Toughness:", (WSD[uTGH])) print("Resistance:", (WSD[uRES])) print("Luck:", (WSD[uLCK])) print("Physical Resist: ", (WSD[uPAR])) print("Magical Resist: ", (WSD[uMAR])) print("-----------------\n") elif choice == "PB" or choice == "pb": Attacks.PistolPacker("Snowgunner", "CottonWoodPistol3", "Aqua") elif choice == "CL" or choice == "cl": Attacks.Claw("Snowgunner", "CottonWoodClaw3", "Aqua") elif choice == "BA" or choice == "ba": Skills.BreathAttack("Snowgunner", "Aqua")
def strategize(self): if self.ally1: # return _position_to_tuple(self.game_state.field.ally1.position) # rush ball # print 'rush goal' cmds = self.rush_goal( _position_to_pose2d(self.game_state.field.ally1.position), _point_to_pose2d(self.game_state.field.ball.point)) # print self.team_side, "forward cmds:", cmds # print self.team_side, "forward pos: ", \ # _position_to_pose2d(self.game_state.field.ally1.position) else: # print 'goalie' # be a goalie (i.e., follow line on ball) # cmds = self.follow_ball_on_line(ball, -1.25) cmds = _position_to_tuple( Skills.stay_between_goalnball(self.game_state, self.game_state.field.ally2)) # print self.team_side, "goalie cmds:", cmds # print self.team_side, "goalie pos: ", \ # _position_to_pose2d(self.game_state.field.ally2.position) # print self.team_side # if self.team_side != 'home': # print 'flip (before =', cmds, ',', # cmds = _flip_coordinate_system(cmds) # print 'after =', cmds, ')' pos_str = "forward" if self.ally1 else "goalie" # print self.team_side, pos_str, "cmds:", cmds my_pos = self.game_state.field.ally1.position if self.ally1 else \ self.game_state.field.ally2.position # print self.team_side, pos_str, "pos: ", my_pos return cmds
def shoot_on_goal(me, ball, distance_from_center, opponent1, opponent2): """ this sets up for a shot at a distance from the center. Distance from center should be between -1 and 1 (really like .75 and -.75). 0 signifies straight on, 1 is top corner and -1 is bottom corner it also attacks the ball then actuates the kicker""" global _shoot_state global _ball_stuck_timer, _BALL_STUCK_MAX global _recently_kicked, _kicker_wait_counter, _KICKER_WAIT_MAX # this is the desired setup point, the whole state machine needs it so it is desired_setup_position = Skills.set_up_kick_facing_goal( ball, distance_from_center ) #!!!!!!should we try and do future? So it predicts # get the distance to the ball (x_pos, y_pos) = Utilities.get_front_of_robot(me) distance_from_kicker_to_ball = Utilities.get_distance_between_points( x_pos, y_pos, ball.xhat, ball.yhat) # We don't want to kicker to actuate so often, so we need to wait for the counter # This will happen every time the function is called, to make sure we don't miss a kick in between transitions _kicker_wait_counter = _kicker_wait_counter + 1 if _kicker_wait_counter >= _KICKER_WAIT_MAX: _recently_kicked = False _kicker_wait_counter = 0 ######################### ### transition states ### ######################### if _shoot_state == ShootState.setup: # _recently_kicked = False # Usually if it's in the setup state, we will have enough time to actuate the kicker. _ball_stuck_timer = _ball_stuck_timer + 1 # if the robot is close enough to the correct angle and its in front of the ball change to the attack state if Utilities.robot_close_to_point(me, *desired_setup_position): if not Utilities.is_ball_behind_robot(me, ball): _shoot_state = ShootState.attack elif _shoot_state == ShootState.attack: # if the ball is behind the robot, go back to set up if (Utilities.is_ball_behind_robot(me, ball) or distance_from_kicker_to_ball >= Constants.robot_width): _shoot_state = ShootState.setup # if the ball is close enough, go to the shoot state elif (distance_from_kicker_to_ball <= Constants.kickable_distance): _shoot_state = ShootState.shoot elif _shoot_state == ShootState.shoot: # Always go to the setup right after so that it only kicks once. _shoot_state = ShootState.setup # default state, go to setup else: _shoot_state = ShootState.setup ############################### ### Moore Outputs in states ### ############################### # go to the desired setup location if _shoot_state == ShootState.setup: if _ball_stuck_timer >= _BALL_STUCK_MAX: _ball_stuck_timer = 0 return Skills.attack_ball(me, ball) else: return desired_setup_position # attack the ball elif _shoot_state == ShootState.attack: # return Skills.attack_ball_towards_goal(me, ball, distance_from_center) return Skills.attack_ball(me, ball) elif _shoot_state == ShootState.shoot: if not Utilities.is_opp_too_close_to_kicker(me, opponent1, opponent2, ball): Skills.kick() else: print "Opponent too close and could damage our kicker" # return Skills.attack_ball_towards_goal(me, ball, distance_from_center) # keep attacking the ball as you kick return Skills.attack_ball(me, ball) # wait for state machine to start else: print('default') return (me.xhat, me.yhat, me.thetahat)
def Faerider(Fae): choice = input( "Select an Action!\n [ST] Statcheck!\n [FB] Faewood Bow!\n [FW] Faewood Wand!\n [FC] Faewood Cane!\n " ) u = Fae uSTR = u + "STR" uSPR = u + "SPR" uSKL = u + "SKL" uABL = u + "ABL" uAGI = u + "AGI" uEVA = u + "EVA" uTGH = u + "TGH" uRES = u + "RES" uLCK = u + "LCK" uPAR = u + "PAR" uMAR = u + "MAR" if choice == "ST" or choice == "st": print("These are the stats for", u, "as they currently stand!") print("\n-----------------") print("Strength:", (WSD[uSTR])) print("Spirit:", (WSD[uSPR])) print("Skill:", (WSD[uSKL])) print("Ability:", (WSD[uABL])) print("Agility:", (WSD[uAGI])) print("Evasion:", (WSD[uEVA])) print("Toughness:", (WSD[uTGH])) print("Resistance:", (WSD[uRES])) print("Luck:", (WSD[uLCK])) print("Physical Resist: ", (WSD[uPAR])) print("Magical Resist: ", (WSD[uMAR])) print("PAR:", (WSD[uPAR])) print("MAR:", (WSD[uMAR])) print("-----------------\n") elif choice == "FB" or choice == "fb" or choice == "Bow" or choice == "bow": choice = input( "Select a Bow Action!\n ==ATTACKS==\n [W]eak!\n [N]ormal!\n [S]trong!\n ==SKILLS==\n [L]ongshot!\n [C]lipshot!\n " ) if choice == "W" or choice == "w": Attacks.BowShotQ("Faerider", "CobaltBow2") elif choice == "N" or choice == "n": Attacks.BowShotN("Faerider", "CobaltBow2") elif choice == "S" or choice == "s": Attacks.BowShotH("Faerider", "CobaltBow2") elif choice == "C" or choice == "c": Skills.Clipshot("Faerider", "CobaltBow2") elif choice == "L" or choice == "l": Skills.Longshot("Faerider", "CobaltBow2") elif choice == "FW" or choice == "fw" or choice == "Wand" or choice == "wand": choice = input( "Select a Wand Action!\n ==ATTACKS==\n [W]eak Ray!\n [N]ormal Ray!\n [S]trong Ray!\n ==SKILLS==\n [W]ater Grenade!\n [F]lame Blast!\n " ) if choice == "W" or choice == "w": Attacks.WandRayQ("Faerider", "NormalIvoryWand7") elif choice == "N" or choice == "n": Attacks.WandRayN("Faerider", "NormalIvoryWand7") elif choice == "S" or choice == "s": Attacks.WandRayH("Faerider", "NormalIvoryWand7") elif choice == "Flame" or choice == "flame" or choice == "fire" or choice == "Fire": Skills.FlameBlast("Faerider", "NormalIvoryWand7") elif choice == "Water" or choice == "water": Skills.WaterGrenade("Faerider", "NormalIvoryWand7") elif choice == "FC" or choice == "fc": choice = input( "Select a Cane action!\n [Q]uick Attack!\n [N]ormal Attack!\n [H]ard Attack!\n " ) if choice == "Q" or choice == "q": Attacks.CaneWhackQ("Faerider", "TungstenCane2") elif choice == "N" or choice == "n": Attacks.CaneWhackN("Faerider", "TungstenCane2") elif choice == "H" or choice == "h": Attacks.CaneWhackH("Faerider", "TungstenCane2")
def Roselyn(Unit): u = Unit uHP = WSD[Unit].HP uENE = WSD[Unit].ENE uSTR = WSD[Unit].STR uSPR = WSD[Unit].SPR uSKL = WSD[Unit].SKL uABL = WSD[Unit].ABL uAGI = WSD[Unit].AGI uEVA = WSD[Unit].EVA uTGH = WSD[Unit].TGH uRES = WSD[Unit].RES uLCK = WSD[Unit].LCK uPAR = WSD[Unit].PAR uMAR = WSD[Unit].MAR uWT = WSD[Unit].ArmorWT choice = input( "Select something!\n [St]atcheck!\n [At]tack!\n [I]nventory!\n [H]ealing Field!\n [Sk]illcheck!\n " ) if choice == "ST" or choice == "St" or choice == "st": print("-----------------") print("HP:", uHP) print("ENE:", uENE) print("STR:", uSTR) print("SPR:", uSPR) print("SKL:", uSKL) print("ABL:", uABL) print("AGI:", uAGI) print("EVA:", uEVA) print("TGH:", uTGH) print("RES:", uRES) print("LCK:", uLCK) print("PAR:", uPAR) print("MAR:", uMAR) print("WT:", uWT) print("-----------------") elif choice == "AT" or choice == "At" or choice == "at": choice = input( "Which weapon?\n [1] Ivory Wand!\n [2] Cobalt Battlecannon!\n ") if choice == "1": choice = input( "Select an action!\n [Q]uick!\n [N]ormal!\n [H]ard!\n [Fi]reball!\n [HR] Healthy Ray!\n [HG] Healthy Glow!\n [EG] Energetic Glow!\n [ER] Energetic Ray!\n " ) if choice == "Q" or choice == "q": AttacksOO.Wand("NormalIvoryWand0", "Roselyn", Flame, 1, 0).QATK elif choice == "N" or choice == "n": AttacksOO.Wand("NormalIvoryWand0", "Roselyn", Flame, 1, 0).NATK elif choice == "H" or choice == "h": AttacksOO.Wand("NormalIvoryWand0", "Roselyn", Flame, 1, 0).HATK elif choice == "FI" or choice == "Fi" or choice == "fi": AttacksOO.OffenseSpell("NormalIvoryWand0", "Roselyn", Flame, 1.15, 0, 0).Fireball elif choice == "HR" or choice == "Hr" or choice == "hr": Skills.HealthyRay("Roselyn", "NormalIvoryWand0") elif choice == "HG" or choice == "Hg" or choice == "hg": Skills.HealthyGlow("Roselyn", "NormalIvoryWand0") elif choice == "ER" or choice == "Er" or choice == "er": Skills.EnergeticRay("Roselyn", "NormalIvoryWand0") elif choice == "EG" or choice == "Eg" or choice == "eg": Skills.EnergeticGlow("Roselyn", "NormalIvoryWand0") elif choice == "2": choice = input( "Select an action!\n [Q]uick!\n [N]ormal!\n [H]ard!\n ") if choice == "Q" or choice == "q": AttacksOO.Battlecannon("NormalCobaltBattlecannon0", "Roselyn", Flame, 0.5, 0).QATK elif choice == "N" or choice == "n": AttacksOO.Battlecannon("NormalCobaltBattlecannon0", "Roselyn", Flame, 0.5, 0).NATK elif choice == "H" or choice == "h": AttacksOO.Battlecannon("NormalCobaltBattlecannon0", "Roselyn", Flame, 0.5, 0).HATK elif choice == "I" or choice == "i": choice = input("Select an item!\n ") elif choice == "SK" or choice == "Sk" or choice == "sk": Check.Skillcheck("Roselyn", 1).Choice
def Jango(Unit): u = Unit uHP = WSD[Unit].HP uENE = WSD[Unit].ENE uSTR = WSD[Unit].STR uSPR = WSD[Unit].SPR uSKL = WSD[Unit].SKL uABL = WSD[Unit].ABL uAGI = WSD[Unit].AGI uEVA = WSD[Unit].EVA uTGH = WSD[Unit].TGH uRES = WSD[Unit].RES uLCK = WSD[Unit].LCK uPAR = WSD[Unit].PAR uMAR = WSD[Unit].MAR uWT = WSD[Unit].ArmorWT choice = input( "Select something!\n [St]atcheck!\n [At]tack!\n [I]nventory!\n [P]ickpocket!\n [Sk]illcheck!\n " ) if choice == "ST" or choice == "St" or choice == "st": print("-----------------") print("HP:", uHP) print("ENE:", uENE) print("STR:", uSTR) print("SPR:", uSPR) print("SKL:", uSKL) print("ABL:", uABL) print("AGI:", uAGI) print("EVA:", uEVA) print("TGH:", uTGH) print("RES:", uRES) print("LCK:", uLCK) print("PAR:", uPAR) print("MAR:", uMAR) print("WT:", uWT) print("-----------------") elif choice == "AT" or choice == "At" or choice == "at": choice = input( "Which weapon?\n [1] Reinforced Bone Knife!\n [2] Reinforced Bone Knife!\n " ) if choice == "1" or choice == "2": choice = input( "Select an action!\n [Q]uick!\n [N]ormal!\n [H]ard!\n [Tr]iple Combo!\n " ) if choice == "Q" or choice == "q": AttacksOO.Knife("ReinforcedBoneKnife0", "Jango", Flame, 1.3, 0, 0).QATK elif choice == "N" or choice == "n": AttacksOO.Knife("ReinforcedBoneKnife0", "Jango", Flame, 1.3, 0, 0).NATK elif choice == "H" or choice == "h": AttacksOO.Knife("ReinforcedBoneKnife0", "Jango", Flame, 1.3, 0, 0).HATK elif choice == "TR" or choice == "Tr" or choice == "tr": AttacksOO.Knife("ReinforcedBoneKnife0", "Jango", Flame, 1.3, 0, 0).TripleCombo elif choice == "SU" or choice == "Su" or choice == "su": Skills.Surprise("Jango", "ReinforcedBoneKnife0", "ReinforcedBoneKnife0", "Flame", "Flame") elif choice == "I" or choice == "i": choice = input( "Select an item!\n [Sh]uriken!\n [Or]ange Juice!\n [Ha]nd Grenade!\n " ) if choice == "SH" or choice == "Sh" or choice == "sh": Items.Shuriken("Jango") elif choice == "OR" or choice == "Or" or choice == "or": Items.OrangeJuice("Jango") elif choice == "HA" or choice == "Ha" or choice == "ha": Items.HandGrenade("Jango") elif choice == "P" or choice == "p": AttacksOO.Pickpocket("Jango") elif choice == "SK" or choice == "Sk" or choice == "sk": Check.Skillcheck("Jango", 1).Choice
def StClips(Unit): u=Unit uHP=WSD[Unit].HP uENE=WSD[Unit].ENE uSTR=WSD[Unit].STR uSPR=WSD[Unit].SPR uSKL=WSD[Unit].SKL uABL=WSD[Unit].ABL uAGI=WSD[Unit].AGI uEVA=WSD[Unit].EVA uTGH=WSD[Unit].TGH uRES=WSD[Unit].RES uLCK=WSD[Unit].LCK uPAR=WSD[Unit].PAR uMAR=WSD[Unit].MAR uWT=WSD[Unit].ArmorWT choice=input("Select something!\n [St]atcheck!\n [Ba]ttlestats!\n [At]tack!\n [T]oggle Shield!\n [I]nventory!\n [C]onfirm Actions!\n ") if choice=="ST" or choice == "St" or choice == "st": print("-----------------") print("HP:",uHP) print("ENE:",uENE) print("STR:",uSTR) print("SPR:",uSPR) print("SKL:",uSKL) print("ABL:",uABL) print("AGI:",uAGI) print("EVA:",uEVA) print("TGH:",uTGH) print("RES:",uRES) print("LCK:",uLCK) print("PAR:",uPAR) print("MAR:",uMAR) print("WT:",uWT) print("-----------------") elif choice == "BA" or choice == "Ba" or choice == "ba": print("-----------------") importlib.reload(HealthBar) print("Current HP:",HealthBar.StClipsHP) importlib.reload(EnergyBar) print("Current ENE:",EnergyBar.StClipsENE) print("-----------------") elif choice == "T" or choice == "t": UserShield="StClipsShield" importlib.reload(Shielding) ShieldPos=getattr(Shielding,UserShield) if ShieldPos == "Equipped": with open('C:\\Users\\seven\\OneDrive\\Desktop\\RoPH OOP Update\\For Testing Ideas\\Shielding.py','a+') as f: importlib.reload(Shielding) print(UserShield+"=NotEquipped",file=f) else: with open('C:\\Users\\seven\\OneDrive\\Desktop\\RoPH OOP Update\\For Testing Ideas\\Shielding.py','a+') as f: importlib.reload(Shielding) print(UserShield+"=Equipped",file=f) elif choice=="AT" or choice=="At" or choice == "at": choice=input("Which weapon?\n [1] Festive Firwood Mechgun+2!\n ") if choice == "1": choice=input("[Q]uick!\n [N]ormal!\n [H]ard!\n [Dr]izzle!\n [Bl]itz!\n ") if choice == "AT" or choice == "At" or choice == "at": Attacks.MechgunManiac("StClips","FestiveWoodMechgun2","Earth") elif choice == "DR" or choice == "Dr" or choice == "dr": Skills.DrizzleManiac("StClips","FestiveWoodMechgun2","Earth") elif choice == "BL" or choice == "Bl" or choice == "bl": Skills.BlitzManiac("StClips","FestiveWoodMechgun2","Earth") elif choice == "I" or choice == "i": choice=input("Select an item!\n ") if choice == "P" or choice == "p": ItemUsed=eval("Items."+input("Item is: ")) exec(str(ItemUsed("StClips"))) elif choice == "C" or choice == "c": choice=input("Select a Type!\n [A]ttackcheck!\n [S]killcheck!\n [I]temcheck!\n ") User="******" UserLevel=WSD[User].Level if choice == "A" or choice == "a": Check.Attackcheck(User).Confirm elif choice == "S" or choice == "s": Check.Skillcheck(User,UserLevel).Choice elif choice == "I" or choice == "i": Check.Itemcheck(User).Confirm
def main(): #DimensoesBalrog = 49x84 win = GraphWin("Fighting Game", 512, 464) time_inicial = time.time() fundo = Image(Point(256,232), "FeiLongStagemaior.png") Image.draw(fundo,win) IdleImg = Image(Point(90,310), "editado.png") IdleImg.draw(win) RightImg = Image(Point(90,310), "editado.png") tecla = "" l = Lutador(100, 0, 90, 310) s = Skills(10, 10, 30, 15) while tecla != "Escape": tecla = win.checkKey() print(tecla) PosX = RightImg.getAnchor().getX() PosY = RightImg.getAnchor().getY() DownImg = Image(Point(PosX,PosY), "balrgo agachado.png") Hitbox1Right = RightImg.getAnchor().getX() - 24.5 Hitbox2Right = RightImg.getAnchor().getY() - 42 Hitbox3Right = RightImg.getAnchor().getX() + 24.5 Hitbox4Right = RightImg.getAnchor().getY() + 42 HitboxRightFinal = Rectangle(Point(Hitbox1Right, Hitbox2Right), Point(Hitbox3Right, Hitbox4Right)) if tecla == "Right": IdleImg.undraw() RightImg.undraw() l.walk_right() l.move() RightImg = Image(Point(l.getX(), l.getY()), "editado.png") RightImg.draw(win) if tecla == "Left": IdleImg.undraw() DownImg.undraw() RightImg.undraw() l.walk_left() l.move() RightImg = Image(Point(l.getX(), l.getY()), "editado.png") RightImg.draw(win) if tecla == "Up": DownImg = Image(Point(PosX,PosY), "balrgo agachado.png") UpImg = Image(Point(PosX,PosY), "balrog pulando.png") Hitbox1Up = UpImg.getAnchor().getX() - 24.5 Hitbox2Up = UpImg.getAnchor().getY() - 62 Hitbox3Up = UpImg.getAnchor().getX() + 24.5 Hitbox4Up = UpImg.getAnchor().getY() + 22 HitboxUpFinal = Rectangle(Point(Hitbox1Up, Hitbox2Up), Point(Hitbox3Up, Hitbox4Up)) IdleImg.undraw() RightImg.undraw() DownImg.undraw() UpImg.draw(win) for i in range(5): UpImg.move(0,-20) time.sleep(0.079) UpImg.move(0,20) HitboxUpFinal.move(0,20) HitboxUpFinal.move(0,-20) UpImg.undraw() RightImg.draw(win) if tecla == "Down": DownImg = Image(Point(PosX,PosY), "balrgo agachado.png") UpImg = Image(Point(PosX,PosY), "balrog pulando.png") Hitbox1Down = DownImg.getAnchor().getX() - 24.5 Hitbox2Down = DownImg.getAnchor().getY() - 26 Hitbox3Down = DownImg.getAnchor().getX() + 24.5 Hitbox4Down = DownImg.getAnchor().getY() + 42 HitboxFinalDown = Rectangle(Point(Hitbox1Down, Hitbox2Down), Point(Hitbox3Down, Hitbox4Down)) RightImg.undraw() IdleImg.undraw() UpImg.undraw() DownImg.draw(win) for i in range(5): DownImg.move(0,0) time.sleep(0.07) DownImg.undraw() RightImg.draw(win) if tecla == "c": RightImg.undraw() IdleImg.undraw() s.setX(l.getX()) s.soco_direita() s.move() soco = Image(Point(s.getX(), s.getY()), "chiko.gif") soco.draw(win) if tecla == "x": RightImg.undraw() IdleImg.undraw() s.setX(l.getX()) s.chute_direita() s.move() chute = Image(Point(s.getX(), s.getY()), "taro.gif") chute.draw(win) if tecla == "z": RightImg.undraw() IdleImg.undraw() s.setX(l.getX()) s.especial_direita() s.move() especial = Image(Point(s.getX(), s.getY()), "especial.png") especial.draw(win) print(time.time() - time_inicial) print(PosX) print(PosY) print(time.time() - time_inicial) win.close()
def shoot_off_the_wall(me, ball): global _trick_state global _trick_x_before, _trick_x_after, _trick_y_before, _trick_y_after global _beginning_trick_shot (x, y) = Utilities.get_front_of_robot(me) distance_from_kicker_to_ball = Utilities.get_distance_between_points( x, y, ball.xhat, ball.yhat) set_up_distance = Constants.robot_half_width + Constants.robot_width y_tweak_value = 8.0 / 10.0 # Ideally, we should aim for goal pos mirrored above/below us, but it won't be perfect so this should handle that if ball.yhat > 0: # will calculate kicking off of the "closest" wall, which is the top wall theta_c = Utilities.get_angle_between_points( ball.xhat, ball.yhat, Constants.field_length / 2, Constants.field_width * y_tweak_value - ball.yhat) else: # will calculate kicking off of the bottom wall. theta_c = Utilities.get_angle_between_points( ball.xhat, ball.yhat, Constants.field_length / 2, -Constants.field_width * y_tweak_value + ball.yhat) theta_c = Utilities.rad_to_deg(theta_c) ######################### ### transition states ### ######################### if _trick_state == TrickState.setvars: # Assign desired positions _trick_x_before = ball.xhat - set_up_distance * np.cos(theta_c) _trick_y_before = ball.yhat - set_up_distance * np.sin(theta_c) _trick_x_after = ball.xhat + set_up_distance * np.cos(theta_c) _trick_y_after = ball.yhat + set_up_distance * np.sin(theta_c) # Transition to setup state _trick_state = TrickState.setup elif _trick_state == TrickState.setup: if Utilities.robot_close_to_point(me, _trick_x_before, _trick_y_before, theta_c): _trick_state = TrickState.attack elif _trick_state == TrickState.attack: if (distance_from_kicker_to_ball <= Constants.kickable_distance): _trick_state = TrickState.shoot elif _trick_state == TrickState.shoot: if distance_from_kicker_to_ball > Constants.kickable_distance: _trick_state == TrickState.setvars else: _trick_state = TrickState.setvars ############################### ### Moore Outputs in states ### ############################### if _trick_state == TrickState.setup: return (_trick_x_before, _trick_y_before, theta_c) elif _trick_state == TrickState.attack: return (_trick_x_after, _trick_y_after, theta_c) elif _trick_state == TrickState.shoot: Skills.kick() _beginning_trick_shot = True return (_trick_x_after, _trick_y_after, theta_c) else: return (_trick_x_before, _trick_y_before, theta_c)
import Characters as Char import Combat import Skills # USE FOR TESTING PURPOSES ONLY hero1 = Char.Fencer() hero2 = Char.Healer() enemy1 = Char.Goblin() enemy2 = Char.Goblin() enemy3 = Char.Hobgoblin() heroes = [hero1, hero2] enemies = [enemy1, enemy2, enemy3] hero1.HP["current"] = hero1.HP["max"] hero2.HP["current"] = hero2.HP["max"] hero1.reflex["base"] = 20 hero1.speed["base"] = -10 hero1.evasion["base"] += 150 hero1.luck["base"] = hero1.defense["base"] = 100 hero1.endurance["base"] = 1 Char.Hobgoblin.identifyCounter = 3 hero1.knownSkills.append(Skills.DodgeThrough()) hero2.knownSkills.append(Skills.Defend()) hero1.knownSkills.append(Skills.Parry()) Combat.startCombat(heroes, enemies)
def enter(): # 게임 상태 ( 인게임 ) 에 들어올 때 초기화 global Back_Ground # 전역변수 선언 Back_Ground = BackGround.BackGround() # 생성한 전역변수로 BackGround 객체를 가리킴 global BGM # 전역변수 선언 BGM = load_music('Resources/Musics/DefaultBattle.ogg') # 생성한 전역변수에 음악 삽입 BGM.set_volume(50) # 음량 BGM.repeat_play() # 반복 재생 global My_Castle, Enemy_Castle # 전역변수 선언 My_Castle = Castle.MyCastle() # 생성한 전역변수로 MyCastle 객체를 가리킴 Enemy_Castle = Castle.EnemyCastle() # 생성한 전역변수로 EnemyCastle 객체를 가리킴 global Basic_Cat, Tank_Cat, Axe_Cat, Gross_Cat, Cow_Cat, Bird_Cat, UFO_Cat, Fish_Cat, Lizard_Cat, Titan_Cat # 전역변수 선언 Basic_Cat = Cats.BasicCat() # 생성한 전역변수로 BasicCat 객체를 가리킴 Tank_Cat = Cats.TankCat() Axe_Cat = Cats.AxeCat() # 생성한 전역변수로 AxeCat 객체를 가리킴 Gross_Cat = Cats.GrossCat() Cow_Cat = Cats.CowCat() Bird_Cat = Cats.BirdCat() UFO_Cat = Cats.UFOCat() Fish_Cat = Cats.FishCat() Lizard_Cat = Cats.LizardCat() Titan_Cat = Cats.TitanCat() global Skele_Dog, Mummy_Dog, Officer_Skeleton, Commander_Skeleton Skele_Dog = Enemies.SkeleDog() Mummy_Dog = Enemies.MummyDog() Officer_Skeleton = Enemies.OfficerSkeleton() Commander_Skeleton = Enemies.CommanderSkeleton() global Headless_Knight Headless_Knight = Enemies.HeadlessKnight() global Headless_Knight_Skill Headless_Knight_Skill = EnemySkills.HeadlessKnightSkill(None, None) global Lizard_Cat_Skill, UFO_Cat_SKill Lizard_Cat_Skill = CatSkills.LizardCatSkill(None, None) UFO_Cat_SKill = CatSkills.UFOCatSkill(None, None) global Number_1, Number_2, Number_3, Number_4, Number_5, Number_6, Number_7, Number_8, Number_9 global Skill_Button Number_1 = Unit_Buttons.ButtonNumber1() Number_2 = Unit_Buttons.ButtonNumber2() Number_3 = Unit_Buttons.ButtonNumber3() Number_4 = Unit_Buttons.ButtonNumber4() Number_5 = Unit_Buttons.ButtonNumber5() Number_6 = Unit_Buttons.ButtonNumber6() Number_7 = Unit_Buttons.ButtonNumber7() Number_8 = Unit_Buttons.ButtonNumber8() Number_9 = Unit_Buttons.ButtonNumber9() Skill_Button = Unit_Buttons.SkillButton() Buttons.append(Number_1) Buttons.append(Number_2) Buttons.append(Number_3) Buttons.append(Number_4) Buttons.append(Number_5) Buttons.append(Number_6) Buttons.append(Number_7) Buttons.append(Number_8) Buttons.append(Number_9) Buttons.append(Skill_Button) global Laser_Beam Laser_Beam = Skills.LaserBeam() global TIME_PER_ACTION global ACTION_PER_TIME TIME_PER_ACTION = 0.5 ACTION_PER_TIME = 1.0 / TIME_PER_ACTION global Frame global Frames Frame = 0 Frames = 0 global Count_Number Count_Number = 0
def Roselyn(Character): u = Character uHP = WSD[Character].HP uENE = WSD[Character].ENE uSTR = WSD[Character].STR uSPR = WSD[Character].SPR uSKL = WSD[Character].SKL uABL = WSD[Character].ABL uAGI = WSD[Character].AGI uEVA = WSD[Character].EVA uTGH = WSD[Character].TGH uRES = WSD[Character].RES uLCK = WSD[Character].LCK uPAR = WSD[Character].PAR uMAR = WSD[Character].MAR uWT = WSD[Character].ArmorWT choice = input( "Select something!\n [St]atcheck!\n [Ba]ttlestats!\n [W]eapons!\n [Su]pport Magic!\n [T]oggle Shield!\n [I]nventory!\n [C]onfirm Actions!\n " ) if choice == "ST" or choice == "St" or choice == "st": print("-----------------") print("HP:", uHP) print("ENE:", uENE) print("STR:", uSTR) print("SPR:", uSPR) print("SKL:", uSKL) print("ABL:", uABL) print("AGI:", uAGI) print("EVA:", uEVA) print("TGH:", uTGH) print("RES:", uRES) print("LCK:", uLCK) print("PAR:", uPAR) print("MAR:", uMAR) print("WT:", uWT) print("-----------------") elif choice == "BA" or choice == "Ba" or choice == "ba": print("-----------------") importlib.reload(HealthBar) print("Current HP:", HealthBar.RoselynHP) importlib.reload(EnergyBar) print("Current ENE:", EnergyBar.RoselynENE) print("-----------------") elif choice == "T" or choice == "t": UserShield = "RoselynShield" importlib.reload(Shielding) ShieldPos = getattr(Shielding, UserShield) if ShieldPos == "Equipped": with open( 'C:\\Users\\seven\\OneDrive\\Desktop\\RoPH OOP Update\\Shielding.py', 'a+') as f: importlib.reload(Shielding) print(UserShield + "=NotEquipped", file=f) else: with open( 'C:\\Users\\seven\\OneDrive\\Desktop\\RoPH OOP Update\\Shielding.py', 'a+') as f: importlib.reload(Shielding) print(UserShield + "=Equipped", file=f) elif choice == "WE" or choice == "We" or choice == "we": choice = input( "Which weapon?\n [1] Ivory Wand!\n [2] Cobalt Battlecannon!\n [3] N/A!\n " ) if choice == "1": choice = input( "Select an action!\n [Q]uick!\n [N]ormal!\n [H]ard!\n [Fi]reball!\n " ) if choice == "Q" or choice == "q": AttacksOO.Wand(WSD["Roselyn"].Weapon1, "Roselyn", Flame, 1, 0, 0).QATK elif choice == "N" or choice == "n": AttacksOO.Wand(WSD["Roselyn"].Weapon1, "Roselyn", Flame, 1, 0, 0).NATK elif choice == "H" or choice == "h": AttacksOO.Wand(WSD["Roselyn"].Weapon1, "Roselyn", Flame, 1, 0, 0).HATK elif choice == "FI" or choice == "Fi" or choice == "fi": AttacksOO.OffenseSpell("NormalIvoryWand0", "Roselyn", Flame, 1.15, 0, 0, 0).Fireball elif choice == "2": choice = input( "Select an action!\n [Q]uick!\n [N]ormal!\n [H]ard!\n ") if choice == "Q" or choice == "q": AttacksOO.Battlecannon(WSD["Roselyn"].Weapon2, "Roselyn", Flame, 0.5, 0, 0).QATK elif choice == "N" or choice == "n": AttacksOO.Battlecannon(WSD["Roselyn"].Weapon2, "Roselyn", Flame, 0.5, 0, 0).NATK elif choice == "H" or choice == "h": AttacksOO.Battlecannon(WSD["Roselyn"].Weapon2, "Roselyn", Flame, 0.5, 0, 0).HATK elif choice == "SU" or choice == "Su" or choice == "su": choice = input( "Select a Spell!\n [HR] Healthy Ray!\n [HG] Healthy Glow!\n [EG] Energetic Glow!\n [ER] Energetic Ray!\n " ) if choice == "HR" or choice == "Hr" or choice == "hr": AttacksOO.SupportSpell(WSD["Roselyn"].Weapon1, "Roselyn").HealthyRay elif choice == "HG" or choice == "Hg" or choice == "hg": Skills.HealthyGlow("Roselyn", "NormalIvoryWand0") elif choice == "ER" or choice == "Er" or choice == "er": Skills.EnergeticRay("Roselyn", "NormalIvoryWand0") elif choice == "EG" or choice == "Eg" or choice == "eg": Skills.EnergeticGlow("Roselyn", "NormalIvoryWand0") elif choice == "I" or choice == "i": choice = input( "Select an item!\n [SC] Strawberry Candy!\n [PO] Pearl Ointment!\n [SS] Soothing Salve!\n " ) if choice == "SC" or choice == "Sc" or choice == "sc": Items.StrawberryCandy("Roselyn") elif choice == "PO" or choice == "Po" or choice == "po": Items.PearlOintment("Roselyn") elif choice == "SS" or choice == "Ss" or choice == "ss": Items.SoothingSalve("Roselyn") elif choice == "P" or choice == "p": ItemUsed = eval("Items." + input("Item is: ")) exec(str(ItemUsed("Roselyn"))) elif choice == "C" or choice == "c": choice = input( "Select a Type!\n [A]ttackcheck!\n [S]killcheck!\n [I]temcheck!\n " ) User = "******" UserLevel = WSD[User].Level if choice == "A" or choice == "a": Check.Attackcheck(User).Confirm elif choice == "S" or choice == "s": Check.Skillcheck(User, UserLevel).Choice elif choice == "I" or choice == "i": Check.Itemcheck(User).Confirm
async def skill(ctx, *args): skill_string = combine_args(*args) await ctx.send(embed=Skills.get_skill(skill_string))