Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[ABS] Enemy Magic System, using Events

This is a tutorial I did for gamingw.net a LONNG time ago, like 3 years ago. I'm just gonna post it here because its still pretty useful, to me at least.



What this does is, in an ABS, you can usually use some form of magic, right? But the enemies should know some magic too, and this tutorial will explain how to do that, and its quite simple.

Ok, create an event, make it parallel process, and enter this in.

<>Variable: [XXXX: magicwait] =, Random ( 0..9 )

In otherwords, go to the variable editing thing and make a variable (I called it magicwait) set to a random number between 0 and 9.

<>Conditional Branch: Variable [XXXX: magicwait] <=3
<>Local Switch: A = ON
<>
: Else Handler
<>Wait: 120 frames
<>
: End
<>
This makes it so that if the variable magicwait is less than 3, it turns a switch on.


Now make a new page with presetting that Local Switch A is ON, and make it parallel process. Enter this code.

<>Message: Enemy magic!
(I would replace this with a picture)
<>Show battle animation [M]: [monsterthing], [Magic Casting]
(This shows a magic casting animation on the monster casting the magic.)
<>Variable: [XXXX: X co] = Player X Coordinate
<>Variable: [XXXX: Y co] = Player Y Coordinate
(This sets the variables to the player's exact location.)
<>Variable: [XXXX: magicchance] = Random ( 0..3)
(THis sets the variable magicchance to a random number between 0 and 3, to see if the magic hits or misses.)
<>Conditional Branch: Variable [XXXX: magicchance] == 1
(This makes it so that if the variable equals 1, the player will get hit)
<>Show battle animation [M]: Player, [Lightning 2]
(This shows the battle animation on the player if he gets hit)
<>Change HP: Entire Party, - 3
<>Message: -Arshes- OUCH OH MY GOSH I GOT HIT BY LIGHTNING!!!!!
<>Local Switch: A = OFF
<>
(This damages the player, and then turn your switch off.)


: Else Handler
<>Variable: [XXXX: y change] = Random ( 0..2 )
<>Variable: [XXXX: x change] = Random ( 0..2 )
---(This randomizes your hero's X,Y coordinates, so the monster's magic will "miss" by a few squares)
<>Conditional Branch: Variable [XXXX: y change] == 1
<>Variable [XXXX: y co] += Random ( 1..5 )
<>
: Else handler
<>Variable [XXXX: y co] -= Random ( 1..5 )
<>
: End
<>Conditional Branch: Variable [XXXX: x change] == 1
<>Variable [XXXX: x co] += Random ( 1..5 )
<>
: Else Handler
<>Variable [XXXX: x co] -= Random ( 1..5)

Doing this makes it so that it can miss in all 4 "quadrants" of axis around your player, if you pretend your player is on 0,0.




Now FREEZE!


Click ok and go back to your map. Somewhere, anywhere, add an event, and don't do anything but name it something like "magicsquare", which is what I named it. After you add that, go back to the event we were editing and add this to finish it.

You need the blank event to become the target of the "missed" magic, because you can't just target an animation on nothing, right?



<>Change Event Location: [magicsquare], By variables [XXXX][XXXX}
(Those two variables should be the changed X coordinate and Y coordinate)
<>Show battle animation [M]: [magicsquare], [Lightning 2]
<>Local Switch: A = OFF
<>
: End
<>

That ends the programming. Of course, you can always edit it to have a greater chance of hitting, a less wide range of missing, or etc.

I hope this helped you and your game or your ABS!
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top