April 28, 2024, 07:00:38 AM
Welcome,
Guest
Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Forum rules
-
please read before posting, it can save you a lot of time.
Home
Help
Search
Calendar
Login
Register
Wintermute Engine Forum
>
Wintermute Engine
>
Technical forum
>
Topic:
Fighting question : ) )
« previous
next »
Pages: [
1
]
Print
Author
Topic: Fighting question : ) ) (Read 3482 times)
0 Members and 1 Guest are viewing this topic.
Catacomber
Supporter
Frequent poster
Karma: 0
Offline
Gender:
Posts: 443
I love mice.
Fighting question : ) )
«
on:
February 12, 2009, 04:58:03 AM »
I have scenes where you fight a monster. The script to fight the monster is below. But it occurs to me that the player might stop fighting the monster---that is stop pressing the spell button.
Now I don't know any self-respecting monster who wouldn't take advantage of that to deliver a big WHAMMO to the player.
But how do you code the player getting reduced health when player doesn't do anything?
Can't be on left click, can't be on spells, player isn't doing anything at all. Ball is in monster's court.
Code: WME Script
on
"spells"
{
var
k =
Scene
.
GetNode
(
"Kaboom"
)
;
health = hud.
GetControl
(
"health"
)
;
ehealth = hud.
GetControl
(
"ehealth"
)
;
CBeans = hud.
GetControl
(
"CBeans"
)
;
if
(
!
(
ehealth.
Text
==
0
)
&& !
(
CBeans.
Text
==
0
)
)
{
k.
Active
=
true
;
k.
Visible
=
true
;
Game
.
PauseMusic
+site:docs.dead-code.org/wme/generated&hl=en&lr=&as_qdr=all&filter=0">
PauseMusic
(
)
;
this
.
PlaySound
(
"Music\Explode.ogg"
)
;
hud.
SubtractHealth
(
5
)
;
hud.
SubtractEH
(
10
)
;
hud.
SubtractMana
(
1
)
;
Sleep
(
200
)
;
k.
Active
=
false
;
k.
Visible
=
false
;
}
else
{
ehealth = hud.
GetControl
(
"ehealth"
)
;
CBeans = hud.
GetControl
(
"CBeans"
)
;
if
(
!
(
ehealth.
Text
==
0
)
&&
(
CBeans.
Text
==
0
)
)
{
var
x = hud.
GetControl
(
"loc"
)
;
x.
Text
=
"Better drink some coffee. Your caffeine level is 0."
;
}
else
{
eh = hud.
GetControl
(
"eh"
)
;
ehealth = hud.
GetControl
(
"ehealth"
)
;
CBeans = hud.
GetControl
(
"CBeans"
)
;
if
(
(
ehealth.
Text
==
0
)
&& !
(
CBeans.
Text
==
0
)
)
{
var
Ent =
Scene
.
GetNode
(
"Ent"
)
;
Ent.
Active
=
false
;
Ent.
Visible
=
false
;
Game
.
UnloadObject
(
"Ent"
)
;
eh.
Visible
=
false
;
ehealth.
Visible
=
false
;
Game
.
ResumeMusic
(
)
;
}
}
}
}
I'm not terribly hung up on this as our game has a lot going on other than fighting and our monsters could all be wimps (I have a pet python who is a total wimp, to some he might be considered a monster), but the question entered my mind. ; )))
«
Last Edit: February 12, 2009, 04:36:13 PM by Catacomber
»
Logged
http://www.catacomber.com/
Code: WME Script
Mnemonic is wonderful.
mylesblasonato
Developer
Frequent poster
Karma: 0
Offline
Gender:
Posts: 265
"Give up is to fail as sacrifice is to succeed"
Re: Fighting question : ) )
«
Reply #1 on:
February 12, 2009, 10:07:47 AM »
Hi Catacomber,
What you need is a while loop that tests all the time if something is getting pressed or if an event is happening, if it's not then loose health. You will need a timer before the while loop as well to give the players time to do something, after that timer (say 5 seconds) is gone then you do the while test loop. If something happens then do this, if nothing then lose health.
Hope this makes sense, if it doesn't then let me know and ill do the code for it
Cheers
Myles Blasonato.
Logged
Lead Game Designer, Royal Wins.
@mylesblasonato
@royalwins
http://au.linkedin.com/pub/myles-blasonato/26/600/a38
Catacomber
Supporter
Frequent poster
Karma: 0
Offline
Gender:
Posts: 443
I love mice.
Re: Fighting question : ) )
«
Reply #2 on:
February 12, 2009, 03:40:34 PM »
Let me try it, Myles, and if I can't get it to work, if it is OK with you, I will pm you.
Logged
http://www.catacomber.com/
Code: WME Script
Mnemonic is wonderful.
Catacomber
Supporter
Frequent poster
Karma: 0
Offline
Gender:
Posts: 443
I love mice.
Re: Fighting question : ) )
«
Reply #3 on:
February 12, 2009, 07:44:43 PM »
Well, I got up a script and it works so well the player is dead within minutes. : ) ) )
Code: WME Script
for
(
var
timer=
6
;timer>
-1
;timer = timer
-1
)
{
spells = hud.
GetControl
(
"spells"
)
;
//spell button
while
(
spells.
Pressed
=
false
)
{
hud.
SubtractHealth
(
2
)
;
Sleep
(
100
)
;
}
}
So I guess my timer should be longer or sleep longer. : )
Much thanks -- this seems to be the solution.
«
Last Edit: February 12, 2009, 08:02:23 PM by Catacomber
»
Logged
http://www.catacomber.com/
Code: WME Script
Mnemonic is wonderful.
Catacomber
Supporter
Frequent poster
Karma: 0
Offline
Gender:
Posts: 443
I love mice.
Re: Fighting question : ) )
«
Reply #4 on:
February 12, 2009, 07:59:37 PM »
A timer of 100 and a sleep of 1000 works very well!!!!
Thanks again!!!! Now my spell system is complete and monsters are no longer sissies!!!!
Logged
http://www.catacomber.com/
Code: WME Script
Mnemonic is wonderful.
Catacomber
Supporter
Frequent poster
Karma: 0
Offline
Gender:
Posts: 443
I love mice.
Re: Fighting question : ) )
«
Reply #5 on:
February 14, 2009, 07:01:04 AM »
Code: WME Script
for
(
var
timer=
100
;timer>
-1
;timer = timer
-1
)
{
ehealth = hud.
GetControl
(
"ehealth"
)
;
health = hud.
GetControl
(
"health"
)
;
spells = hud.
GetControl
(
"spells"
)
;
var
Ent =
Scene
.
GetNode
(
"Ent"
)
;
while
(
spells.
Pressed
==
false
&& !
(
ehealth.
Text
==
0
)
&& !
(
health.
Text
==
0
)
)
//ehealth is health of monster and health is health of player
{
hud.
SubtractHealth
(
1
)
;
Game
.
PauseMusic
+site:docs.dead-code.org/wme/generated&hl=en&lr=&as_qdr=all&filter=0">
PauseMusic
(
)
;
this
.
PlaySound
(
"Music\Whoosh.ogg"
)
;
Sleep
(
1000
)
;
}
}
I had to tweak this to test whether the monster had health and the player had health. Now this works fine. The whoosh stuff is just the sound effect the monster makes on attacking. I am starting to think like a computer in 0's and 1's---how lovely. : )
I don't know where that + site stuff comes from when you put your code inside the code tags here. That command is just
Game.PauseMusic();
this.PlaySound("Music\Whoosh.ogg");
I didn't type all that strange stuff. : )
«
Last Edit: February 14, 2009, 07:16:02 AM by Catacomber
»
Logged
http://www.catacomber.com/
Code: WME Script
Mnemonic is wonderful.
Print
Pages: [
1
]
« previous
next »
Wintermute Engine Forum
>
Wintermute Engine
>
Technical forum
>
Topic:
Fighting question : ) )