ID:180494
 
OK, I have my 100 battle areas for my turn-based game (same as a long time before). When a person gets in a fight, they are warped to one of these battle areas (one that is not in use). I plan on having one little "battle_area" area type on each battle area. When the person gets into a fight, a for loop loops through all of the "battle_area"s, looking for one not in use. The person is then warped to the appropriate spot in the battle area. Here's a picture representing some stuff:


Now, the yellow target spots represent the spots where people will end up in the battle area (they will be locked in those spots). The middle orange one represents the invisible battle_area area type.

Now, finally, here's my problem: How can I associate the battle area with it's target spots (where the players end up)?

I was thinking of doing it directly by location, because I'll have the battle_area type in the same position in each battle area. I mean, I could do it by the coordinates of the target spots related to the coordinate of their battle_area. Would that be a good way to do it? If so, how could I?
I was thinking of doing it directly by location, because I'll have the battle_area type in the same position in each battle area. I mean, I could do it by the coordinates of the target spots related to the coordinate of their battle_area. Would that be a good way to do it? If so, how could I?

An easier way, which I do in Hunter, is simply to subclass the target spots from the area spots.

For example:

area
battle_area001
party1
party2
battle_area002
party1
party2

Then, you move the player's mob to the battle_area001 location, and then you move the combatants to the appropriate party# area there.

Eg.

//loop through all of the battle areas until you find an empty one here

player1.loc = locate(/area/battle_areaXXX)
player2.loc = locate(/area/battle_areaXXX)
for(var/mob/M in player1.troops)
M.loc = locate(/area/battle_areaXXX/party1)
for(var/mob/M in player2.troops)
M.loc = locate(/area/battle_areaXXX/party2)


You can easily adapt this to be more object-oriented, but I'm not about to launch into details... you've got the framework, so make it work right! =)
In response to Spuzzum
On 5/30/01 7:08 pm Spuzzum wrote:
I was thinking of doing it directly by location, because I'll have the battle_area type in the same position in each battle area. I mean, I could do it by the coordinates of the target spots related to the coordinate of their battle_area. Would that be a good way to do it? If so, how could I?

An easier way, which I do in Hunter, is simply to subclass the target spots from the area spots.

For example:

area
battle_area001
party1
party2
battle_area002
party1
party2

Then, you move the player's mob to the battle_area001 location, and then you move the combatants to the appropriate party# area there.

Eg.

//loop through all of the battle areas until you find an empty one here

player1.loc = locate(/area/battle_areaXXX)
player2.loc = locate(/area/battle_areaXXX)
for(var/mob/M in player1.troops)
M.loc = locate(/area/battle_areaXXX/party1)
for(var/mob/M in player2.troops)
M.loc = locate(/area/battle_areaXXX/party2)

Uhm, doing it that way, wouldn't I have to define 100 different area types? That's what I was trying to avoid...
In response to Cinnom
Uhm, doing it that way, wouldn't I have to define 100 different area types? That's what I was trying to avoid...

In times of trouble, go with what you know! ;-)

You do raise a valid question, though. But my advice would be that there really is no easy way to go about this problem, so choose the method that seems easiest.

Personally, I think this method is easiest. Your mileage may vary.
In response to Spuzzum
On 5/30/01 7:35 pm Spuzzum wrote:
Uhm, doing it that way, wouldn't I have to define 100 different area types? That's what I was trying to avoid...

In times of trouble, go with what you know! ;-)

You do raise a valid question, though. But my advice would be that there really is no easy way to go about this problem, so choose the method that seems easiest.

Personally, I think this method is easiest. Your mileage may vary.

Well, in the end, your way seems the easiest. I guess I'll go ahead and start copying and pasting those areas =)