ID:158894
Jun 13 2009, 2:23 pm
|
|
So I am trying to create a rpg game where you get into a battle when you get near an enemy on the world map. If usr is 1 distance from the enemy, usr would thrown into a battlefield that would allow him to fight said enemy. How would I program this? I don't really know where to start.
|
Copyright © 2024 BYOND Software.
All rights reserved.
Don't use the word "usr" so much. It's not a valid word anyway and you're probably relying on the usr var too much and thinking it's suitable for every case. It very much isn't.
You want to initiate the battle when a player steps on a turf which is adjacent to an enemy. You can do something after every time a player steps into a turf by overriding turf/Entered() - that proc is called whenever something has entered a turf. The beginning of your system would look a little like this:
That's the basic premise. You could also of course look for multiple enemies and start a multiple-enemy battle if you want that. What exactly to do in the rest depends on multiple factors such as whether your game is single-player or multiplayer, what do you want to happen when a battle is initiated and how you want it to work, do you want the participants to be still visible on the map at the spot where the battle began, etc. Generally, you should handle battles tidily by using datums to keep track of the battle status. A short example: