I am trying to do something that seemed simple at first but after 30 minutes of attempts I can not get anything that works. I have a verb that will only function if the player is 4 tiles away from a set location. The code will randomly pick a location point and assign it to a variable. Then when a player clicks on the verb it will compare the location variable and the users location and see if they are within 4 tiles. Can anyone point me to a proc or a domcument that would give me some tips?
Thanks
Shwn
ID:178807
Apr 2 2002, 7:22 am
|
|
In response to Lummox JR
|
|
I don't care about the turf as much as the location. I want to avoid having special turf icons and I don't want to use areas. I am trying to write some treasure hunting code. When a map is created it is tagged with a random location on the map and placed in a variable lets say its called maplocation. There is a verb called dig, that verb will allow you to dig only if you are within 4 tiles of the location in maplocation otherwise it will return a string of "You dig and find nothing". So anytime the player clicks on the dig verb it will check the players current location with the location in maplocation and determine if it is 4 tiles away.
So what I am looking for is the bit of logic that takes a location such as 3,16,1 and compares it to the current player location to deciede if is is within 4 tiles. |
In response to Shwn
|
|
Shwn wrote:
I don't care about the turf as much as the location. I want to avoid having special turf icons and I don't want to use areas. I am trying to write some treasure hunting code. When a map is created it is tagged with a random location on the map and placed in a variable lets say its called maplocation. There is a verb called dig, that verb will allow you to dig only if you are within 4 tiles of the location in maplocation otherwise it will return a string of "You dig and find nothing". So anytime the player clicks on the dig verb it will check the players current location with the location in maplocation and determine if it is 4 tiles away. Aha. That is rather different, then. Try something like this: var/turf/X // marks the spot Lummox JR |
In response to Lummox JR
|
|
This is sort of what I have been trying, with no success.
I am a bit confused about the get_dist proc, it wants 2 arguments get_dist(Loc1,Loc2). What is Loc1 and Loc2? Are they locations on the map such as 3,12,1 or are they objects? In your code I do not understand where the random location is set. This is what I was trying dig() if (get_dist(src,usr.maplocation)<=4) ... With usr.maplocation set with a location on the map. To test I use 3,16,1 but that seems unimportant. This code fails even if you are standing in location 3,16,1 on the map. |
In response to Shwn
|
|
Shwn wrote:
This is sort of what I have been trying, with no success. A location on the map, as returned by locate(), would be a turf. In the case of get_dist, Loc1 and Loc2 are both atoms. An atom can be a turf, mob, obj, or area (though I'm not sure if or how get_dist() works with areas.) This is what I was trying How are you setting usr.maplocation? Is it set using locate(3,16,1)? Assuming this is correct, I'd check your indentation under that if(). I don't know if the ... you put in is indented the same as the code in your actual verb, but if it is, then it needs to be indented further. (Otherwise the if() does nothing.) Lummox JR |
In response to Lummox JR
|
|
Lummox JR wrote:
Shwn wrote: Is there a reason to have a variable called maplocation when the user's location can already be determined? Try this: dig() if (get_dist(src, usr)<=4) ... |
In response to Skysaw
|
|
Skysaw wrote:
Is there a reason to have a variable called maplocation when the user's location can already be determined? He's using usr.maplocation to point to the location of buried treasure. In the example code I posted, I made this a global variable--which is a little more consistent with multiplayer play. Lummox JR |
In response to Lummox JR
|
|
Lummox JR wrote:
Skysaw wrote: Sorry, I guess I was too lazy to read the whole thread. I skip ahead in novels too. I'm still wondering why that location would be a usr variable though... |
In response to Lummox JR
|
|
The problem was I was not setting my maplocation var correcly. Thanks for all your help.
Shwn |
Um... I'm really not sure I follow what you're saying, here. Let me see if I have this straight:
There is a particular turf (T) on the map. The player may use a certain verb only if they are within 4 tiles of T. You want to know how to restrict the verb to only work within 4 tiles' distance from T.
Is that correct?
If that's the case, what you probably have to do is this:
If you want this to be controlled by a var that turns on, you could (I think) do this:
I believe that should work, but I haven't tested it.
Lummox JR