Master Cabalist
Member
First off I promise not to post again until these issues are resolved.
This is the code for my collision between my bats and my brains. What I want it to do is the following. The player controlling the bats double clicks on a brain when it is next to it. The brain begins its attack animation and so does the bat. The player keeps clicking on the brain, which causes a "thumping" sound and causes damage indicators to float upward from the brain. There is a damage meter below the bat and as the player takes damage, the meter empties. If the player wants to, he/she can click away from the brain and run to escape (that's in another posting). So the brain (hopefully) gets killed by the bat and then the bat is free to fly around until it runs into another brain.
This is what is happening. The player double clicks on the brain. After a couple clicks the brain starts taking damage and the bat starts its flying animation. Then every click that "hits or does damage" changes the brain object's sprite to the attack sprite for the bat for some reason. As the player clicks on the brain, every hit makes a thumping sound and the damage indicator works as it should. The same for the damage meter. If was player wants to click away from the brain to get away, sometimes it will back up (assuming you are escaping to the rear) and the brain will follow, sometimes it won't do anything. So then the brain gets killed by the bat and then the bat is free to fly around until it runs into another brain.
Phew
Ok. To start, here is the code for collision:
I hope this makes sense. colliderbat is the bat you control in the game in this collision. You can have control of multiple different kinds of bats. colliderbrain is is the brain the AI controls in this collision.
Screenshot 1 - sentry bat graphic responding the attacking brain when the sentry bat is attacking the brain
Screenshot 2 - the way the brain should look
Sorry about the long post but I wanted to be thorough
This is the code for my collision between my bats and my brains. What I want it to do is the following. The player controlling the bats double clicks on a brain when it is next to it. The brain begins its attack animation and so does the bat. The player keeps clicking on the brain, which causes a "thumping" sound and causes damage indicators to float upward from the brain. There is a damage meter below the bat and as the player takes damage, the meter empties. If the player wants to, he/she can click away from the brain and run to escape (that's in another posting). So the brain (hopefully) gets killed by the bat and then the bat is free to fly around until it runs into another brain.
This is what is happening. The player double clicks on the brain. After a couple clicks the brain starts taking damage and the bat starts its flying animation. Then every click that "hits or does damage" changes the brain object's sprite to the attack sprite for the bat for some reason. As the player clicks on the brain, every hit makes a thumping sound and the damage indicator works as it should. The same for the damage meter. If was player wants to click away from the brain to get away, sometimes it will back up (assuming you are escaping to the rear) and the brain will follow, sometimes it won't do anything. So then the brain gets killed by the bat and then the bat is free to fly around until it runs into another brain.
Phew
Ok. To start, here is the code for collision:
Code:
var play_timer = 0;
var played = true;
var colliderbrain;
var colliderbat;
global.timer_big_brain--;
if (global.timer_big_brain <= 0)
{
global.timer_big_brain = room_speed/8;
if (mouse_check_button_released(mb_left))
{
show_debug_message("LMB pressed");
colliderbrain = instance_position(mouse_x, mouse_y, SimpleBrain);
if (instance_exists(colliderbrain))
{
show_debug_message("Collider brain exists");
}
if (colliderbrain != noone)
{
show_debug_message("Collider Brain initializating collider bat");
with (colliderbrain)
{
show_debug_message("With Colliderbrain");
colliderbat = instance_position(mouse_x, mouse_y, other)
}
}
/////////////////////////COLLIDERBRAIN AND COLLIDER BAT//////////////////////
if (colliderbrain == noone || colliderbat == noone)
{
return;
}
//////////////////////////////////////////////
show_debug_message(object_get_name(colliderbrain) + "shoujld be a brain");
show_debug_message(object_get_name(colliderbat) + "should be a bat");
///////////////////////////////////////
//colliderbat = other;//instance_place(mouse_x, mouse_y, SentryBatObject)
if (colliderbrain != noone)
{
show_debug_message("Collider brain is not noone");
with (colliderbrain)
{
// if (point_distance(argument0, argument1, x, y) < 40)
if (point_distance(argument0, argument1, x, y) < 100)
{
///colliderbrain is Brain
show_debug_message("With colliderbrain");
sprite_index = SimpleBrainAttack;
hp_minus = irandom_range(10, 30)
hp = hp - hp_minus;
speed =0;
under_attack = true;
took_a_hit = true;
//sprite_index = SentryBatAttack
//image_speed = 1;
audio_play_sound(BatThumpSound,20,false);
show_debug_message("Showing Damage Indicator");
floater = instance_create_depth(x+10, y-10, -17000, DamageIndicatorObject);
floater.text = string(hp_minus);
//killl the brain
if (hp <= 0)
{
show_debug_message("Kill the brain");
global.achievement_gold_counter++;
global.achievement_tome_experience += 20;
show_debug_message("Dead Brain Ghost and Fading Gem");
audio_play_sound(DieingBrainSound, 20, false);
instance_create_depth(x, y, -1100,DeadBrainObject);
instance_create_depth(x-150, y-20, -1100, FadingGemObject);
instance_destroy();
}
}
}
}
if (colliderbat != noone)
{
with (colliderbat)
{
show_debug_message("Colliderbat is not noone");
//damage to batq
if (!global.group_invincibility)
{
hp = hp - 1;
damage = 1;
damage_dealt_to_bat = damage;
}
sprite_index = SentryBatAttack;
image_speed = 0;
show_debug_message("SentryBatAttack");
//alarm[5] = room_speed;
under_attack = true;
took_a_hit = true;
//sprite_index = SimpleBrainAttack;
//audio_stop_sound(BatWingsMovementSound);
/* kill the bat */
if (hp <= 0)
{
audio_play_sound(BatDeathSound, 20, false);
instance_create_depth(x, y, -1100,DeadBatObject);
global.num_sentry_killed++;
instance_destroy();
}
}
}
Screenshot 1 - sentry bat graphic responding the attacking brain when the sentry bat is attacking the brain
Screenshot 2 - the way the brain should look
Sorry about the long post but I wanted to be thorough
Attachments
-
371.6 KB Views: 20
-
370.9 KB Views: 17