I need a little bit of help on my personnal project: Feast of the greedy.
It seems like i made a partially viable code on game maker, let me explain my reasonning.
i set up variables relating to the position of the objective and the floor one need to go
patrol = 100 (never change for now)
objective = 0
objectiveX = 0
objectiveY = 0
patrol_floor = 5 (this is the default value it returns too since 0 is the ground floor)
//chosing objective (1:patrol)(2:eat)(3:rest)
if objective = 0
{
if patrol > 99
{
objective = 1
}
else
{
if hungry > 50
{
objective = 2
}
else
objective = 3
}
}
Now we reach the problematic code
if objective = 1 && patrol_floor =5
{
patrol_floor = irandom(3)
global.patrol_floor = patrol_floor
if patrol_floor == 0
{
objectiveY = Obj_locationWaypoint1.y
objectiveX = Obj_locationWaypoint1.x
}
if patrol_floor == 1
{
objectiveY = Obj_locationWaipoint2.y
objectiveX = Obj_locationWaipoint2.x
}
if patrol_floor == 2
{
objectiveY = Obj_locationWaipoint3.y
objectiveX = Obj_locationWaipoint3.x
}
if patrol_floor == 3
{
objectiveY = Obj_locationWaipoint4.y
objectiveX = Obj_locationWaipoint4.x
}
}
this part generate a random number (it works)
in order to tell what waypoint location to use for later code.
the part after this is supposed to tell where to move in order to reach teleporters (in working condition).
adding ! (not) to the second part of the condition relating to if the waypoint position corelate with the one given in advance (yes there is a typo in waypoint, but its not the problem) will cause an endless movement in the given position. Currently the Ai stand still and doesn’t go anywhere.
//time to go about the building
//walking
if objectiveY < y or objectiveY > y
{
if Obj_locationWaypoint1.y = y && Obj_locationWaipoint4 = objectiveY
{
hsp= movespeed
}
if Obj_locationWaypoint1.y = y && Obj_locationWaipoint3 = objectiveY
{
hsp= -movespeed
}
if Obj_locationWaypoint1.y = y && Obj_locationWaipoint2 = objectiveY
{
hsp= -movespeed
}
if Obj_locationWaipoint2.y = y && Obj_locationWaypoint1 = objectiveY
{
hsp= -movespeed
}
if Obj_locationWaipoint2.y = y && Obj_locationWaipoint3 = objectiveY
{
hsp= movespeed
}
if Obj_locationWaipoint2.y = y && Obj_locationWaipoint4 = objectiveY
{
hsp= movespeed
}
if Obj_locationWaipoint3.y = y && Obj_locationWaipoint2 = objectiveY
{
hsp= movespeed
}
if Obj_locationWaipoint3.y = y && Obj_locationWaypoint1 = objectiveY
{
hsp= movespeed
}
if Obj_locationWaipoint3.y = y && Obj_locationWaipoint4 = objectiveY
{
hsp= -movespeed
}
if Obj_locationWaipoint4.y = y && Obj_locationWaypoint1 = objectiveY
{
hsp= movespeed
}
if Obj_locationWaipoint4.y = y && Obj_locationWaipoint3 = objectiveY
{
hsp= -movespeed
}
if Obj_locationWaipoint4.y = y && Obj_locationWaipoint2 = objectiveY
{
hsp= -movespeed
}
}
well if anything i may need to just change completely my code if i can’t fix it
Well i hope all your projects will go smoothly.