Author Topic: Mid-Boss Avoidance  (Read 4696 times)

BaronBlade

  • Spike Dodger
  • Posts: 140
  • bees?
  • OS:
  • Windows 8.1/Server 2012 Windows 8.1/Server 2012
  • Browser:
  • Chrome 47.0.2526.106 Chrome 47.0.2526.106
    • View Profile
  • Playstyle: Keyboard
Mid-Boss Avoidance
« on: December 23, 2015, 05:33:18 PM »
Hello! I'm making a medley, and most of my bosses are going to have avoidance segments in the middle. However, I'm not quite sure how to change to the avoidance room, then go back with the boss's HP at the same level. I would guess that you could make the boss a persistent object, but is there anything else to keep in mind? Any help would be much appreciated. Thanks!
bean!

lawatson

  • The Kid
  • Posts: 331
  • I do things and I make things.
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 47.0.2526.80 Chrome 47.0.2526.80
    • View Profile
  • Playstyle: Keyboard
Re: Mid-Boss Avoidance
« Reply #1 on: December 23, 2015, 06:13:10 PM »
a global variable should work. in the room with the post-avoidance phase of the boss, just put in the create event, hp=global variable. of course this is literally a 5-second line of code i thought out, so there might be a more optimized way to do this.

edit: if this is studio where variables are treated like assdicks then yeah listen to someone else lol
(click to show/hide)

smoke weed everyday

Kyir

  • The Kid
  • Posts: 293
  • Normal Guy
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 47.0.2526.106 Chrome 47.0.2526.106
    • View Profile
  • Playstyle: Keyboard
Re: Mid-Boss Avoidance
« Reply #2 on: December 23, 2015, 06:52:43 PM »
If you want it to transition to an avoidance at the same HP value every time, you could make a duplicate of the boss that just starts at whatever value that is. So you'd have the original boss object that that ends when the avoidance starts, and then when that ends you just bring in the second one starting at the proper value.

Derf

  • Wannabe
  • Posts: 23
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Firefox 43.0 Firefox 43.0
    • View Profile
  • Playstyle: Keyboard
Re: Mid-Boss Avoidance
« Reply #3 on: December 23, 2015, 07:02:03 PM »
No you should be fine with a persistent object as long as you make sure to write in the object's code not to trigger any of its attacks if the room = the avoidance room. Lawatson's suggestion of a global.variable works as well and might be less cumbersome than using persistent objects in all honestly. Kyir's suggestion seems pointlessly inefficient to me.

I'd go with the global.variable suggestion if I were you, just make sure to reset it when the payer dies and you should be a-ok. Failing that persistent objects will do fine.

Kyir

  • The Kid
  • Posts: 293
  • Normal Guy
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 47.0.2526.106 Chrome 47.0.2526.106
    • View Profile
  • Playstyle: Keyboard
Re: Mid-Boss Avoidance
« Reply #4 on: December 23, 2015, 08:30:06 PM »
Persistence is more trouble than it's worth in my opinion. My way has the added benefit of simplifying things if you want attacks to change after the avoidance. There are plenty of options to choose from when it comes to this sort of thing though.

BaronBlade

  • Spike Dodger
  • Posts: 140
  • bees?
  • OS:
  • Windows 8.1/Server 2012 Windows 8.1/Server 2012
  • Browser:
  • Chrome 47.0.2526.106 Chrome 47.0.2526.106
    • View Profile
  • Playstyle: Keyboard
Re: Mid-Boss Avoidance
« Reply #5 on: December 23, 2015, 09:52:39 PM »
Persistence is more trouble than it's worth in my opinion. My way has the added benefit of simplifying things if you want attacks to change after the avoidance. There are plenty of options to choose from when it comes to this sort of thing though.

Thanks for the tip, Kyir! With your way, though, would I be able to keep the healthbar at a fraction of the total health? I'm really unfamiliar with how healthbars are handled in gamemaker studio.
bean!

Aelya

  • Cherry Eater
  • Posts: 55
  • love~ <3
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 47.0.2526.106 Chrome 47.0.2526.106
    • View Profile
    • stream
  • Playstyle: Keyboard
Re: Mid-Boss Avoidance
« Reply #6 on: December 23, 2015, 10:17:53 PM »
if it comes down to it, you could always just make your own healthbar object too

Kyir

  • The Kid
  • Posts: 293
  • Normal Guy
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 47.0.2526.106 Chrome 47.0.2526.106
    • View Profile
  • Playstyle: Keyboard
Re: Mid-Boss Avoidance
« Reply #7 on: December 23, 2015, 10:22:43 PM »
Persistence is more trouble than it's worth in my opinion. My way has the added benefit of simplifying things if you want attacks to change after the avoidance. There are plenty of options to choose from when it comes to this sort of thing though.

Thanks for the tip, Kyir! With your way, though, would I be able to keep the healthbar at a fraction of the total health? I'm really unfamiliar with how healthbars are handled in gamemaker studio.

To be honest, I don't have a lot of experience with visible health bars myself. If you want one that persists through the whole fight, one of the other options suggested would probably be more suited to it.

lawatson

  • The Kid
  • Posts: 331
  • I do things and I make things.
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 47.0.2526.80 Chrome 47.0.2526.80
    • View Profile
  • Playstyle: Keyboard
Re: Mid-Boss Avoidance
« Reply #8 on: December 23, 2015, 10:43:58 PM »
Not trying too hard to stray from the topic and just convey my point on one post, the math behind health bars is easy: You get the x position and the max length of the health bar, and then you divide the max length by the max HP and then multiply that result by the HP you already have. That gets you an interpolated value between the x position and the maximum length which you can use as either the xscale of a 1px long sprite OR just the rightwards coordinate in a rectangle.

tl;dr:
xdist=maxLength/maxHP*HP;

paired with

make_rectangle(x,y,x+xdist,y+anything);
OR
draw_sprite_ext(sprHealthBar,0,x,y,xdist,1,0,c_white,1);

And you can combine this with the code from before to get a working healthbar which is based on a global.HP variable or so-so. I hope you understand.
« Last Edit: December 23, 2015, 10:47:23 PM by lawatson »
(click to show/hide)

smoke weed everyday

Derf

  • Wannabe
  • Posts: 23
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Firefox 43.0 Firefox 43.0
    • View Profile
  • Playstyle: Keyboard
Re: Mid-Boss Avoidance
« Reply #9 on: December 24, 2015, 03:56:22 AM »
Persistence is more trouble than it's worth in my opinion. My way has the added benefit of simplifying things if you want attacks to change after the avoidance. There are plenty of options to choose from when it comes to this sort of thing though.
I don't understand why you would suggest making two objects when one will suffice. Not to mention you'd also have to create a second separate room to house this object unless you want to code an exception of what to spawn when re-entering the initial room, and by that point you're doing enough coding that you may as well use global variables anyway because they'll take less effort and lines of code. The added benefit you mention is also something that can easily and simply be achieved by either of the other two methods by putting a switch case or if/else statement for the bosses health in the code block where you program its attacks, which is likely something that will already be coded in if it's a functional boss. The problem with this suggestion is it appears initially very simple, and indeed the initial step is more simple than any of the other methods, but it's so inefficient that when it comes to things like handling re-spawning back into the room and having healthbars it's clearly the least efficient of the methods mentioned.

There are situations where you can get away with cowboy coding to create shortcuts in the design process, but when you're creating something as finicky as a three-part boss it's best to just use tried and true methods like global.variables that have literally no downsides and won't create fringe issues which will come back to bite you later on in the process.

Persistence is more trouble than it's worth in my opinion. My way has the added benefit of simplifying things if you want attacks to change after the avoidance. There are plenty of options to choose from when it comes to this sort of thing though.

Thanks for the tip, Kyir! With your way, though, would I be able to keep the healthbar at a fraction of the total health? I'm really unfamiliar with how healthbars are handled in gamemaker studio.
Are you coding the healthbar from scratch or using GMs in built functionality for healthbars? Lawatson's suggestion seems like a good way to go (and you could certainly do it with Kyir's method but it would probably end up being more confusing). It might be worthwhile using global.variables to handle the bosses health and making the heathbar object itself persistent.

Kyir

  • The Kid
  • Posts: 293
  • Normal Guy
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 47.0.2526.106 Chrome 47.0.2526.106
    • View Profile
  • Playstyle: Keyboard
Re: Mid-Boss Avoidance
« Reply #10 on: December 24, 2015, 04:34:16 AM »
Since these are fangames, you can pretty much get away with coding stuff any way you want. It's not like we're operating the LHC over here. Baron asked for suggestions, I gave him one, as did a bunch of other people. Sorry mine didn't live up to your best coding practices or whatever.

I don't see why everything always has to devolve into a climactic struggle between right and wrong with you.
« Last Edit: December 24, 2015, 04:37:13 AM by Kyir »

Derf

  • Wannabe
  • Posts: 23
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Firefox 43.0 Firefox 43.0
    • View Profile
  • Playstyle: Keyboard
Re: Mid-Boss Avoidance
« Reply #11 on: December 24, 2015, 04:43:29 AM »
Since these are fangames, you can pretty much get away with coding stuff any way you want. It's not like we're operating the LHC over here. Baron asked for suggestions, I gave him one, as did a bunch of other people. Sorry mine didn't live up to your best coding practices or whatever.

I don't see why everything always has to devolve into a climactic struggle between right and wrong with you.
What are you even talking about Kyir? We're trying to help BaronBlade. Your suggestion had things wrong with it, just because you were trying to help doesn't mean you're immune to criticism. Grow up.

infern0man1

  • ~(=^・ω・^)ψ
  • Global Moderator
  • Oatmeal Killer
  • Posts: 1.021
  • Dear sir stroke madam, fire exclamation point
  • OS:
  • Android 4.4.2 Android 4.4.2
  • Browser:
  • Chrome 47.0.2526.83 Chrome 47.0.2526.83
    • View Profile
    • Twitter
  • Playstyle: Keyboard
Re: Mid-Boss Avoidance
« Reply #12 on: December 24, 2015, 11:27:34 AM »
Edit: had a discussion with Derf; it seems everything arises from a small misunderstanding, which I fell into as well. Yes, there are multiple ways of doing this, and Derf was just saying Kyir's second suggestion would probably make things more difficult than it should, and Derf offered his own suggestion; he wasn't calling Kyir out on it, as everything is prone to criticism. Plus, even if you don't agree with criticism, it isn't mandatory that you respond as if it were a threat.

Hopefully these arguments can be avoided in the future.
« Last Edit: December 24, 2015, 12:00:13 PM by infern0man1 »

lawatson

  • The Kid
  • Posts: 331
  • I do things and I make things.
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 47.0.2526.80 Chrome 47.0.2526.80
    • View Profile
  • Playstyle: Keyboard
Re: Mid-Boss Avoidance
« Reply #13 on: December 24, 2015, 11:53:11 AM »
yeah man any answer is ok as long as it works without causing any other problems. this isnt a python competition lmfao
(click to show/hide)

smoke weed everyday

BaronBlade

  • Spike Dodger
  • Posts: 140
  • bees?
  • OS:
  • Windows 8.1/Server 2012 Windows 8.1/Server 2012
  • Browser:
  • Chrome 47.0.2526.106 Chrome 47.0.2526.106
    • View Profile
  • Playstyle: Keyboard
Re: Mid-Boss Avoidance
« Reply #14 on: December 24, 2015, 01:01:38 PM »
Alright, well, thanks for all the advice, guys! I'll try a few suggestions out and see what works.  :atkHappy:
bean!