SOLVED Cape

Hey

I'm not sure I can explain this but I'm going to try.
1. When a stage starts,. curtains open up to reveal the level.
Well that works.

2. When I create a lightning bat character the left curtains
(not the right) open.

I did a search for LeftCape and a search for Right Cape and the only result:

Searching for 'LeftCape'...
Tutorial-Create at line 42: if (!object_exists(LeftCapeObject) && object_exists(RightCapeObject))
Search Complete (1 results)
 

TsukaYuriko

🌠
Forum Staff
Moderator
object_exists refers to a resource in the resource tree.
Did you mean to use instance_exists?

That aside, to get this straight... when you create a lightning bat, what is supposed to happen? The right curtain opens? No curtain opens?

Please post the code in its Create event and the Create event of its parent as well.
 
When you create lightning bat, it is supposed to play a lightning bolt strike and lands on the ground. There should be no i repeat *no* reason for the curtains to appear except at the beginning of the level.

//global.flight = true;
global.flight_stop = false;
global.flight_walk = true;


weighting=0;
update_speed=30;
for (i=0;i<2;i+=1)
{
path=path_add();
path_set_kind(path,1);
path_set_closed(path,0);
}
alarm[0]=2;



global.lit_bat = true;
hp_minus = 0;

x_coord = 0;
y_coord = 0;

sound_timer = room_speed;
flight = false;
counter = 0;
hp = 15000;
hp_max = 15000
alarm[6] = room_speed;
alarm_5_flag = false;
lit_myTimer = 0;

global.lightning_1_x = 0;
global.lightning_1_y = 0;
global.lightning_2_x = 0;
global.lightning_2_y = 0;
global.lightning_3_x = 0;
global.lightning_3_y = 0;
global.litorigin_x = 0;
global.litorigin_y = 0;

global.lit_strike_1 = false;
global.lit_strike_2 = false;
global.lit_strike_3 = false;

myTimer = 0;

global.mx1 = 0;
global.mx2 = 0;
global.my1 = 0;
global.my2 = 0;

global.nx1 = 0;
global.ny1 = 0;
global.nx2 = 0;
global.ny2 = 0;

global.target_x = 0
global.target_y = 0


target_x = 0;
target_y = 0;
///////////////////
little_guy_flag = true;
/////////////

array = 0;
object3 = 0;
flash = true;

////////////////
lit_zap_sound = room_speed;
spots = false;

//////////////////
object_set_solid( SentryBatObject, true );
target_placement_x = 0;
target_placement_y = 0;
//is the bat currently in flight (is movetopoint true)
flight = false;
sprite_index = SentryBatStill;
new_bat = false;
snap = false;
flight = false;
alarm[0] = room_speed * 10;

hp = 15000;
damage = 0;
hp = 15000;
killed_a_brain = false;

opponent = noone;

under_attack = false;

global.current_collision_lightning = noone;

active = false;
colliding_flag = false;

play_myTimer = room_speed;
played = false;
big_play_myTimer = room_speed;

playe_myTimer = room_speed;

lit_movement_flag = room_speed;

lit_sound_myTimer = room_speed;

attackRange = 50;
flyspeed = 10;

attackTarget = noone;
battle_myTimer = room_speed;
floater_myTimer = room_speed;



/////////////STRENGTH//////////////


global.bat_strength = 15;
strength = 55;
/////////////////DEFENSE//////////////
defense = 35;

//////////////////ATTACK/////////////////

attack = 13;

//////////////////////DEXTERITY/////////////
//ability to use a projectile

dexterity = 10;

/////////////////SPEED ///////////

//unaccelerated spaed

spd = 15;

///////////////INTELLIGENCE////////////////
//strength of projectiles

intelligence = 20;
global.intelligence = intelligence;

///////////EXPERIEINCE///////////////

//rolling over experience every time kill something with this bat type

experience = 10;

///////////////LEVEL///////////////////////////

//experience adds up to a new level for that bat
//this increases stats for that bat type

experience_level = 1;


little_lit_flag = true;


with(FrankensteinIdleObject)
{
sprite_index = FrankensteinMonsterSendOutBrains;
}
 
Spoiler
if (hp <= 0)
{
global.dropped_bat = false
}
global.bat_strength = strength;
/////////////////DEFENSE//////////////
global.bat_defense = defense;
global.current_collision_snow = false;
//////////////////ATTACK/////////////////

global.bat_attack = attack;

//////////////////////DEXTERITY/////////////
//ability to use a projectile

global.bat_dexterity = dexterity;

/////////////////SPEED ///////////

//unaccelerated spaed

global.bat_spd = spd;

///////////////INTELLIGENCE////////////////
//strength of projectiles

global.bat_intelligence = intelligence;

///////////EXPERIEINCE///////////////

//rolling over experience every time kill something with this bat type

global.bat_experience = experience;

///////////////LEVEL///////////////////////////

//experience adds up to a new level for that bat
//this increases stats for that bat type

global.bat_experience_level = experience_level;




global.party_still = LightningBatStill;
global.party_walk = LightningBatWalk;
global.party_kill = LightningBatAttack



if (killed_a_brain == true)
{

sprite_index = LightningBatStill;
killed_a_brain = false;

}


event_inherited();




if (!instance_exists(global.current_collision_lightning))
{
if (flight)
{
sprite_index = LightningBatWalk;
}
else
{
sprite_index = LightningBatStill;
}
}



global.mx1 = 0;
global.my1 = 0;
global.mx2 = 0;
global.my2 = 0;


/*




/// @description draw_lightning_color(path,segment length,width,color1,color2,alpha,fork path,attractive object, enable particles,weighting)
/// @param path
/// @param segment length
/// @param width
/// @param color1
/// @param color2
/// @param alpha
/// @param fork path
/// @param attractive object
/// @param enable particles
/// @param weighting


draw_lightning_hue(path[0],32,32,0,255,.2+.8*(1-abs(weighting)),path[1],p_metal,fx.particles,weighting);
,p_metal,fx.particles,weighting);

*/

if (mouse_check_button_pressed(mb_right))
{
inst = instance_position(mouse_x, mouse_y, BrainParentObject)
inst2 = instance_position(mouse_x,mouse_y, BOSSESParent)
inst3 = instance_position(mouse_x, mouse_y, SpecialBrains)
inst4 = instance_position(mouse_x, mouse_y, FranksParent)
/*
if (SpecialBrains != noone)
{
with (SpecialBrains)
{
if (hp <= 1000)
{
hp_minus = irandom_range(200, 300)
hp -= hp_minus
floater = instance_create_depth(x+10, y-10, -1700, DamageIndicatorObject);
floater.text = string(hp_minus);
if (hp <= 0)
{
instance_create_depth(x, y, -1100,DeadBrainObject);
instance_create_depth(x-150, y-20, -1100, FadingGemObject);
audio_play_sound(DieingBrainSound, 20, false);
instance_destroy()
}
}
}



}*/


if (inst != noone || inst2 != noone || inst3 != noone || inst4 != noone)
{

/*
for (i=0;i<30;i++)
{
show_debug_message("Getting ready to draw lightning")
//draw_set_color(c_white)
//draw_lightning_simple(x,y,mouse_x,mouse_y,32,60)//render lightning with a single line of code!
draw_lightning_color(path[0], 20, 300, c_blue, c_orange, 1.0, path[1], p_metal, fx.particles, weighting);
}*/

global.tgt_x = mouse_x;
global.tgt_y = mouse_y;


for (i=0;i<room_speed/7;i++)
{
instance_create_depth(global.tgt_x, global.tgt_y,-1200,o_lightning_hue)
}


}
}
/*
if (mouse_check_button_pressed(mb_right))
{
show_debug_message("Getting ready to draw lightning")
//draw_set_color(c_white)
//draw_lightning_simple(x,y,mouse_x,mouse_y,32,60)//render lightning with a single line of code!
draw_lightning_hue(path[0],32,32,0,255,.2+.8*(1-abs(weighting)),path[1],p_metal,fx.particles,weighting);
}
*/


Create Super Class.







/*


with(global.current_bat)
{
var obj_index=global.current_bat.object_index;
var obj_name=object_get_name(obj_index); // obj_name="obj_test"
if (obj_name == "LightningBatObject")
{
if (mouse_check_button_pressed(mb_right) && counter == 0)
{
counter++;
global.lightning_1_x = mouse_x;
global.lightning_1_y = mouse_y;
spots = true;

global.lightning_2_x = 0;
global.lightning_2_y = 0;
global.lightning_3_x = 0;
global.lightning_3_y = 0;
}



else if (mouse_check_button_pressed(mb_right) && counter == 1)
{

counter++;
global.lightning_2_x = mouse_x;
global.lightning_2_y = mouse_y;

}
else if (mouse_check_button_pressed(mb_right) && counter == 2)
{

counter++;
global.lightning_3_x = mouse_x;
global.lightning_3_y = mouse_y;
NightObject.visible = true;
global.active = true;
flash = true;
lit_myTimer =0;
alarm_5_flag = false;

}
}
}
//}

if (hp <= 0)
{
instance_destroy();
}




//activate chain lightning
//can choose three enemies


//start by just choosing three points

end_x = x
end_y = y
new_y = y
new_x = x

global.litorigin_x = x;
global.litorigin_y = y;

if global.active
{array = 0;

if (counter == 3)
{
if (lit_myTimer == 0)
{
sprite_index = LightningBatAttack;
new_x = x;
new_y = y;
end_x = global.lightning_1_x;
end_y = global.lightning_1_x;
global.active = true
}
if (lit_myTimer == 1)
{
sprite_index = LightningBlackBack;
new_x = global.lightning_1_x;
new_y = global.lightning_1_y;
end_x = global.lightning_2_x;
end_y = global.lightning_2_y;
}
if (lit_myTimer == 2)
{
sprite_index = LightningBatAttack
new_x = global.lightning_2_x;
new_y = global.lightning_2_y;
end_x = global.lightning_3_x;
end_y = global.lightning_3_y;


}
if (lit_myTimer == 3)
{
counter = 0;
lit_myTimer = 0;
flash = false;
global.active = false;
spots = false;
NightObject.visible = false;
sprite_index = LightningBatStill;
}
}
//end_x = lightning_3_x; //<<< this is my end point - change this to whatever you want
//end_y = lightning_3_y;
//new_x = end_x;
//new_y = end_y;
line_number = 10; //<<<<<<<<number of segments in the line
line_amount = point_distance(x ,y, end_x, end_y) / line_number; // <<<<<<<distance to end point divided by number of segments
for (a = line_number; a > 0; a-=1)
{line_dir = point_direction(new_x, new_y, x ,y);
if a div 2 == (a div 1) / 2
{amount = irandom_range(-25, -55)}
else
{amount = irandom_range(25, 55);}
new_x = new_x + lengthdir_x(line_amount, line_dir + amount);
new_y = new_y + lengthdir_y(line_amount, line_dir + amount);
array[a,0] = new_x;
array[a,1] = new_y;}

//active = false;
}




/*
if (counter == 3)
{

draw_line_width(x,y,lightning_1_x,lightning_1_y,10);
draw_line_width(lightning_1_x,lightning_1_y, lightning_2_x, lightning_2_y,10);
draw_line_width(lightning_2_x,lightning_2_y, lightning_3_x, lightning_3_y,10);

lightning_1_x = 0;
lightning_1_y = 0;
lightning_2_x = 0;
lightning_2_y = 0;
lightning_3_x = 0;
lightning_3_y = 0;
counter = 0;
}

mouse_clear(mb_any);
*/

if (little_lit_flag)
{
instance_create_depth(65, 1245, -1100, MiniLightningObject);
little_lit_flag = false;

}

And this is the the super class from Lightning Bat Object.
class:




global.party_still = noone;
global.party_walk = noone;
global.party_kill = noone;
global.party_bat_sound = noone;
global.party_brain_sound = noone;

short_sound_effect_timer_a = 0;
short_sound_effect_timer_b = 0;

attackTarget = noone;
attackRange = 50;
ForestSpecialtyBrain.attackTarget = noone;
x = 0
y = 0
x_coord = 0;
y_coord = 0;
/////////STATS////////////

total_strength = 0
total_defense = 0
total_formula = 0
damage = 0

colliderbat = noone;
colliderbrain = noone;

global.brain_strength = noone;
global.brain_defense = noone;
global.bat_strength = noone;
global.bat_defense = noone;



//////////////////////////STATS/////////////////
//FOR INPUT TO THE ALGOIRTHM

/////////////STRENGTH//////////////

global.bat_strength = 25;
/////////////////DEFENSE//////////////
global.bat_defense = 35;

//////////////////ATTACK/////////////////

global.bat_attack = 15;

//////////////////////DEXTERITY/////////////
//ability to use a projectile

global.bat_dexterity = 10;

/////////////////SPEED ///////////

//unaccelerated spaed

global.bat_spd = 20;

///////////////INTELLIGENCE////////////////
//strength of projectiles

global.bat_intelligence = 10;

///////////EXPERIEINCE///////////////

//rolling over experience every time kill something with this bat type

global.bat_experience = 10;

///////////////LEVEL///////////////////////////

//experience adds up to a new level for that bat
//this increases stats for that bat type

global.bat_experience_level = 1;


spit_inst = noone;

played_wind_sound = false;
 

TsukaYuriko

🌠
Forum Staff
Moderator
There are a couple of instance_creates in there. Are these all creating instances of objects they are supposed to create? For example, o_lightning_hue breaks the naming scheme of your other objects (SomethingSomethingObject), so I'm unsure whether that's actually an object.

That aside, if the cause is not within this code, the only chance you have of tracking this down is either stepping through your code with the debugger, or using debug messages.

For the debugger route, set a breakpoint when you create a bat, then step through your code until you arrive at an instance_create which then switches to a curtain's Create event. That line is the one causing it to appear.

For the debug message route, look for other instance_creates which either 1) create the curtains or 2) create instances of something determined by a variable and spawning an alert if they are about to create a curtain. Like this:
Code:
if (obj == RightCapeObject || obj == LeftCapeObj)
{
    show_debug_message("Script/Event <NAME OF SCRIPT OR OBJECT AND EVENT> at line <LINE NUMBER> is spawning a curtain");
}
instance_create...(..., obj);
This will tell you exactly which line in which script or event is spawning them.
 
What do you mean there are couple of instance_creates in here?
~
o_lightining_hue breaks the naming scheme is because part of the lightning uses lightning from another script..
~
There are a couple of instance_creates in there. Are these all creating instances of objects they are supposed to create? For example, o_lightning_hue breaks the naming scheme of your other objects (SomethingSomethingObject), so I'm unsure whether that's actually an object.

That aside, if the cause is not within this code, the only chance you have of tracking this down is either stepping through your code with the debugger, or using debug messages.

For the debugger route, set a breakpoint when you create a bat, then step through your code until you arrive at an instance_create which then switches to a curtain's Create event. That line is the one causing it to appear.

For the debug message route, look for other instance_creates which either 1) create the curtains or 2) create instances of something determined by a variable and spawning an alert if they are about to create a curtain. Like this:
Code:
if (obj == RightCapeObject || obj == LeftCapeObj)
{
    show_debug_message("Script/Event <NAME OF SCRIPT OR OBJECT AND EVENT> at line <LINE NUMBER> is spawning a curtain");
}
instance_create...(..., obj);
This will tell you exactly which line in which script or event is spawning them.
I'm not sure what the obj is for???
 
@TsukaYuriko

Not feeling well lately. Can you explain this stack trace to me?

GML:
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object LightningBatObject:

Variable LightningBatObject.obj(100991, -2147483648) not set before reading it.
 at gml_Object_LightningBatObject_Create_0 (line 173) - if (obj == RightCapeObject || obj == LeftCapeObject)
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_LightningBatObject_Create_0 (line 173)
called from - gml_Object_DropBatObject_Step_0 (line 56) -                             global.current_bat = instance_create_depth(390, 1050, -1500, LightningBatObject);
 
In the create event of LightningBatObject you have the following line:
Code:
if (obj == RightCapeObject || obj == LeftCapeObject)
But you have not set a value into the obj variable before you do this if check.
 
@BaBiA Game Studio
In the create event of LightningBatObject you have the following line:
Code:
if (obj == RightCapeObject || obj == LeftCapeObject)
But you have not set a value into the obj variable before you do this if check.
What does obj represent. I'm confused.

And @TsukaYuriko for the instance_create_depth, is this line the one you are referring to:

GML:
    for (i=0;i<room_speed/7;i++)
        {
            instance_create_depth(global.tgt_x, global.tgt_y,-1200,o_lightning_hue)
        }
 
I know all of these things, it is my code.

GML:
  for (i=0;i<room_speed/7;i++)
        {
            instance_create_depth(global.tgt_x, global.tgt_y,-1200,o_lightning_hue)
        }
the o_lightning_hue is a single bolt of lightning . The for loop is there to send out multiple bolts.
i don't *get* how this the following is relevant:

Code:
if (obj == RightCapeObject || obj == LeftCapeObj)
{
    show_debug_message("Script/Event <NAME OF SCRIPT OR OBJECT AND EVENT> at line <LINE NUMBER> is spawning a curtain");
}
I'm going afk for a while. I'm sick and I may have to have another hospital stay. Sorry if I was confusing to everyone.


-TW
 

Nidoking

Member
i don't *get* how this the following is relevant:
It was relevant to show you what you were supposed to put in as debug code. You weren't supposed to copy it as-is and just paste it anywhere. You were supposed to replace parts of it with names that are relevant to your own program.
 
Top