| Mirage Source http://miragesource.net/forums/ |
|
| How to handle gathering. http://miragesource.net/forums/viewtopic.php?f=201&t=3882 |
Page 1 of 1 |
| Author: | Asrrin29 [ Mon Jun 23, 2008 2:49 pm ] |
| Post subject: | How to handle gathering. |
I have the code in place to use a gathering profession to gather items such as minerals and plants. if the person steps on a tile that has a gatherable item, then it checks the player's profession and profession level to determine what and how many items the player gets by performing the gathering action. however, I currently have not programmed a way for the game to know that the player cannot gather from that spot for a pre-determined amount of time. What do you think would be the best, most efficient way of going about programming this? preferably something that uses as few checks in the server loop as possible. |
|
| Author: | Robin [ Mon Jun 23, 2008 3:16 pm ] |
| Post subject: | Re: How to handle gathering. |
Do you want it set per tile or per player? |
|
| Author: | Asrrin29 [ Mon Jun 23, 2008 6:07 pm ] |
| Post subject: | Re: How to handle gathering. |
whatever is going to use the least amount of code. the easiest thing to code would be to check every tile on every map to see if it's been used, but that would lag the game so much it wouldn't be worth it. the most efficient thing to do would be making a separate database that stores what tiles on what maps have these resource "nodes" and just check each of these at certain times. if they've been used (a flag variable) then they get reset. If you have an idea for something more efficient, let me know. |
|
| Author: | Robin [ Mon Jun 23, 2008 7:25 pm ] |
| Post subject: | Re: How to handle gathering. |
Just make it so when the player stands on the tile, GetTickCount is saved to any empty Data* that is there, then whenever someone else stands on it do something like this: Code: If Tile.Data3 + 10000 > GetTickCount then
CAN HARVEST else ALREADY HARVESTED end if |
|
| Author: | Asrrin29 [ Mon Jun 23, 2008 7:31 pm ] |
| Post subject: | Re: How to handle gathering. |
good idea, thanks! But would that be GetTickCount server side, or client side? |
|
| Author: | Robin [ Mon Jun 23, 2008 7:35 pm ] |
| Post subject: | Re: How to handle gathering. |
Server. The entire thing should be serverside. |
|
| Author: | Asrrin29 [ Mon Jun 23, 2008 7:38 pm ] |
| Post subject: | Re: How to handle gathering. |
That's what I thought, just wanted to be sure. I can rewrite my code to put the profession data in the item stats instead of the map stats too to save having to program extra map data which can bog things down. |
|
| Author: | deathknight [ Thu Aug 21, 2008 7:55 am ] |
| Post subject: | Re: How to handle gathering. |
I have a question (sorry, I'm trying to learn a little bit of coding) would this bit of code activate only when you walk onto the tile, as long as you are standing on the tile, or would it depend on where you placed the code? Any explanation to a response would be appreciated. Quote: Code: If Tile.Data3 + 10000 > GetTickCount then CAN HARVEST else ALREADY HARVESTED end if |
|
| Author: | Rian [ Thu Aug 21, 2008 8:22 am ] |
| Post subject: | Re: How to handle gathering. |
Depends on where you place the code. This bit is probably activated by player action, such as standing on the tile and hitting enter, or using an item, such as a scythe or hoe, in front of or next to the tile. What it definitely does do though, is make a player wait a certain amount of time (tile.Data3 + 10000) before someone can perform the action (harvesting) again. In this case, it looks like gettickcount is being stored in the tile's .Data3 |
|
| Author: | Asrrin29 [ Thu Aug 21, 2008 11:53 am ] |
| Post subject: | Re: How to handle gathering. |
I have the code set up to check when a player tries to pick up an item (for me that's using the "f" key). if they are on a tile with an item they pick it up, but if they are on a resource tile it runs the resource checking sub to make sure they have everything needed to gather the resource. |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|