Master Cabalist
Member
Hey
I have these characters (Brains) underneath an unbrella (SpecfialtyBrain) . Since I've switched over to this inheritance format I'm having all kinds of trouble.
Most of them I think its where the event_inherited(); are placed. But some are not.
PARENT CREATE
PARENT STEP
STORMSPECIALBRAIN CREATE
STORMSPECIALBRAIN STEP CODE
I have these characters (Brains) underneath an unbrella (SpecfialtyBrain) . Since I've switched over to this inheritance format I'm having all kinds of trouble.
Most of them I think its where the event_inherited(); are placed. But some are not.
PARENT CREATE
Code:
x = 0
y = 0
global.current_brain_specialty_target = 0
global.brain_party_still = noone;
global.brain_party_walk = noone;
global.brain_party_kill = noone;
decision_timer = room_speed;
///Random path change for brains
path_change = room_speed*3;
attackTarget = noone;
floater_myTimer = room_speed;
//////////////////////////STATS/////////////////
///FOR INPUT INTO THE ALGORITHM////////
/////////////STRENGTH//////////////
global.brain_strength = 25;
/////////////////DEFENSE//////////////
global.brain_defense = 35;
//////////////////ATTACK/////////////////
global.brain_attack = 15;
//////////////////////DEXTERITY/////////////
//ability to use a projectile
global.brain_dexterity = 10;
/////////////////SPEED ///////////
//unaccelerated spaed
spd = 20;
//
global.brain_spd = 20;
/////////////INTELLIGENCE////////////////
//strength of projectiles
global.brain_intelligence = 10;
///////////EXPERIEINCE///////////////
//rolling over experience every time kill something with this bat type
global.brain_experience = 10;
///////////////LEVEL///////////////////////////
//experience adds up to a new level for that bat
//this increases stats for that bat type
global.brain_experience_level = 1;
////////////////////////////////GLOBAL RECEIVE HP DAMAGE//////////////////////////////
colliderbat = noone;
colliderbrain = noone;
intelligence = 10;
PARENT STEP
Code:
[4] = room_speed/4;
//hp is incoming damage
hp -= global.current_brain_specialty_target
global.current_brain_specialty_target = 0
///////////////PAIRING///////////////////
//////////////////////////////////////////
attackRange = 50;
flyspeed = 5;
floater_myTimer--;
//if attackTarget is empty
if (!instance_exists(attackTarget))
{
//player presses mouse left
if (mouse_check_button_released(mb_left))
{
//get a bat (was get a bat, now its brain parent
attackTarget = instance_place(mouse_x, mouse_y, BatParentObject);
//show_debug_message("Brain is attacking is : " + string(BatParentObject));
}
}
//make sure thqt attackatarget has a reference
if instance_exists(attackTarget)
{
//When decision_timer is set, count down the timer and clear the attackTarget and attacking
if decision_timer > 0
{
decision_timer--;
if (decision_timer == 0)
{
//brain is no longer attacking
attackTarget = noone;
attacking = false;
}
}
else if distance_to_object(attackTarget) > attackRange //DECISION TIMER IS 0 AND BRAIN IS NO LONGER ATTCKING
{// BRAIN DISTANCE FROM BAT IS > attackRange
//Far from brain, move towards it
//{
if attacking == false //set attacking to false and
//move towrds bat
move_towards_point(attackTarget.x,attackTarget.y, flyspeed);
//}
//Note: You could have the decision_timer code under an else-conditional here,
//which would allow ranged brains to keep attacking until the bat leaves its range
}
else //BRAIN DISTANCE TIMER IS 0 AND BRAIN IS CLOSE TO BAT
//LOCKING IN
//assign attack target
//or move towards target
//or lock in battle
{
//LOCK IN BATTLE
attacking = true;
speed=0;
other.speed = 0
other.path_speed = 0
//locked in
//if global.colliderbat_temp exists
//attackTarget is assigned to global.colliderbbat_temp
if (instance_exists(global.colliderbat_temp))
{
attackTarget = global.colliderbat_temp;
show_debug_message("Brain locked onto attackTarget");
}
}
} //end instancfe exits attacktarget
else
{
attacking = false;
//attackTarget = noone;
decision_timer = 0;
}
//////////////////////////////////////////
///////////Deal Damage
if distance_to_object(attackTarget) < attackRange
{
//deal out damage to enemy brain
//total damage to brain
total_strength = global.bat_strength - global.brain_strength;
total_defense = global.bat_defense - global.brain_defense;
total_formula = (global.bat_strength - global.brain_defense)*global.bat_attack
damage = total_formula*irandom_range(50, 75)/1000
show_debug_message("Damage deal to bat" + string(damage))
//clamping
if (damage < 0)
{
damage = damage * -1;
}
///calculate later
global.current_bat_attack_target_damage = damage;
/////////////STATUS EFFECTS///////////////
}
if (x < 200) //Enemy Hit the Castle
{
instance_destroy();
}
//mindbreaker
if (global.mindbreak || global.mindbreaker)
{
path_start(path30, 15, path_action_reverse, 0);
}
//was hit by a snowball
if (frozen)
{
path_speed =0;
speed = 0;
sprite_index =SnowFrozenEnemy;
alarm[9] = room_speed;
}
//petrified
if (global.petrification == true)
{
path_speed = 0;
speed = 0
sprite_index = PetrifiedBrain;
}
if (global.freeze_brains)
{
path_speed = 0;
speed = 0;
//sprite_index = BigBrainStill;
alarm[9] = room_speed;
}
//hit by lightning
was_hit_by_lit = false;
defense = 1;
if (global.defense_boost)
{
defense = 20;
}
//////////POISON INFLICTED////////////////
/////////////////////////////////////////
/////////////////////////////////
//Poison ZmyTimer
//
if (poisoned)
{
myTimer--;
if (myTimer <= 0)
{
total_strength = strength - other.strength
total_defense = defense - other.defense
total_formula = (strength - defense)*attack
hp_minus = total_formula*irandom_range(200, 400);
hp_minus = damage;
myTimer = 0;
floater = instance_create_depth(x+10, y-10, -17000, DamageIndicatorObject);
floater.text = string(hp_minus);
if (hp <= 0)
{
show_debug_message("Dead Brain Ghost and Fading Gem");
instance_create_depth(x, y, -1100,DeadBrainObject);
instance_create_depth(x-150, y-20, -1100, FadingGemObject);
global.achievement_gold_counter++;
with (other)
{
experience += 50
}
global.achievement_tome_experience += 20;
instance_destroy();
}
myTimer = room_speed;
}
under_attack = true;
took_a_hit = true;
}
attackRange = 50;
flyspeed = 5;
floater_myTimer--;
global.brain_strength = strength
/////////////////DEFENSE//////////////
global.brain_defense = defense
//////////////////ATTACK/////////////////
global.brain_attack = attack
//////////////////////DEXTERITY/////////////
//ability to use a projectile
global.brain_dexterity = dexterity
/////////////////SPEED ///////////
//unaccelerated spaed
global.brain_spd = spd
///////////////INTELLIGENCE////////////////
//strength of projectiles
global.brain_intelligence = intelligence
////////////////////////////////////////////
if (point_in_rectangle(x-100, y, 156, 100, 600, 1400))
{
show_debug_message("Wall Collision");
castle_wall_myTimer--;
if (castle_wall_myTimer <= 0)
{
// hp_minus = irandom_range(40, 150);
hp_minus = irandom_range(200, 600);
hp = hp - hp_minus
global.castle_hp = global.castle_hp - hp_minus;
path_end();
//Trieed 500 unsuccesful. Try ing 600.
//600 works but spans the whole level
//trying 650
if (x < 590 && x>200) //tried 500 and 600. Tried 550.Tried 590. Tried 580
{
show_debug_message("Xdimensions IS " + string(x))
with (ScorpionBrainObject)
{
sprite_index = ScorpionBrainAttack;
}
with (BigBrainObject)
{
sprite_index = BigBrainAttacking
}
while (damage_display <= room_speed*10)
{
damage_display++;
floater = instance_create_depth(x,y, -1700, DamageIndicatorObject);
floater.text = string(hp_minus);
}
}
instance_create_depth(x, y-300, -1800, FrankGhostObject);
instance_destroy()
//sprite_index = global.brain_party_kill;
castle_wall_myTimer--;
number_of_attacks++;
//if (number_of_attacks > 5)
//{
// instance_destroy();
//}
castle_wall_myTimer = room_speed;
//floater = instance_create_depth(x+10, y-10, -17000, DamageIndicatorObject) ;
//floater.text = string(hp_minus);
show_debug_message("Iterating through step wall myTimer");
}
}
/////////////////////////////////
/////////////LIGHTNING BAT ATTACK//////////////
/////////////////////////////////////////////
//show_debug_message("lit_damage_myTimera: " + string(lit_damage_myTimera));
//show_debug_message("lit_damage_myTimerb: " + string(lit_damage_myTimerb));
//show_debug_message("lit_damage_myTimerc: " + string(lit_damage_myTimerc));
if (global.active) { show_debug_message("Active is true"); }
else { show_debug_message("ACtive is false"); }
if (global.active == true && collision_line(global.litorigin_x, global.litorigin_y, global.lightning_1_x, global.lightning_1_y, ScorpionBrainObject, false, false))
{
lit_damage_myTimera--;
show_debug_message("lit_damage_myTimera: " + string(lit_damage_myTimera));
if (lit_damage_myTimera <= 0)
{
show_debug_message("Lit myTimer A fire: ");
total_strength = strength - other.strength
total_defense = defense - other.defense
total_formula = (strength - defense)*attack
hp_minus = total_formula*irandom_range(100, 400);
damage = hp_minus;
hp = hp - hp_minus;
floater = instance_create_depth(x, y, -17000, DamageIndicatorObject)
floater.text = string(damage)
under_attack = true;
took_a_hit = true;
was_hit_by_lit = true;
lit_damage_myTimera = room_speed*4;
}
}
if (global.active == true && collision_line(global.lightning_1_x, global.lightning_1_y, global.lightning_2_x, global.lightning_2_y, ScorpionBrainObject, false, false))
{
lit_damage_myTimerb--;
if (lit_damage_myTimerb <= 0)
{
show_debug_message("Lit myTimer B fire: ");
total_strength = strength - other.strength
total_defense = defense - other.defense
total_formula = (strength - defense)*attack
hp_minus = total_formula*irandom_range(100, 400);
damage = hp_minus;
hp = hp - hp_minus;
floater = instance_create_depth(x, y, -17000, DamageIndicatorObject)
floater.text = string(damage)
under_attack = true;
took_a_hit = true;
was_hit_by_lit = true;
lit_damage_myTimerb = room_speed*4;
}
}
if (global.active == true && collision_line(global.lightning_2_x, global.lightning_2_y, global.lightning_3_x, global.lightning_3_y, ScorpionBrainObject, false, false))
{
lit_damage_myTimerc--;
if (lit_damage_myTimerc <=0)
{
show_debug_message("Lit myTimer C fire: ");
total_strength = strength - other.strength
total_defense = defense - other.defense
total_formula = (strength - defense)*attack
hp_minus = total_formula*irandom_range(100, 400);
damage = hp_minus;
hp = hp - hp_minus;
floater = instance_create_depth(x, y, -17000, DamageIndicatorObject)
floater.text = string(damage)
under_attack = true;
was_hit_by_lit = true;
lit_damage_myTimerc = room_speed*4;
}
}
//////////////////Lightning Bat KIll////////////////////
if (hp <= 0)
{
global.achievement_gold_counter++;
global.achievement_tome_experience += 20;
with (other)
{
experience += 30
}
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 (poisoned == true)
{
hp -= 100
instance_destroy(PoisonBuffIcon)
instance_create_depth(x, y-100, -1400, PoisonBuffIcon)
}
event_inherited();
Code:
global.brain_party_still = StormSpecialtyBrain;
global.brain_party_walk = StormSpecialtyBrainWalk;
global.brain_party_kill = StormSpecialtyBrain;
global.brain_strength = strength
/////////////////DEFENSE//////////////
global.brain_defense = defense
//////////////////ATTACK/////////////////
global.brain_attack = attack
//////////////////////DEXTERITY/////////////
//ability to use a projectile
global.brain_dexterity = dexterity
/////////////////SPEED ///////////
//unaccelerated spaed
global.brain_spd = spd
///////////////INTELLIGENCE////////////////
//strength of projectiles
global.brain_intelligence = intelligence
///////////EXPERIEINCE///////////////
//rolling over experience every time kill something with this bat type
global.brain_experience = experience
///////////////LEVEL///////////////////////////
//experience adds up to a new level for that bat
//this increases stats for that bat type
global.brain_experience_level = experience_level
///////////////damage/////////////////////
show_debug_message("DAMAGE" + string(global.current_brain_attack_target_damage));
if (global.current_brain_attack_target_damage > 0)
{
//direct damage works
//global.current_brain_attack_target_damage is 0
hp -= 50;
//hp -= global.current_brain_attack_target_damage;
//global.current_brain_attack_target_damage = 0; //reset damage
}
/////////////STRENGTH//////////////
event_inherited();
////mindbreaker
STORMSPECIALBRAIN STEP CODE
Code:
global.brain_party_still = StormSpecialtyBrain;
global.brain_party_walk = StormSpecialtyBrainWalk;
global.brain_party_kill = StormSpecialtyBrain;
global.brain_strength = strength
/////////////////DEFENSE//////////////
global.brain_defense = defense
//////////////////ATTACK/////////////////
global.brain_attack = attack
//////////////////////DEXTERITY/////////////
//ability to use a projectile
global.brain_dexterity = dexterity
/////////////////SPEED ///////////
//unaccelerated spaed
global.brain_spd = spd
///////////////INTELLIGENCE////////////////
//strength of projectiles
global.brain_intelligence = intelligence
///////////EXPERIEINCE///////////////
//rolling over experience every time kill something with this bat type
global.brain_experience = experience
///////////////LEVEL///////////////////////////
//experience adds up to a new level for that bat
//this increases stats for that bat type
global.brain_experience_level = experience_level
///////////////damage/////////////////////
show_debug_message("DAMAGE" + string(global.current_brain_attack_target_damage));
if (global.current_brain_attack_target_damage > 0)
{
//direct damage works
//global.current_brain_attack_target_damage is 0
hp -= 50;
//hp -= global.current_brain_attack_target_damage;
//global.current_brain_attack_target_damage = 0; //reset damage
}
/////////////STRENGTH//////////////
event_inherited();
////mindbreaker