The problem is; for some reason while the "shell" form is rolling around, it's unaffected by Mario's spin jump. If you jump on it with a regular jump, it stops moving like it's supposed to. But if you do a spin jump on it, you simply pass through and take damage. Also, the spin jump defeats it just fine when you use it before stomping it into a "shell".
I've been looking at this code up and down, comparing it to the normal shell object and whatnot, and I just can't figure out what's wrong with this thing.
Here's the altered code I have for the thing:
CREATE:
CODE
image_speed = 0.15
gravity = 0.25
hitpoint = 0
bam = 0
rolling = 0
hurtmario = 0
gravity = 0.25
hitpoint = 0
bam = 0
rolling = 0
hurtmario = 0
END STEP:
CODE
if collision_rectangle(x-22,y+47,x+22,y+47,obj_solidtop,1,1)
{
gravity = 0
vspeed = 0
}
else
gravity = 0.25
while collision_rectangle(bbox_left,bbox_top,bbox_right,bbox_bottom,obj_slopeparent,1,1)
y-=1
if vspeed > 4
vspeed = 4
if hspeed > 0
and collision_rectangle(self.x+hspeed+22,self.y,self.x+hspeed+22,self.y+45,obj_solid,1,1)
{
if x>view_xview[0]-22
and x<view_xview[0]+342
and y<view_yview[0]+240
and y>view_yview[0]-44
sound_play(snd_bump)
instance_create(x,y,obj_blockbumper)
hspeed = -hspeed
image_xscale = -1
}
if hspeed < 0
and collision_rectangle(self.x+hspeed-22,self.y,self.x+hspeed-22,self.y+45,obj_solid,1,1)
{
if x>view_xview[0]-22
and x<view_xview[0]+342
and y<view_yview[0]+240
and y>view_yview[0]-44
sound_play(snd_bump)
instance_create(x,y,obj_blockbumper)
hspeed = -hspeed
image_xscale = 1
}
if visible = 0
and not instance_exists(obj_warpmario)
visible = 1
if bam = 0
and not collision_rectangle(bbox_left,bbox_top,bbox_right,bbox_bottom,obj_mario,1,1)
bam = 1
if rolling = 1
and hurtmario = 0
and not collision_rectangle(bbox_left,bbox_top,bbox_right,bbox_bottom,obj_mario,1,1)
hurtmario = 1
{
gravity = 0
vspeed = 0
}
else
gravity = 0.25
while collision_rectangle(bbox_left,bbox_top,bbox_right,bbox_bottom,obj_slopeparent,1,1)
y-=1
if vspeed > 4
vspeed = 4
if hspeed > 0
and collision_rectangle(self.x+hspeed+22,self.y,self.x+hspeed+22,self.y+45,obj_solid,1,1)
{
if x>view_xview[0]-22
and x<view_xview[0]+342
and y<view_yview[0]+240
and y>view_yview[0]-44
sound_play(snd_bump)
instance_create(x,y,obj_blockbumper)
hspeed = -hspeed
image_xscale = -1
}
if hspeed < 0
and collision_rectangle(self.x+hspeed-22,self.y,self.x+hspeed-22,self.y+45,obj_solid,1,1)
{
if x>view_xview[0]-22
and x<view_xview[0]+342
and y<view_yview[0]+240
and y>view_yview[0]-44
sound_play(snd_bump)
instance_create(x,y,obj_blockbumper)
hspeed = -hspeed
image_xscale = 1
}
if visible = 0
and not instance_exists(obj_warpmario)
visible = 1
if bam = 0
and not collision_rectangle(bbox_left,bbox_top,bbox_right,bbox_bottom,obj_mario,1,1)
bam = 1
if rolling = 1
and hurtmario = 0
and not collision_rectangle(bbox_left,bbox_top,bbox_right,bbox_bottom,obj_mario,1,1)
hurtmario = 1
COLLISION <> OBJ_MARIO
CODE
if hurtmario = 0
and rolling = 0
{
if obj_mario.direct = 1
{
image_xscale = 1
hspeed = 2.5
rolling = 1
}
if obj_mario.direct = -1
{
image_xscale = -1
hspeed = -2.5
rolling = 1
}
sound_play(snd_kick)
sprite_index = spr_hamster_roll
image_speed = 0.1
}
//Sonic/Tails jumping and rolling attacks
if (global.playerclass = 3 || global.playerclass = 4)
{
if (obj_mario.spinattack >= 1)
and not (other.y < y-24)
{
imdead = instance_create(x,y+16,obj_enemy_dead)
imdead.sprite_index = sprite_index
imdead.image_speed = 0
imdead.image_xscale = image_xscale
sound_play(snd_sonic_stomp)
instance_create(x,y,obj_100pts)
instance_destroy()
exit
}
}
if other.y < y-24
{
hspeed = 0
if (obj_mario.stompgrade >= 2)
{
hurtmario = 0
imdead = instance_create(x,y+48,obj_enemy_dead)
imdead.sprite_index = sprite_index
imdead.image_xscale = image_xscale
scr_givepoints_stomp2()
instance_destroy()
}
}
if hurtmario = 1
{
if instance_exists(obj_invincibility)
exit
if other.y < y-24
{
hspeed = 0
if not(obj_mario.stompgrade >= 2)
{
ID = instance_create(x,y,hamster_stunned)
}
scr_givepoints_stomp()
if keyboard_check(vk_shift)
other.vspeed = -8
else
other.vspeed = -4
other.jumpnow = 2
instance_destroy()
}
//Begin Hurt Code
else if other.invincible = 0
{
scr_hurtmario()
}
//End Hurt Code
}
and rolling = 0
{
if obj_mario.direct = 1
{
image_xscale = 1
hspeed = 2.5
rolling = 1
}
if obj_mario.direct = -1
{
image_xscale = -1
hspeed = -2.5
rolling = 1
}
sound_play(snd_kick)
sprite_index = spr_hamster_roll
image_speed = 0.1
}
//Sonic/Tails jumping and rolling attacks
if (global.playerclass = 3 || global.playerclass = 4)
{
if (obj_mario.spinattack >= 1)
and not (other.y < y-24)
{
imdead = instance_create(x,y+16,obj_enemy_dead)
imdead.sprite_index = sprite_index
imdead.image_speed = 0
imdead.image_xscale = image_xscale
sound_play(snd_sonic_stomp)
instance_create(x,y,obj_100pts)
instance_destroy()
exit
}
}
if other.y < y-24
{
hspeed = 0
if (obj_mario.stompgrade >= 2)
{
hurtmario = 0
imdead = instance_create(x,y+48,obj_enemy_dead)
imdead.sprite_index = sprite_index
imdead.image_xscale = image_xscale
scr_givepoints_stomp2()
instance_destroy()
}
}
if hurtmario = 1
{
if instance_exists(obj_invincibility)
exit
if other.y < y-24
{
hspeed = 0
if not(obj_mario.stompgrade >= 2)
{
ID = instance_create(x,y,hamster_stunned)
}
scr_givepoints_stomp()
if keyboard_check(vk_shift)
other.vspeed = -8
else
other.vspeed = -4
other.jumpnow = 2
instance_destroy()
}
//Begin Hurt Code
else if other.invincible = 0
{
scr_hurtmario()
}
//End Hurt Code
}
sprite size: 48x48
origin: x=24,y=0
These three events are the only ones that should really matter at all; I left out all those collision events designed to kill the thing in various ways.
I added in some extra code to switch the "shell" form between different sprites depending on if it's idle or rolling, and I also took the Sonic spin attack and spin jump out of the "if hurtmario=1" condition, because it made no sense that the "shell" couldn't be defeated while it was sitting around idle. Note that it was still having this problem before I took the spin jump code out of that condition.
Is there anyone good at coding who could take a look at all this and let me know how to fix the problem?