Hi, I'm fairly new to coding and new help with this.
In the game im making, you have the ability to buy rooms.
How do I give a certain area of the map to a player in the most effective way?
Any help will be very appreciated.
ID:158562
Aug 6 2009, 1:49 am
|
|
Aug 6 2009, 2:00 am
|
|
Define give, as we could take this to many any number of things.
|
In response to Demon_F0rce
|
|
At start, all rooms will be empty and have no owner. A player can only do changes to a room he does own. For that he needs to buy the room.
The question is: How do I change the owner of a certain piece of the map, in this case a room, from "None" to the buyer's name. It's kind of hard to explain, sorry for the complications. |
In response to Akibaba
|
|
obj/room/verb/Buy() |
In response to Demon_F0rce
|
|
Ok, but does the DM know where the room is on the map and what is in it then?
|
In response to Akibaba
|
|
Of course not, how can that be possible? DM is just a programming language, not a sentient creature.
You have to tell the game what to look for and what to do. |
In response to GhostAnime
|
|
That was just a polite way of saying that the answer given was not exactly what I was looking for.
How would I do that in this case then? |
In response to Akibaba
|
|
I presume your rooms have doors,
using the above example, only allow the door.owner to pass the door. |
My suggestion is to divide each room up into an area, which conveniently provides a list of what is within the room: everything in room.contents - except for mobs - belongs to you and can be modified. Give each room a unique tag, ideally using the instance editor in the map editor: when you select your /area/room, right click on the "room" in the "Object" box below the minimap and Edit Instance, and then change the tag (and probably the name too) to something unique and place it on the map. Repeat for every room you have.
With the unique tags, you can easily list them and locate them. The list of areas can be generated at world/New, like so: var/list/rooms = list() That'll give you an associative list. You can have a player select a room from rooms and it will list their names (so you can name them "apartment 5B" or somesuch) which you can then fetch the tag from with roomtag = rooms[selection]. Once you have the tag, you can locate the room with locate(roomtag). As for allowing somebody to modify something, as I said: if the area belongs to them, they can modify it. So, to modify a turf, var/area/A = T.loc, and check if A.owner is the player. For an obj, it'd be var/area/A = O.loc.loc. Saving and loading is something of an issue here. I suggest that if you want the contents of an area saved and loaded that you do it in world/Del() and New(). If the area has a reference to the player then it should be declared tmp so as not to save (var/mob/tmp/owner). If the player has a list of rooms they own, they need to be saved as text strings, like so: mob If you don't do this, by the way, you'll get weird rollback bugs and generally Bad Stuff will happen as a result of saving and loading, such as any homeowners being loaded in world/New() and just sort of standing around. |