Diego

Member
Hi you all,
I've scripted an "Herbalism Knife" to take reagents and colored berrys if used on a Forest LandTile.
Can you suggest me how to limit the max usages per single tile (a sort of respawn time)?

Thank you!
 
You could have a static dictionary of <Point2D,DateTime> which contains the last time that particular point2d was harvested. Then when the player harvests the tile, get the Point2D location of it and check the last harvest time in the dictionary.

Not super important but you'd probably want to clear out expired datetimes as well, which you could do on a shard save. Honestly though, a dictionary like like probably isn't ever going to grow super large in size, and it will reset on shard restart anyway.
 
Hi you all,
I've scripted an "Herbalism Knife" to take reagents and colored berrys if used on a Forest LandTile.
Can you suggest me how to limit the max usages per single tile (a sort of respawn time)?

Thank you!
If you look closely at the scripts in the Harvest system, you'll see that you can add lots more to it, in terms of land tiles. Then players would have to have that tool to harvest from that tile...just like mining.

If that seems a bit too far over your head, you could use a package like Hammerhand released:
https://www.servuo.com/archive/firerock-crafting-by-hammerhand.107/

Then you just have to make changes to the items within the system.
 
Another option could be to have on the first use of the tile succeed, create a hidden placeholder item at that tile that will decay on a timer after whatever time. Then on the second use of the tile the code could check and search that tile for these placeholder items and if there is one, or if there is one within a range of whatever amount, then deny the use of the Herbalism Knife.
 
I tried to add a new property to PlayerMobile (TileUsed) which is a Point2D type.
When I successfully harvest a tile, its coords are saved inside that variable and a timer starts..so after a certain time (it depends on player's skill value) the coords are deleted from the TileUsed var.
I don't serialize the property (It's not a problem if, after a restart or crash, tiles respawn).

Do You think this is a good solution? Or maybe I should use the Dictionary?
Using timers could lead performance issues?
 
Well you shouldnt store it in PlayerMobile (unless it would be static) and is it just a Point2D or an array? If it is just a variable what happens if you harvest another area? Will it override the previous area?
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back