Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Fighting question : ) )  (Read 3482 times)

0 Members and 1 Guest are viewing this topic.

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
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
  1. on "spells"
  2.   {
  3.     var k = Scene.GetNode("Kaboom");
  4.     health = hud.GetControl("health");
  5.     ehealth = hud.GetControl("ehealth");
  6.     CBeans = hud.GetControl("CBeans");
  7.       if(!(ehealth.Text == 0) && !(CBeans.Text == 0))
  8.       {
  9.         k.Active = true;
  10.         k.Visible = true;
  11.         Game.PauseMusic+site:docs.dead-code.org/wme/generated&hl=en&lr=&as_qdr=all&filter=0">PauseMusic();       
  12.         this.PlaySound("Music\Explode.ogg");
  13.         hud.SubtractHealth(5);
  14.         hud.SubtractEH(10);
  15.         hud.SubtractMana(1);
  16.         Sleep(200);
  17.         k.Active = false;
  18.         k.Visible = false;
  19.       }
  20. else
  21.       {
  22.         ehealth = hud.GetControl("ehealth");
  23.         CBeans = hud.GetControl("CBeans");
  24.           if(!(ehealth.Text == 0) && (CBeans.Text == 0))
  25.      {
  26.         var x = hud.GetControl("loc");
  27.         x.Text = "Better drink some coffee.  Your caffeine level is 0.";
  28.      }
  29. else
  30.     {
  31.     eh = hud.GetControl("eh");
  32.     ehealth = hud.GetControl("ehealth");
  33.     CBeans = hud.GetControl("CBeans");
  34.       if((ehealth.Text == 0) && !(CBeans.Text == 0))
  35.         {
  36.           var Ent = Scene.GetNode("Ent");
  37.           Ent.Active = false;
  38.           Ent.Visible = false;
  39.           Game.UnloadObject("Ent");
  40.           eh.Visible = false;
  41.           ehealth.Visible = false;
  42.           Game.ResumeMusic();
  43.        }
  44.        }
  45.        }
  46.        }
  47.  

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
  1. Mnemonic is wonderful.
  2.  

mylesblasonato

  • Developer
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 265
  • "Give up is to fail as sacrifice is to succeed"
    • View Profile
    • Royal Wins
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 :P
Cheers ::beer
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 Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
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
  1. Mnemonic is wonderful.
  2.  

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
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
  1. for (var timer=6;timer>-1;timer = timer -1)
  2.   {
  3.     spells = hud.GetControl("spells");//spell button
  4.     while (spells.Pressed = false)
  5.   {
  6.     hud.SubtractHealth(2);
  7.     Sleep(100);
  8.   }
  9.   }
  10.  

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
  1. Mnemonic is wonderful.
  2.  

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
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
  1. Mnemonic is wonderful.
  2.  

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: Fighting question : ) )
« Reply #5 on: February 14, 2009, 07:01:04 AM »

Code: WME Script
  1. for (var timer=100;timer>-1;timer = timer -1)
  2. {
  3. ehealth = hud.GetControl("ehealth");
  4. health = hud.GetControl("health");
  5. spells = hud.GetControl("spells");
  6. var Ent = Scene.GetNode("Ent");
  7. while (spells.Pressed == false && !(ehealth.Text == 0) && !(health.Text == 0))//ehealth is health of monster and health is health of player
  8.   {
  9.     hud.SubtractHealth(1);
  10.     Game.PauseMusic+site:docs.dead-code.org/wme/generated&hl=en&lr=&as_qdr=all&filter=0">PauseMusic();
  11.     this.PlaySound("Music\Whoosh.ogg");
  12.     Sleep(1000);
  13.   }
  14.   }
  15.  
  16.  

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
  1. Mnemonic is wonderful.
  2.  
 

Page created in 0.088 seconds with 24 queries.