The Question
Member
I have four booleans, npc_canmove_up, npc_canmove_down, npc_canmove_left, ncp_canmove-right, in my npc object's variable definitions section. Then in my create event I started this self repeating alarm.
This works perfectly, but there is one defect I don not like. Lets say the random number is 1, but the ncp_canmove_right is false, the the alarm will happen restart and nothing will happen. Which is fine, but I want the npc to move to move every time the alarm is called so ncp_canrotatetime_min and max to work properly.
I tried putting if statements in irandom_rage to only select the value if the boolean is true, but it doesn't seem to accept if statements inside it. Another idea I had was in the create event make a array based on the variable definitions and select a random value out of the array, but I'm not sure how to do that or if there is a better way to this all together.
That was a long one, if I didn't make sense or if you need you info feel free to ask.
Code:
//start another alarm
alarm[0] = random_range(ncp_rotatetime_min,ncp_rotatetime_max);
//select random number for direction of npc
var i = irandom_range(1,4);
//rotate based on the random number and if npc_canrotate is true
if(i=1 and ncp_canrotate_right) direction = 0;
if(i=2 and ncp_canrotate_up)direction = 90;
if(i=3 and ncp_canrotate_left)direction = 180;
if(i=4 and ncp_canrotate_down)direction = 270;
I tried putting if statements in irandom_rage to only select the value if the boolean is true, but it doesn't seem to accept if statements inside it. Another idea I had was in the create event make a array based on the variable definitions and select a random value out of the array, but I'm not sure how to do that or if there is a better way to this all together.
That was a long one, if I didn't make sense or if you need you info feel free to ask.