Windows oEgun error...

Z

ZuboeD

Guest
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object oEgun:

Variable oEgun.countdownrate(100064, -2147483648) not set before reading it.
at gml_Object_oEgun_Create_0 (line 6) - countdown = countdownrate;
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_oEgun_Create_0 (line 6)
called from - gml_Object_oEnemy_Create_0 (line 7) - mygun = instance_create_layer(x,y,"Gun",oEgun)

Create
countdown = 40;
countdown = countdownrate;


Begin Step
x = owner.x;
y = owner.y+10;

image_xscale = abs (owner.image_xscale);
image_yscale = abs (owner.image_yscale);

if (instance_exists(oPlayer))
{
if(oPlayer.x < x) image_yscale = -image_yscale;
if (point_distance(oPlayer.x,oPlayer.y,x,y) < 600)
{
image_angle = point_direction(x,y,oPlayer.x,oPlayer.y);
countdown--;
if (countdown <=0)
{
countdown = countdownrate;
with (instance_create_layer(x,y,"Bullets",oEbullet))
{
spd = 10;
direction = other.image_angle + random_range(-3,3);
image_angle = direction;
}
}
}
}


sEnemy
Create
if (hasweapon)
{
mygun = instance_create_layer(x,y,"Gun",oEgun)
with (mygun)
{
owner = other.id
}

}
else mygun = noone;


step

vsp = vsp + grv;

// Не уходи с краев

if (grounded) && (afraidofheights) && (!place_meeting(x+hsp,y+1, oWall))
{
hsp = -hsp;
}

//Горизонтальное столкновение
if (place_meeting(x+hsp,y,oWall))
{
while( !place_meeting(x+sign(hsp),y,oWall))
{
x = x + sign(hsp);
}
hsp = -hsp;
}
x = x + hsp;

//Вертикальное столкновение
if (place_meeting(x,y+vsp,oWall))
{
while (!place_meeting(x,y+sign(vsp),oWall))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;

//Анимация
if (!place_meeting(x,y+1,oWall))
{
grounded = false;
sprite_index = sEnemyA;
image_speed = 0;
if (sign(vsp) > 0) image_index = 1; else image_index = 0;

}
else
{
grounded = true;
image_speed = 1;
if (hsp == 0)
{
sprite_index = sEnemy;
}
else
{
sprite_index = sEnemyR;
}
}

if (hsp !=0) image_xscale=sign(hsp)* size;
image_yscale = size;


Begin Step

if (hp <= 0)
{
with (instance_create_layer(x,y,layer,oDead))
{
direction = other.hitfrom;
hsp = lengthdir_x(3, direction);
vsp = lengthdir_y(3, direction)-2;
if (sign(hsp) != 0) image_xscale = sign(hsp) * other.size;
image_yscale = other.size;
}

with (mygun) instance_destroy();
instance_destroy();
}

oGun
Begin Step
x = oPlayer.x;
y = oPlayer.y+10;

if (oPlayer.controller == 0)
{
image_angle = point_direction(x,y,mouse_x,mouse_y);
}
else
{
var controllerh = gamepad_axis_value(0, gp_axisrh);
var controllerv = gamepad_axis_value(0, gp_axisrv);
if (abs(controllerh) > 0.2) || (abs(controllerv) > 0.2)
{
controllerangle = point_direction(0,0,controllerh,controllerv)
}
image_angle = controllerangle;
}
firingdelay = firingdelay - 1;
recoil = max (0,recoil - 1) ;

if ((mouse_check_button(mb_left)) || gamepad_button_check(0,gp_shoulderrb)) && (firingdelay < 0)
{
recoil = 4;
firingdelay = 5;
Screenshake(2,10)
with (instance_create_layer(x,y,"Bullets",oBullet))
{
spd = 25;
direction = other.image_angle + random_range(-3,3);
image_angle = direction;
}
}

x = x - lengthdir_x(recoil, image_angle);
y = y - lengthdir_y(recoil, image_angle);

if (image_angle > 90) && (image_angle < 270)
{
image_yscale = -1;
}
else
{
image_yscale = 1;
}

Create
firingdelay = 0;
recoil = 0;
controllerangle = 0;

OEbullet
step
x += lengthdir_x(spd,direction);
y += lengthdir_y(spd,direction);

if (place_meeting(x,y,oWall)) && (image_index !=0)
{
while (place_meeting(x,y,oWall))
{
x -= lengthdir_x(1,direction);
y -= lengthdir_y(1,direction);
}
spd = 0;
instance_change(oHitSpark,true);
}

Animation End

image_speed = 0;
image_index = 1;


Help? I am Russian, I understand a little English.
 
Last edited by a moderator:
Z

ZuboeD

Guest
The answer is so obvious that it hurts. Just take a look back at your code:

Create
countdown = 40;
countdown = countdownrate;

___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Step Event0
for object oEbullet:

Variable oEbullet.spd(100020, -2147483648) not set before reading it.
at gml_Object_oEbullet_Step_0 (line 5) - x += lengthdir_x(spd,direction);
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_oEbullet_Step_0 (line 5)
 
Z

ZuboeD

Guest
Are you just copying tutorials without understanding them? It's the same issue.
OEbullet
step
x += lengthdir_x(spd,direction);
y += lengthdir_y(spd,direction);

if (place_meeting(x,y,oWall)) && (image_index !=0)
{
while (place_meeting(x,y,oWall))
{
x -= lengthdir_x(1,direction);
y -= lengthdir_y(1,direction);
}
spd = 0;
instance_change(oHitSpark,true);
}

Animation End

image_speed = 0;
image_index = 1;

what is the problem?
 
Top