mock fighting system (need help but on right path)

This forum is meant for people to share their knowledge by writing their own tutorials for Adventure Maker.

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

mock fighting system (need help but on right path)

Postby Stitches » 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)
http://www.youtube.com/user/MaynardStaly/videos and http://libertycap.webs.com
“With a bit of luck, his life was ruined forever. Always thinking that just behind some narrow door in all of his favorite bars, men in red woolen shirts are getting incredible kicks from things he’ll never know.”
User avatar
Stitches
Active Member
 
Posts: 71
Joined: Tue Nov 12, 2013 3:56 am
Location: UK

Re: mock fighting system (need help but on right path)

Postby reneuend » Tue Mar 11, 2014 1:18 am

I think that in order to help you on this, I would need this code in a project. It's hard for me to see all the relationships and the paths. My guess is that your timed events are colliding with each other, but that's purely a guess.
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2686
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Re: mock fighting system (need help but on right path)

Postby Stitches » Tue Mar 11, 2014 2:30 am

Oh you're right there, dude! I played about for about 5 hours with this... taking little bits out and using portions at a time and it seems accessing the timed events is a problem. I started looking at some course on VBS for a better understanding.

This could help but I dunno if I'm right with it. (also I dunno if it should be a sub or in frame properties... but it calls a sub.

Dim AttackTimer
AttackTimer = Action.CreateTimedEvent(5,"CallSub",False)

With this code, am I to understand that now a variable has been created called AttackTimer and the Timedevent code has been assigned to it?

Now does this go in a sub and...

AttackTimer = 1

go into hotspot properties?

I don't know if I've mixed this up. But isn't the AttackTimer variable instantly set to 0 and incrementing it to 1 would activate it, thus starting the single timed event which would run once, in the case after five seconds?

To simplify the code without necessity of a project... let's look at it like this:
There is a claw button on the frame. When clicked, it's supposed to take an allocated amount of time before the player is allowed to click on it again. The time is supposed to depend on how high the ATP (or attack points) are. The higher the points, the more damage you will basically do with an attack and also the les time it will take for you to be able to attack again.

Using this method, I'm to have several attacks on the screen which can be clicked by the player offering different events in the game. I hope there is an ability to, the help files said you can have as many timed events as you want somewhere there. (Man, I am tired...)

***Incidentally while I have you, the PlayVideo command seems to have a problem. I code it fine, but it says there is a missing component and has a big error. Cannot find media object or something like that. It's been in one of the help files here, though on an initial read I wasn't able to see anybody post the solution, just a mention of it.

So there we go.
http://www.youtube.com/user/MaynardStaly/videos and http://libertycap.webs.com
“With a bit of luck, his life was ruined forever. Always thinking that just behind some narrow door in all of his favorite bars, men in red woolen shirts are getting incredible kicks from things he’ll never know.”
User avatar
Stitches
Active Member
 
Posts: 71
Joined: Tue Nov 12, 2013 3:56 am
Location: UK


Return to Post Your Own Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest

cron