<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
Hey everyone :)<BR>
I'm extremely new to programming as python is the first language I have attempted to learn (and I only started yesterday!)<BR>
I decided to start learning by attempting to create a short textbased rpg.<BR>
My progress so far has been rather haphazard to say the least, but I think I might be finally getting somewhere with this.<BR>
&nbsp;<BR>
Below is my code as it currently exists:<BR>
&nbsp;<BR>
<STRONG>#Character stats (lv 1)</STRONG><BR>
<STRONG>max_c_hp = 180<BR>max_c_mp = 30<BR>c_strength = 50<BR>c_defence = 25<BR>c_agility = 50<BR>c_fireball = 60<BR>c_heal = 100</STRONG><BR>
<STRONG>#Skeleton stats (lv1)</STRONG><BR>
<STRONG>max_e_hp = 230<BR>max_e_mp = 30<BR>e_strength = 48<BR>e_defence = 30<BR>e_agility = 50<BR>e_fireball = 75</STRONG><BR>
<STRONG>#Battle functions</STRONG><BR>
<STRONG>def battle_start(): #Allows player to choose to fight or run<BR>&nbsp;&nbsp;&nbsp; print 'A skeleton appears from the shadows!'<BR>&nbsp;&nbsp;&nbsp; fight_or_run = int(raw_input ('Do you fight[1] or run[2]?'))<BR>&nbsp;&nbsp;&nbsp; if fight_or_run == 1:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'You engage the enemy.'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; battle_menu() #Sends player to battle menu<BR>&nbsp;&nbsp;&nbsp; elif fight_or_run == 2:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; escape()</STRONG><BR>
<STRONG>def battle_menu(): #Allows player to choose primary action in battle<BR>&nbsp;&nbsp;&nbsp; print 'Attack[1]'<BR>&nbsp;&nbsp;&nbsp; print 'Magic[2]'<BR>&nbsp;&nbsp;&nbsp; print 'Escape[3]'<BR>&nbsp;&nbsp;&nbsp; menu_selection = int(raw_input ('Enter your choice.'))<BR>&nbsp;&nbsp;&nbsp; if menu_selection == 1:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c_attack()<BR>&nbsp;&nbsp;&nbsp; elif menu_selection == 2:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c_m_attack()<BR>&nbsp;&nbsp;&nbsp; elif menu_selection == 3:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; escape()</STRONG><BR>
<STRONG>def c_attack(): #Processes damage dealt by a physical attack<BR>&nbsp;&nbsp;&nbsp; damage_to_enemy = c_strength - e_defence <BR>&nbsp;&nbsp;&nbsp; print 'You inflicted', damage_to_enemy, "points of damage to your enemy"&nbsp; #shows damage dealt<BR>&nbsp;&nbsp;&nbsp; temp_e_hp - damage_to_enemy #!!!attempts to deduct damage_to_enemy from temp_e_hp!!!<BR>&nbsp;&nbsp;&nbsp; print temp_e_hp<BR>&nbsp;&nbsp;&nbsp; if temp_e_hp == 0:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; victory()<BR>&nbsp;&nbsp;&nbsp; else:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; battle_menu()</STRONG><BR>
<STRONG>def escape(): #Allows player to escape from a battle<BR>&nbsp;&nbsp;&nbsp; print 'You attempt to flee the battle!'<BR>&nbsp;&nbsp;&nbsp; if c_agility &gt; e_agility:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'You succssfully escape' #!!!Need to quit battle and return to field!!!<BR>&nbsp;&nbsp;&nbsp; elif c_agility &lt; e_agility:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'You fail to escape and miss a battle turn.' #!!!Need to find a way to miss a turn after tb system written!!!<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; battle_menu()<BR>&nbsp;&nbsp;&nbsp; elif c_agility == e_agility:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'You fail to escape and are forced to contine engaging the enemy.'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; battle_menu() #Sends player to battle menu</STRONG><BR>
<STRONG>#Battle flow<BR>temp_c_hp = max_c_hp # creates a temporary stat for characters hp, just to be used in this battle<BR>temp_e_hp = max_e_hp #creates a temporary stat for enemies hp, just to be used in this battle<BR>battle_start() # launches battle sequence<BR></STRONG><BR>
As you can see, I've annotated it rather thoroughly to display the (simple) processes being performed and there are several issues slowing my progress.&nbsp; The main one I need help with is in the c_attack function.&nbsp; For some reason, I cant manage to&nbsp;subtract damage_to_enemy from&nbsp;temp_e_hp.&nbsp; Any help with my script (especially with this problem) would be highly appreciated.<BR>
And for one final question, is there a way to use random percentages of a number.&nbsp; For example, to subtract 80 - 120 % of damage_to_enemy from temp_e_hp?<BR>
&nbsp;<BR>
Sorry for all the questions, but I'm totally stumped at the moment.<BR>
Thanks for your time<BR>
&nbsp;<BR>
-Jake<BR><br /><hr />She said what? About who? <a href='http://www.msnsearchstar.com' target='_new'>Shameful celebrity quotes on Search Star!</a></body>
</html>