don't click here

Sonic Max Question - Making a Simple Boss

Orrin

Press Start Screen
Mar 19, 2019
5
0
7
27
I've been trying for a couple of days now to make a boss, I've got lots of other things down but can't seem to make a boss. Anyone got any good versatile examples?
 

PM13

Shameless Recolor
Feb 25, 2018
80
79
128
Can you be a little more specific? What have you gotten done and what are you having trouble with in terms of implementing a boss?
 

Orrin

Press Start Screen
Mar 19, 2019
5
0
7
27
my main issue is creating an object that can take a specific amount of collisions before either being destroyed or changing into a different object (Like when Eggman runs away)
 

PM13

Shameless Recolor
Feb 25, 2018
80
79
128
Well there are a couple of different ways to go about this. I did it by creating a new script called scrPlayerHandleBoss() and added it to the Player's Step event with the other object handle scripts.
if(instance_exists(objBoss))
{
OffX = 9+(15*(Shield == consShieldInstashield)) ;
OffY = 19+(5*(Shield == consShieldInstashield)) ;
_ObjectHandle = collision_rectangle(x-OffX, y-OffY, x+OffX, y+OffY, objBoss, true, true);

if(_ObjectHandle != noone){
if _ObjectHandle.bossHp == 0
exit;​

// -----------------------------------------------------
// If the Player hits the boss:
// Handle Boss Values
// -----------------------------------------------------
if(Action == ActionRolling || Action == ActionJumping || Action == ActionSpindash || Action == ActionGlide || ShieldAction || Invincibility == 2 || SuperForm){
if _ObjectHandle.bossInv == false{
if _ObjectHandle.bossInv == false
audio_play_sound(sndBossHit, 1, false);​

if _ObjectHandle.bossHp > 1
{
_ObjectHandle.bossHp -= 1;
_ObjectHandle.alarm[0] = room_speed/2;
_ObjectHandle.sprite_index = _ObjectHandle.hurtSprite;​
}
else if _ObjectHandle.bossHp == 1
{
_ObjectHandle.sprite_index = _ObjectHandle.hurtSprite;
_ObjectHandle.bossDefeated = true;
_ObjectHandle.alarm[1] = room_speed/2;
_ObjectHandle.alarm[2] = room_speed*4;​
}
_ObjectHandle.bossInv = true;​
}​

// -----------------------------------------------------
// Bounce Off Boss
// -----------------------------------------------------
X = x-_ObjectHandle.x;
Y = y-_ObjectHandle.y;
Magnitude = sqrt(X*X+Y*Y);
X /= Magnitude;
Y /= Magnitude;
if(sign(X) == sign(Speed) && sign(Y) == sign(Gravity)){
exit;​
}
Speed = X*3;
Gravity = Y*3;
JumpVariable = false;
if(ShieldAction == true)
ShieldAction = false;​
if(Action != ActionJumping && Action != ActionRolling)
Action = ActionNormal;​

_ObjectHandle.Bounce += 2;
_ObjectHandle.Index = 3;​
}
else
{
// -----------------------------------------------------
// If the Player does not hit the boss:
// Take Damage
// -----------------------------------------------------
scrPlayerHurt(_ObjectHandle, sndPlayerDead);​
}​
}​
}

Then I made my bosses children objects of objBoss. All of my bosses are initialized with the same basic variables and alarms.
Variables:
bossHp = (Usually 8. Health Points)
bossInv = (False. Invincibility Frames)
bossDefeated = (False. Used to manage other level triggers, like the camera lock)
hurtSprite = (Sprite for when the boss takes damage)
Alarms:
alarm[0]:
Sets bossInv to false, ending invincibility frames, and resets sprite.​
alarm[1]:
Creates an explosion at (x-sprite_xoffset+random(sprite_width), y-sprite_yoffset+random(sprite_height)) and sets alarm[1] for the next explosion.​
alarm[2]:
Sets alarm[1] to -1, stopping the explosions, sets bossHp to 0, and sets bossDefeated to true. You can either destroy the boss object or change into a different object.​

I hope that makes sense. Let me know if I need to elaborate on anything.
 
  • Like
Reactions: Orrin

Orrin

Press Start Screen
Mar 19, 2019
5
0
7
27
I had already made my scrPlayerHandleBoss and forgot to add it to my player object (Though yours is probably more well made considering it not just some horrible amalgamation of the bumper handle and enemy handle :emoji_sweat_smile:). Thanks my dude, this should make things a LOT easier (I see you tend to post help fairly often, I saw the post from Otatron)
 

PM13

Shameless Recolor
Feb 25, 2018
80
79
128
Mine is totally just an amalgamation of the bumper and enemy handle. I just tried to tidy it up some. :emoji_sweat_smile:
Glad I could help!
(Not too often. I just try to help where I can.)