Stress meter

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

Stress meter

Postby blacktrix » Mon Mar 24, 2008 1:35 am

Hey guys, I really could use some help here.

I need to develop a "stress meter" where certain actions will add to a "stress bar" and if the bar fills up, the game ends.

Is there any way to implement this using the software?
blacktrix
Junior Member
 
Posts: 6
Joined: Mon Dec 11, 2006 3:55 am

Postby Lyberodoggy » Mon Mar 24, 2008 6:51 am

It could be implemented using a stress integer variable. I can help you, but first I need to know if you have any knowledge on vbs programming, because you will need some to fully understand the method

I was working on creating an HP bar :P
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby blacktrix » Mon Mar 24, 2008 7:20 am

Haven't really tried out VBS programming as I just used AM for it's basic features for the time being, but I have a background in simple Java and C, but alot of Actionscript.
blacktrix
Junior Member
 
Posts: 6
Joined: Mon Dec 11, 2006 3:55 am

Postby Lyberodoggy » Mon Mar 24, 2008 11:59 am

Okay... So let's plan it a little. You create an integer variable called stress.
AM will automatically save and load it for you.
Then you change it using simple maths
Code: Select all
stress=stress=+i

Where "i" is replaced by the number you want to add to the player's stress with this action. You can also decrease the variable's value using the same method replacing "+" with "-".

Now the difficult part.
You can scale the player's stress from 1 to 100 or whatever you like. Well let's use 1 to 100 for this tutorial...

It's possible to simply display the score like with time (there's already a tutorial for that one). All you 've got to do is create a blank frame, add a text with right click and place it where you want the stress to be displayed in every frame. Then go to every frame of your game you want the stress to be displayed and merge them with the blank frame. Now go to project properties, under advanced select "Execute some VBScript code every time that a frame is loaded" and type this code:
Code: Select all
i=Action.GetMergedTextIndex
Text(i).Caption="Stress:"+" "+cStr(stress)

Of course you will have to check for the hard limits every time you decrease/increase the stress using Ifs. For example
Code: Select all
If 1<=stress and stress<=100 then
stress=stress+1
Else If stress>100
Action.GotoFrame "Overstressed"//remember to replace the frame or the whole code to fit your needs
End If
End If


Now, there is another way: The status bar. You can create a stress bar by adding a bitmap in a hotspot's appearance in the merged Stress Frame (note that the bitmap should be selected to stretch to fit the hotspot)...
Then using vbs you will be able to simply decrease/increase it by adding some code in the "Execute some VBScript code every time that a frame is loaded" like in the previous method. Type:
Code: Select all
hotspot(Action.GetMergedHotspotIndex).move x*15,y*15,w*15,h*15

where x,y are the coordinates of the hotspot and w,h its width and height.
Well in case you can't get it yet, you must select a permanent set of x,y and h and alter the w depending on the variable's value (that's for an horizontal bar. If you create a vertical one you will need to decrease the value of y to make the bar go up).
Now if you just type the code I wrote above you won't have any results. You will need to integrate the stress variable and multiply it with w, then make some other mathematical procedures to have a functional bar. I will try to make a sample, but since you 've worked on C, I think you will find your way out (and if you do, please post it here for me to see it :P).


Note that if you alter the stress in a frame and you use the bar method, you will have either to reload the frame by going to it again
Code: Select all
Action.GotoFrame "Action.GetCurrentFrameName"

or to execute the code that is executed every time a frame is loaded from the hotspot or dialogue that changes the stress variable

Anyway, if there's anything you don't get, feel free to ask.

To Moderator Team: please, transfer this one to tutorials, could be useful.
Last edited by Lyberodoggy on Mon Mar 24, 2008 12:56 pm, edited 1 time in total.
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Lyberodoggy » Mon Mar 24, 2008 12:46 pm

Well the w coordinate multiplier that worked for me was stress*(5/2).

I 've also got to say that the bar method can get better by doing these actions: Create a VBS Procedure, by going to VBS Procedures and typing these:
Code: Select all
Sub ChangeBar(x,y,w,h)
Hotspot(Action.GetMergedHotspotIndex).move x*15,y*15,stress*w*15,h*15
End Sub

Now go to "Execute some VBS after a frame is loaded" like in the previous tutorial and type these:
Code: Select all
ChangeBar 0,575,5/2,22
Action.CreateTimedEvent 0.1,"ChangeBar 0,575,5/2,22",True

Where the numbers must be replaced with the ones that fit your project.

I 'm attaching a sample of this method now.
Attachments
BarTutorial.rar
The sample project using the bar method
(97.95 KiB) Downloaded 476 times
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Lyberodoggy » Mon Mar 24, 2008 1:57 pm

Here goes another sample project that uses both methods to display the stress. Note that this can be reversed to be used as HP meter or something like that.
Attachments
BarTutorial.rar
Both methods sample
(98.04 KiB) Downloaded 503 times
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby blacktrix » Mon Mar 24, 2008 2:57 pm

OMG...... Thank you so much! This really helps alot.
Will make the changes and see if it works.

Thank you so much again! You're a life saver!
blacktrix
Junior Member
 
Posts: 6
Joined: Mon Dec 11, 2006 3:55 am

Postby Lyberodoggy » Mon Mar 24, 2008 2:57 pm

hehe... Thanks. If you have any problem, contact me...
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Mystery » Mon Mar 24, 2008 7:17 pm

Moved to the Tutorials subforum, since it might help also others who would like to use such a feature.

Thanks Lyberodoggy :)
Last edited by Mystery on Mon Mar 24, 2008 7:45 pm, edited 1 time in total.
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

Postby Lyberodoggy » Mon Mar 24, 2008 7:36 pm

You are welcome :P May I ask why many people write my nickname "Liberodoggy" and not "Lyberodoggy".

It doesn't really matter, I 'm just curious... :lol:
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Mystery » Mon Mar 24, 2008 7:46 pm

Awww, I'm sorry for misspelling your name :oops:

(Don't know why, maybe it is more natural for me :lol: I'll pay attention next time to spell it right :))
Last edited by Mystery on Mon Mar 24, 2008 8:06 pm, edited 1 time in total.
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

Postby Lyberodoggy » Mon Mar 24, 2008 8:00 pm

No, there's really no problem with that. It's just that it has happened with another member too and I 'm starting to believe it can't be coincidence...
Anyway, no need to apologize.
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Imari » Tue Mar 25, 2008 12:32 am

I hope that I haven't done that, but maybe its' because "Lybero" looks a little like "Liberty" and we're subconsciously thinking of you as "FreedomDoggy". :wink:

Oh wait... or maybe it looks like "Library" and because of your quick answers to our questions, we're thinking of you as "EncyclopediaDoggy".... ::ducks::
User avatar
Imari
VIP
 
Posts: 872
Joined: Fri Jun 20, 2003 4:49 pm
Location: Virginia, USA

Postby Lyberodoggy » Tue Mar 25, 2008 8:34 am

:lol: :lol: :lol:
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby binhotinto » Thu Apr 10, 2008 12:53 am

Code: Select all
Sub gameover
If stress <=0 Then Action.GoToFrame "m8"
End Sub


I used this to go to another frame called "m8" when the value of stress becomes zero or less.
but its not working.
The procedure is called everytime a frame is loaded.

Any help?
binhotinto
Member
 
Posts: 50
Joined: Wed Jun 13, 2007 8:55 pm

Postby Mystery » Thu Apr 10, 2008 12:03 pm

What other script are you using in connection with the stress variable?
This might help us to identify the problem.
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

Postby Lyberodoggy » Thu Apr 10, 2008 2:44 pm

binhotinto, if this check is performed only when the frame loads, it won't do anything if the player's hp becomes 0 during the frame. To solve this problem all you have to do is call the sub from the frame's advanced using a timed event:
Code: Select all
Action.CreateTimedEvent 0.1,"gameover",True


Also, your code needs fixing:
Code: Select all
Sub gameover
If stress <=0 Then
Action.GoToFrame "m8"
end if
End Sub
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby binhotinto » Thu Apr 10, 2008 8:59 pm

Thanks
Its working now, but theres another problem, when the stress <=0, it loads the "m8" frame infinite times.
I need to stop the timedevent after the "m8" frame is loaded but I dont know how to do it.
binhotinto
Member
 
Posts: 50
Joined: Wed Jun 13, 2007 8:55 pm

Postby Lyberodoggy » Thu Apr 10, 2008 9:04 pm

GM could help with that, but you can solve it in a way doing this:
Add a line in the code so it looks like this one
Code: Select all
Sub gameover
If stress <=0 and gameoverframe=0 Then
Action.GoToFrame "m8"
end if
End Sub


create the gameoverframe integer variable
go to the "m8" frame.
in advanced tab type
Code: Select all
gameoverframe=1


This helps only for the time being. Please ask GM for information on how to stop a timed event. I don't know how to do that.
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby binhotinto » Thu Apr 10, 2008 9:20 pm

Working at 100% now, thanks
Tomorrow i'll post here in the forum a demonstration of what i'm making with this stress meter.
binhotinto
Member
 
Posts: 50
Joined: Wed Jun 13, 2007 8:55 pm

Postby Lyberodoggy » Thu Apr 10, 2008 9:43 pm

okay... waiting for that. I 'm also preparing something big but won't present it until I get AM full to compile it...
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby binhotinto » Fri Apr 11, 2008 12:28 am

Its done.

Link to download it

Go to the last post from here -> http://www.adventuremaker.com/phpBB2/vi ... php?t=3071
binhotinto
Member
 
Posts: 50
Joined: Wed Jun 13, 2007 8:55 pm


Return to Post Your Own Tutorials

Who is online

Users browsing this forum: No registered users and 0 guests

cron