I'm making an rpg game that's going to be tons of awesome, but I need some pointers because I don't know script very well. I want player to pop up into a battle room randomly everytime he steps on a floor in a dungeon, and after defeating all the monsters, appears back at the same exact spot before entering the battle room. Second, I want the enemies to follow the player in only four directions (Northwest, Southwest, Northeast, Southeast) and attack when they are close enough to the player for close combat. third I want them to randomly drop treasures when defeated.
Also, I would like for my player to be able to have an inventory they can check and use items from and spells at their disposal.
This is a lot, I know, but I hope you guys can help me out with some of the stuff, please and thank you!
Making Enemies Follow Player Diagnally
Started by Vison, Dec 03 2011 11:01 PM
3 replies to this topic
#1
Posted 03 December 2011 - 11:01 PM
#2
Posted 03 December 2011 - 11:52 PM
For the whole "same exact spot after battle room" save variables.
Let's assume on a collision with obj_enemy, obj_player goes into battleroom, then goes back to the same position in the same room afterwards.
For the enemies going in only four directions, put in their step events:
Let's assume on a collision with obj_enemy, obj_player goes into battleroom, then goes back to the same position in the same room afterwards.
//Put this in collision with obj_enemy for obj_player var global.memx, global.memy, global.memroom; global.memx = x global.memy = y global.memroom = room //Put this after you're done in the battle room x=global.memx y=global.memy room=global.memroom
For the enemies going in only four directions, put in their step events:
move_towards_point(obj_player.x,obj_player.y,whateverspeedyouwant) direction = floor(direction/4)+45 Randomly drop treasures and inventories require arrays, which I am not very good at. Sorry if the codes here don't work.
#3
Posted 04 December 2011 - 12:24 AM
Okay, I may have done something wrong. 1 the enemy only moves one direction, and 2, there was an error at line 2 var global.memx, global.memy, global.memroom; Perhaps I've put the codes on the wrong events or objects?
#4
Posted 04 December 2011 - 02:17 AM
That was probably my fault. Try putting each var on a separate line:
And with the whole direction thing, IDK. I'd assume it's because I used two different types of movement. I'm not too good with GML, so I would just trash the diagonal movement, move towards the point of the player, and leave it at that. Sorry for giving you nonworking code
If the vars still don't work, copy and paste the code into the create event for your player object.
var global.memx; var global.memy; var global.memroom;
And with the whole direction thing, IDK. I'd assume it's because I used two different types of movement. I'm not too good with GML, so I would just trash the diagonal movement, move towards the point of the player, and leave it at that. Sorry for giving you nonworking code
If the vars still don't work, copy and paste the code into the create event for your player object.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











