T
Tom_SavePointsGames
Guest
Hello,
I am making a game with a lot of enemies that use similar variables.
examples:
enemy_health = 5;
enemy_damage = 2;
enemy_spd = 3;
I am familiar with inheritence and thought it would be easier to maintain one script with a list of all the enemies and what there initial variables should be instead of editing each individual create event
so in the parent create event for obj_enemy I have the following
scr_build_enemy( object_get_name( self ) ); //the spaces are to make it easier to read they are not in the code. (side note I have also tried self.id and id instead of self.
Then i have a script with the following:
var enemy = argument0;
if (enemy == obj_bug)
{
enemy_health = 5;
enemy_damage = 2;
enemy_spd = 3;
}
if (enemy == obj_flier)
{
enemy_health = 10;
enemy_damage = 3;
enemy_spd = 5;
}
etc.
it's not working. is there a way to get the name of the object for that instance and pass it instead a script as an argument and then set that to a variable that is used to check and set enemy variables?
Thanks
-Tom
I am making a game with a lot of enemies that use similar variables.
examples:
enemy_health = 5;
enemy_damage = 2;
enemy_spd = 3;
I am familiar with inheritence and thought it would be easier to maintain one script with a list of all the enemies and what there initial variables should be instead of editing each individual create event
so in the parent create event for obj_enemy I have the following
scr_build_enemy( object_get_name( self ) ); //the spaces are to make it easier to read they are not in the code. (side note I have also tried self.id and id instead of self.
Then i have a script with the following:
var enemy = argument0;
if (enemy == obj_bug)
{
enemy_health = 5;
enemy_damage = 2;
enemy_spd = 3;
}
if (enemy == obj_flier)
{
enemy_health = 10;
enemy_damage = 3;
enemy_spd = 5;
}
etc.
it's not working. is there a way to get the name of the object for that instance and pass it instead a script as an argument and then set that to a variable that is used to check and set enemy variables?
Thanks
-Tom