Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Kill off an enemy with spell  (Read 4632 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
Kill off an enemy with spell
« on: February 10, 2009, 06:21:35 AM »

I have set up an object (sprite) in a scene.  It's a monster and I want to kill it with a spell.

I have no problem getting rid it if I use this script on the monster--you fight it to death.

Code: WME Script
  1.  
  2. #include "scripts\base.inc"
  3.  
  4. ehealth = hud.GetControl("ehealth")//health of monster--reduced by increments of 10
  5. health = hud.GetControl("health");   //your health--reduced by increments of 5
  6.  
  7. on "LeftClick"
  8.  
  9. if(ehealth.Text == 10)
  10. {
  11. this.Active = false;
  12. this.Visible = false;
  13. ehealth.Text = 0;
  14. }
  15. else
  16. if (!(ehealth.Text == 0))
  17. {
  18. hud.SubtractHealth(5);
  19. hud.SubtractEH(10);
  20. }
  21. else
  22. {hud.SubtractHealth(5);
  23. }
  24.  
  25.  

Works fine.


But I have a spell system I'd like to work with and rather than kill off the monster by clicking on it, I'd rather click on the spell to get rid of the monster.

The spell system is in a window and when I click on the spell in the window--although it seems to be coded alright--nothing happens -- I get an error about my GetControl script for the window that holds the spells but my script to access that seems OK. 

If I put the same script on the object I want to begone, everything works fine--I'm a little bit puzzled. 

My spells are in a window that's separate from the window that has all the info about the player's and monster's health.  I'ts called up when you click on a button called spells in the window that has the info about the player's and monster's health.
« Last Edit: February 12, 2009, 10:40:14 PM by Catacomber »
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

Birdline

  • Supporter
  • Occasional poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 57
    • View Profile
    • Birdline Web Site
Re: Kill off an enemy with spell
« Reply #1 on: February 10, 2009, 08:47:14 AM »

Hi Catacomber,
I don't have the whole picture here (what happens in the windows),
but getting error for GetControl, means maybe the engine does not know that this is a window.
I mean there is probably a problem with the variable. Is it a global? How you pass that from one window to the other?

BTW, Why you use two separate windows?

Spyros

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Kill off an enemy with spell
« Reply #2 on: February 10, 2009, 01:09:02 PM »

Yes, please show us the actual script that's giving you errors (and what errors exactly?).
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: Kill off an enemy with spell
« Reply #3 on: February 10, 2009, 04:08:58 PM »

Thanks, Birdline and Mnemonic.  Let me try it with one window and see what happens. That may solve my problem.

I have so much stuff going on in the first window, I wanted to keep the spell inventory window separate---it's not active in all the scenes and I don't need it to work like the regular inventory window as it will only have a few spells.  So I'll try it in one window and see what happens.

I'll be back if I continue to get an error.  Thanks for your prompt reply.  : )
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: Kill off an enemy with spell
« Reply #4 on: February 10, 2009, 08:46:02 PM »

I'm still having a problem killing the monster.

The monster's name is Ent.

I have my spells in their own window.  (It just seems easier this way because the HUD is very filled up with objects as it is.)

The code on the Ent is very simple--if you left click on him you take damage.  Works fine.

When I click on a button Spells in the HUD it brings up the Spells window with the blast spell and a close button.  The close button works fine.

The code on the spells button:

Code: WME Script
  1.  
  2. #include "scripts\base.inc"
  3.  
  4. on "blast"
  5.  
  6. ehealth = hud.GetControl("ehealth");
  7. health = hud.GetControl("health");
  8.  
  9. if(ehealth.Text == 0)
  10. {
  11.  
  12. Monster.Active = false;
  13. Monster.Visible = false;
  14. }
  15. else
  16. if (!(ehealth.Text == 0))
  17. {
  18. hud.SubtractHealth(5);
  19. hud.SubtractEH(10);
  20. }
  21.  
  22. In scriptinit for scene:
  23.  
  24. varEnt = Scene.GetNode("Ent");
  25. Monster = ent
  26.  
  27.  

(Monster is a global in base.inc script

Nothing works when I left click on the blast spell. So the problem seems to be the script on the blast spells button--I tried attaching it to the spells window script and had the same problem. 

I get this script error:

14:49: Compiling script 'scenes\House_Arrest3\scr\scene_init.script'...
14:49:   Error@line 14: Variable 'monster' is referenced but not defined


Any help, as always, is appreciated.
« Last Edit: February 12, 2009, 10:42:03 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: Kill off an enemy with spell
« Reply #5 on: February 10, 2009, 09:49:58 PM »

I resolved the script error.  Now I have no script errors but the Ent takes no damage and the player takes no damage.  I'm puzzled.  The window is transparent so that's not the problem.  The close button works fine.
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: Kill off an enemy with spell
« Reply #6 on: February 10, 2009, 10:11:17 PM »

The problem seems to be the monster.

If I just put script that reduces the player's health on the button, everything is fine and will probably be fine if I reduce the health of the monster but if I try to do anything to get the Ent to disappear, it doesn't work.
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: Kill off an enemy with spell
« Reply #7 on: February 11, 2009, 04:15:17 AM »

Well, I solved it by moving the spell system to the HUD and using very simple script:

Code: WME Script
  1. on "spells"
  2. {
  3. health = hud.GetControl("health");   //player health
  4. ehealth = hud.GetControl("ehealth")// monster health
  5. if(!(ehealth.Text == 0))           
  6. {
  7. hud.SubtractHealth(5)//subtract player's health = will vary based on certain things
  8. hud.SubtractEH(10);   //subtract monster's health = also will vary based on certain things
  9. }
  10. else
  11. {
  12. eh = hud.GetControl("eh");   //button for text that says Enemy Health
  13. var Ent = Scene.GetNode("Ent");   //adorable monster that I've been dying to kill
  14. if(ehealth.Text == 0)
  15. {
  16. Ent.Active = false//this and following stuff gets rid of Ent from scene
  17. Ent.Visible = false;
  18. eh.Visible = false//this and following stuff gets rid of monster stats
  19. ehealth.Visible = false;
  20. }
  21. }
  22. }
  23.  

Killing off the player is handled through the method that removes player's health.

The wicked Ent is dead!!!!!!!!!!   :  )

Thanks for all your help.   
« Last Edit: February 12, 2009, 10:42:42 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: Kill off an enemy with spell
« Reply #8 on: February 11, 2009, 06:03:25 AM »

Now I'm convinced WME can be used to make a full-blown rpg game.  :  )  Ours is a hybrid adventure/point and click/rpg game and I want to concentrate on things other than fighting-------but am pleased to know the engine can be stretched....and stretched.  :  )
« Last Edit: February 11, 2009, 06:07:29 AM by Catacomber »
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  
 

Page created in 0.093 seconds with 21 queries.