K
Kloetengott
Guest
Hello Community,
good to see so many active members here. Looks like this community is very alive
So hopefully somebody can help my with a little problem:
I´m playing around with a small Arenagame. The part i´m working on right now is the "core" itself.
You can put up to 6 fighters in the arena and you will get 6 enemy fighters against you.
So if I would code every possible Object-Meeting i would need to do that 36 times. I thought i found a more elegant solution:
This is part of the code from step-event of my main gladiator.
As you can see i created the IF with 6 different statements that can be true. This seems to work fine. I did some tests with this and draw_texts onscreen and it worked.
I then wanted to use the "other" feature to get values from the object, that my main-object has just met. For example the enemy gladiator.
Not much code here yet:
This is from the Create-Event.
When compiling i get the error, that the values for this variables are not set:
glad2_strike = other.agility+random(other.luck);
So it looks like the other-feature is not working as i want it to work.
Could somebody give ma a hint what i did wrong here?
I would prefer not to code 36 meeting-events seperately
good to see so many active members here. Looks like this community is very alive
So hopefully somebody can help my with a little problem:
I´m playing around with a small Arenagame. The part i´m working on right now is the "core" itself.
You can put up to 6 fighters in the arena and you will get 6 enemy fighters against you.
So if I would code every possible Object-Meeting i would need to do that 36 times. I thought i found a more elegant solution:
Code:
if place_meeting(x,y,obj_enemy_1) || place_meeting(x,y,obj_enemy_2) || place_meeting(x,y,obj_enemy_3) || place_meeting(x,y,obj_enemy_4) || place_meeting(x,y,obj_enemy_5) || place_meeting(x,y,obj_enemy_6)
{
if other.alive == true
{
move = false;
other.move = false;
dir = point_direction(x, y, other.x, other.y);
glad1_strike = global.glad_own_agi[0]+random(global.glad_own_luck[0]);
glad2_strike = other.agility+random(other.luck);
if glad1_strike > glad2_strike
{
other.hlife -= global.glad_own_str[0];
instance_create(other.x, other.y, obj_sword_g1);
....
As you can see i created the IF with 6 different statements that can be true. This seems to work fine. I did some tests with this and draw_texts onscreen and it worked.
I then wanted to use the "other" feature to get values from the object, that my main-object has just met. For example the enemy gladiator.
Not much code here yet:
Code:
alive = true;
move = false;
agility = 8;
luck = 8;
life = 90;
hlife = life;
strenght = 9;
When compiling i get the error, that the values for this variables are not set:
glad2_strike = other.agility+random(other.luck);
So it looks like the other-feature is not working as i want it to work.
Could somebody give ma a hint what i did wrong here?
I would prefer not to code 36 meeting-events seperately
Last edited by a moderator: