PenUltima Online

It is currently Sat Sep 06, 2008 5:04 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Harvest Resource Questions
PostPosted: Tue May 23, 2006 11:47 pm 
Offline

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1127
Location: Southern Central USA
In the POL docs the HarvestResource function is defined as:
Quote:
HarvestResource( resource, x, y, b, n )

Where: resource is a string, x and y are integer world coordinates, b is an integer and n is an integer

Attempts to harvest a resource from a location.
Notes: Harvests a*b resource units, where 0 is less than or equal to 'a' and 'a' is less than or equal to n. Thus you can request 0-40 units in groups of 5, etc.


My question is where is a defined? Is it a random number generated by the core?

I am trying to figure out how to regulate the number of resource units I get from chopping a tree. As I understand it I can change the value for b and that will determine the maximum units harvested per each function call. Now if I want to make the resources run out faster but not give all the resources to the player I can do this:
Code:
var wood_amount -  := HarvestResource( "wood", tree.x, tree.y, 1, 10, me.realm );
wood_amount := CInt(wood_amount/2);


but is there a way to control that on the function call side of the equation? Will changing the value of b affect how many of the actual resources get sent to the player during the whole process of lumberjacking one tree? As it is with a .1 lumberjacking the script will give as many as 70 logs to my player. That seems just a bit high for a .1 skill level.

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 24, 2006 12:19 am 
As I understand that to be written, a is the random number being generated.

You get a*b... b is sent to the function.

a will be >= 0 and <= n. So by setting n, you are setting the range that a will be in. Then it is multiplied by b, and that's your result.

So 0 would be the minimim ((a=0)*b), and n*b would be the max ((a=n)*b)


With that said, I can't say I know for a fact that's how it works. I know our players don't get anything close to 70 logs per chop, though. That said, we don't use the return value from that function to determine how much wood they get...
Code:
      var wood_amount := HarvestResource ("wood", tree.x, tree.y, 1, 8);
      if (!wood_amount)
         SendSysmessage(me, "There's not enough wood here to chop.");
         return 0;
      endif

      var skill := GetEffectiveSkill (me, SKILLID_LUMBERJACKING);
      wood_amount := RandomInt(CINT(skill/33)) + CINT(skill/33) + 1;
      if (!wood_amount)
         wood_amount := 1;
      endif


With this code, they get a reasonable amount, and the tree runs out in a reasonable amount of time. As you can see, though, we don't really use that return value at all, except to see when the tree is all out. Incidentally, the wood.cfg in /regions:

Code:
    UnitsPerArea        50
    SecondsPerRegrow    1800
    Capacity            10000
    Range               0 0 5119 4095


It seems possible that the max 8 value is what is coming out, and that when it hits 50, it's all done for that area, and the player has to move on. I haven't tested it extensively, but I wouldn't be surprised to see it that way, or something close.

Hope this helps!


Top
  
 
 Post subject:
PostPosted: Wed May 24, 2006 12:43 pm 
Offline

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1127
Location: Southern Central USA
Thanks Marilla.

I figured a was a random number but I didn't want to assume. I was/am going to rewrite the chop tree function to give an amount according to skill. Once the player has reached a point they are able to harvest a certain type of log the skill will be used to determine how many "usable" logs they get. I figured that was more logical and more "real world".
*chuckles*

Although how much skill does it take to chop down a tree and cut it into logs IRL?

Then again never having done it maybe there is a skill to it.

Any lumberjacks out there who can answer that for me?


P.S. Might end up "stealing" your equation, Marilla, if the other proves too difficult though. As long as you don't mind.


*winks*

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl