mock fighting system (need help but on right path)
Posted: Mon Mar 10, 2014 1:20 pm
In the attempt to involve some RPG style elements, I have been working on a fighting system which uses videos and I'm having a little trouble with the code. I think I'm no the right path but if anybody could help me here would be appreciated...
1. First, these are in the frame properties.
ClawSlash = 1
Text(1).Caption=""+CStr(HP)
Text(2).Caption=""+CStr(ATP)
Text(3).Caption=""+CStr(EnemyHP)
Then the subs:
(ATP is attack points, a clocking up variable throughout the game as you level up. The sounds all work fine from the external folder and are mere grunts and such for indication of a hot or miss.)
Sub EnemyDeath
If EnemyHP =< 1 Then
Action.GoToFrame "Victory".2,1
EXP = EXP + 10
End If
End Sub
Sub ClawAttack
If ATP < 20 Then
randomize
i = int( RND * 3 ) + 1
If i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 12
If i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 8
If i = 3 then PlaySound GetPath(2) + "Dammit!.mp3", 1, 9
Action.CreateTimedEvent 10, "ClawSlash = 1", False
EXP = EXP + 1
ElseIf ATP >= 20 AND ATP < 99 Then
randomize
i = int( RND * 3 ) + 1
If i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 20
If i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 9
If i = 3 then PlaySound GetPath(2) + "Dammit!.mp3", 1, 9
Action.CreateTimedEvent 9, "ClawSlash = 1", False
EXP = EXP + 1
ElseIf ATP >= 100 AND ATP < 174 Then
randomize
i = int( RND * 3 ) + 1
If i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 25
If i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 12
If i = 3 then PlaySound GetPath(2) + "Dammit!.mp3", 1, 9
Action.CreateTimedEvent 7, "ClawSlash = 1", False
EXP = EXP + 1
ElseIf ATP >= 175 AND ATP < 349 Then
randomize
i = int( RND * 3 ) + 1
If i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 50
If i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 20
If i = 3 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 5 : HP = HP - 5
Action.CreateTimedEvent 6, "ClawSlash = 1", False
EXP = EXP + 2
ElseIf ATP >= 350 AND ATP < 499 Then
randomize
i = int( RND * 3 ) + 1
If i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 70
If i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 35
If i = 3 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 55 : HP = HP - 15
Action.CreateTimedEvent 5, "ClawSlash = 1", False
EXP = EXP + 3
EnemyDeath
ElseIf ATP >= 500 Then
randomize
i = int( RND * 3 ) + 1
If i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 100
If i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 75
If i = 3 then PlaySound GetPath(2) + "Nice!.mp3", 1, 9 : EnemyHP = EnemyHP - 55
Action.CreateTimedEvent 3, "ClawSlash = 1", False
EXP = EXP + 3
End If
End Sub
And finally the hotspot properties which for this example is a claw button.
ClawAttack
EnemyDeath
Text(1).Caption=""+CStr(HP)
Text(2).Caption=""+CStr(ATP)
Text(3).Caption=""+CStr(EnemyHP)
So, when ClawSlash = 1, the claw attack is available. The point of the code it to refer to how many ATP you have and effect damage to the EnemyHP. The Higher your ATP (until over 500 for this example) The more damage you do with this attack. A timed event is supposed to be used to disable the attack (preventing multiple clicks instantly) and give the player a certain number of seconds before they can use it again (number of seconds declines in correlation with higher ATP and thus higher Levels and Experience).
PROBLEMS:
I keep getting an automation error at random points. Sometimes, the score will work, but the timed event won't... it'll work twice or so then give same error... basically that damned automation error is holding me back.
I thought of using a Select Case sub instead of an IF sub...
Sub ClawAttack
Select Case ATP
Case ATP < 20
randomize
i = int( RND * 3 ) + 1
if i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 12
if i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 8
if i = 3 then PlaySound GetPath(2) + "Dammit!.mp3", 1, 9
Action.CreateTimedEvent 10, "ClawSlash = 1", False
EXP = EXP + 1
EnemyDeath
Case ATP >= 20 AND ATP < 99
randomize
i = int( RND * 3 ) + 1
if i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 20
if i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 9
if i = 3 then PlaySound GetPath(2) + "Dammit!.mp3", 1, 9
Action.CreateTimedEvent 9, "ClawSlash = 1", False
EXP = EXP + 1
EnemyDeath
Case ATP >= 100 AND ATP < 174
randomize
i = int( RND * 3 ) + 1
if i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 25
if i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 12
if i = 3 then PlaySound GetPath(2) + "Dammit!.mp3", 1, 9
Action.CreateTimedEvent 7, "ClawSlash = 1", False
EXP = EXP + 1
EnemyDeath
Case ATP >= 175 AND ATP < 349
randomize
i = int( RND * 3 ) + 1
if i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 50
if i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 20
if i = 3 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 5 : HP = HP - 5
Action.CreateTimedEvent 6, "ClawSlash = 1", False
EXP = EXP + 2
EnemyDeath
Case ATP >= 350 AND ATP < 499
randomize
i = int( RND * 3 ) + 1
if i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 70
if i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 35
if i = 3 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 55 : HP = HP - 15
Action.CreateTimedEvent 5, "ClawSlash = 1", False
EXP = EXP + 3
EnemyDeath
Case ATP >= 500
randomize
i = int( RND * 3 ) + 1
if i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 100
if i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 75
if i = 3 then PlaySound GetPath(2) + "Nice!.mp3", 1, 9 : EnemyHP = EnemyHP - 55
Action.CreateTimedEvent 3, "ClawSlash = 1", False
EXP = EXP + 3
EnemyDeath
End Select
End Sub
I tried taking out the EnemyDeath sub and placing it in the Attack hotspot, but no luck. What am I missing? >.< (frustrations eh)
1. First, these are in the frame properties.
ClawSlash = 1
Text(1).Caption=""+CStr(HP)
Text(2).Caption=""+CStr(ATP)
Text(3).Caption=""+CStr(EnemyHP)
Then the subs:
(ATP is attack points, a clocking up variable throughout the game as you level up. The sounds all work fine from the external folder and are mere grunts and such for indication of a hot or miss.)
Sub EnemyDeath
If EnemyHP =< 1 Then
Action.GoToFrame "Victory".2,1
EXP = EXP + 10
End If
End Sub
Sub ClawAttack
If ATP < 20 Then
randomize
i = int( RND * 3 ) + 1
If i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 12
If i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 8
If i = 3 then PlaySound GetPath(2) + "Dammit!.mp3", 1, 9
Action.CreateTimedEvent 10, "ClawSlash = 1", False
EXP = EXP + 1
ElseIf ATP >= 20 AND ATP < 99 Then
randomize
i = int( RND * 3 ) + 1
If i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 20
If i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 9
If i = 3 then PlaySound GetPath(2) + "Dammit!.mp3", 1, 9
Action.CreateTimedEvent 9, "ClawSlash = 1", False
EXP = EXP + 1
ElseIf ATP >= 100 AND ATP < 174 Then
randomize
i = int( RND * 3 ) + 1
If i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 25
If i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 12
If i = 3 then PlaySound GetPath(2) + "Dammit!.mp3", 1, 9
Action.CreateTimedEvent 7, "ClawSlash = 1", False
EXP = EXP + 1
ElseIf ATP >= 175 AND ATP < 349 Then
randomize
i = int( RND * 3 ) + 1
If i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 50
If i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 20
If i = 3 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 5 : HP = HP - 5
Action.CreateTimedEvent 6, "ClawSlash = 1", False
EXP = EXP + 2
ElseIf ATP >= 350 AND ATP < 499 Then
randomize
i = int( RND * 3 ) + 1
If i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 70
If i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 35
If i = 3 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 55 : HP = HP - 15
Action.CreateTimedEvent 5, "ClawSlash = 1", False
EXP = EXP + 3
EnemyDeath
ElseIf ATP >= 500 Then
randomize
i = int( RND * 3 ) + 1
If i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 100
If i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 75
If i = 3 then PlaySound GetPath(2) + "Nice!.mp3", 1, 9 : EnemyHP = EnemyHP - 55
Action.CreateTimedEvent 3, "ClawSlash = 1", False
EXP = EXP + 3
End If
End Sub
And finally the hotspot properties which for this example is a claw button.
ClawAttack
EnemyDeath
Text(1).Caption=""+CStr(HP)
Text(2).Caption=""+CStr(ATP)
Text(3).Caption=""+CStr(EnemyHP)
So, when ClawSlash = 1, the claw attack is available. The point of the code it to refer to how many ATP you have and effect damage to the EnemyHP. The Higher your ATP (until over 500 for this example) The more damage you do with this attack. A timed event is supposed to be used to disable the attack (preventing multiple clicks instantly) and give the player a certain number of seconds before they can use it again (number of seconds declines in correlation with higher ATP and thus higher Levels and Experience).
PROBLEMS:
I keep getting an automation error at random points. Sometimes, the score will work, but the timed event won't... it'll work twice or so then give same error... basically that damned automation error is holding me back.
I thought of using a Select Case sub instead of an IF sub...
Sub ClawAttack
Select Case ATP
Case ATP < 20
randomize
i = int( RND * 3 ) + 1
if i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 12
if i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 8
if i = 3 then PlaySound GetPath(2) + "Dammit!.mp3", 1, 9
Action.CreateTimedEvent 10, "ClawSlash = 1", False
EXP = EXP + 1
EnemyDeath
Case ATP >= 20 AND ATP < 99
randomize
i = int( RND * 3 ) + 1
if i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 20
if i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 9
if i = 3 then PlaySound GetPath(2) + "Dammit!.mp3", 1, 9
Action.CreateTimedEvent 9, "ClawSlash = 1", False
EXP = EXP + 1
EnemyDeath
Case ATP >= 100 AND ATP < 174
randomize
i = int( RND * 3 ) + 1
if i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 25
if i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 12
if i = 3 then PlaySound GetPath(2) + "Dammit!.mp3", 1, 9
Action.CreateTimedEvent 7, "ClawSlash = 1", False
EXP = EXP + 1
EnemyDeath
Case ATP >= 175 AND ATP < 349
randomize
i = int( RND * 3 ) + 1
if i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 50
if i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 20
if i = 3 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 5 : HP = HP - 5
Action.CreateTimedEvent 6, "ClawSlash = 1", False
EXP = EXP + 2
EnemyDeath
Case ATP >= 350 AND ATP < 499
randomize
i = int( RND * 3 ) + 1
if i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 70
if i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 35
if i = 3 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 55 : HP = HP - 15
Action.CreateTimedEvent 5, "ClawSlash = 1", False
EXP = EXP + 3
EnemyDeath
Case ATP >= 500
randomize
i = int( RND * 3 ) + 1
if i = 1 then PlaySound GetPath(2) + "GAH!.mp3", 1, 9 : EnemyHP = EnemyHP - 100
if i = 2 then PlaySound GetPath(2) + "grr.mp3", 1, 9 : EnemyHP = EnemyHP - 75
if i = 3 then PlaySound GetPath(2) + "Nice!.mp3", 1, 9 : EnemyHP = EnemyHP - 55
Action.CreateTimedEvent 3, "ClawSlash = 1", False
EXP = EXP + 3
EnemyDeath
End Select
End Sub
I tried taking out the EnemyDeath sub and placing it in the Attack hotspot, but no luck. What am I missing? >.< (frustrations eh)