I
iMilchshake
Guest
Hayho Guys! ^-^
Hope you guys can help me. So basicly im doing a Robot AI (Team A) vs. Robot AI (Team B) simulation right now. There is a script that searches for a new target in the detection range for each Robot. The Script get triggered all 3-4 Seconds or if a Robot has no target (Target Died). Second doesnt work. That is because im saving all the Enemys Robots(In the Detection Range) ids in a ds_list:
Same for team=="B" of course.
When im trying to put a code like this in the step event:
I get this Error Message:
Looks like the Ids arent beeing recognised as ids in a ds_list. tried it with this already:
No Error message tho, but doesnt work as it should. When a robot's target dies it doesnt triggers the script automatically, because the variable "target" doesnt get cleared when the target dies. Hope someone understood my problem and can help me D:.
EDIT:
Idea: When a Robot dies it first checks if it was someones target. If yes it sets their variable "target" to undefined (dont know how to do that tho). Then
should work, right?
Hope you guys can help me. So basicly im doing a Robot AI (Team A) vs. Robot AI (Team B) simulation right now. There is a script that searches for a new target in the detection range for each Robot. The Script get triggered all 3-4 Seconds or if a Robot has no target (Target Died). Second doesnt work. That is because im saving all the Enemys Robots(In the Detection Range) ids in a ds_list:
Code:
ds_list_clear(spotted_enemys); //ds list where ids get saved in
if team=="A" //checks with team the robot is in
{
for (var i=0;i<instance_number(RobotB);i++)
{
e=instance_find(RobotB,i)
if distance_to_object(e)<detrange //checks if the checked robot is in the detection range
ds_list_add(spotted_enemys,e) //if yes, adds it to the list
}
target=ds_list_find_value(spotted_enemys,irandom(ds_list_size(spotted_enemys)))
}
When im trying to put a code like this in the step event:
Code:
if !(instance_exists(target))
{
scr_get_target();
}
Code:
instance_exists argument 1 incorrect type (5) expecting a Number (YYGI32)
at gml_Object_Robot_StepNormalEvent_1 (line 6) - if !(instance_exists(target))
Code:
if is_undefined(target)
EDIT:
Idea: When a Robot dies it first checks if it was someones target. If yes it sets their variable "target" to undefined (dont know how to do that tho). Then
Code:
if is_undefined(target)