ID:164003
![]() Jul 22 2007, 7:05 am
|
|
I want to know how I would make the player get a random item like from fishing. The player could randomly get Bass, Brim, Trout, and Salmon. How would I do this?
|
![]() Jul 22 2007, 8:40 am
|
|
Here is an example.
|
Revojake wrote:
Here is an example. No, don't do that. Make a list of the possible items that the fisherman might catch: var/list/fishing_results = list("/obj/trout", "/obj/salmon", "/obj/rubberboot", etc...) Now you'll have a new random fish in your contents. If you want some fish to be less likely than others, you might look up Lummox's pickweight() proc, which is posted on one of his BYONDscape articles, but you can probably find it by searching on the forums. [Edit] Look at the bottom of Lummox JR's BYONDscape article on Associative Lists: http://www.byondscape.com/ascape.dmb/LummoxJR.2002-0103/ |
Ok, now how would I make if the player's fishing level was 1, he would only catch shrimp but if the player's fishing level was 5, he could catch shrimp and sardines?
|
basically all u gotta do is create different lists for different levels. and then in the lists, input all the fish the person of that lvl could catch
|
actually his method is easier because you don't have to type up a lot of if statements. Also when you are using random like that use it like this:
mob |
Kakashi24142 wrote:
usr.random = rand(1,4) No need to use a variable with that. switch(rand(1,4))
Works just fine. I agree with Foomer's method though. |
I agree with Foomer's method, but I'm just letting him know that there's a more efficient method if he's gonna use the other way.
|
Ok I understand now but if the player catches a shrimp he/she gets 10 EXP but if the player catches a sardine he/she gets 15 EXP. How would I do that?
|
Restricting which fish you can catch at which level - how you'd do that depends on whether you wanted to use the pickweight() proc to determine how likely each fish is to be caught.
If you don't use pickweight, then just associate each fish type in the list with a value to determine what skill level you must be to catch it. If you DO use pickweight, then you'll need to create a second list with all the fish types and their associated skill levels alongside the list of fish types with their associated probability of catching. I'll assuming that you're not going to use pickweight: var/list/fishing_results = list("/obj/trout"=2, "/obj/salmon"=5, "/obj/rubberboot"=0, etc...) You should be able to do something similar to determine how much experience you get for each fish, however I feel the need to express that I think its ridiculous and stupid to determine how much experience the player gets based on a totally random outcome. So you might randomly get 5 experience or you might randomly get 25? That's dumb. |
Foomer wrote:
You should be able to do something similar to determine how much experience you get for each fish, however I feel the need to express that I think its ridiculous and stupid to determine how much experience the player gets based on a totally random outcome. So you might randomly get 5 experience or you might randomly get 25? That's dumb. Depends on what kind of fishing spot (Net, Pole, etc.) is what kind of fish you get. So if you fish in a Net area, you would catch small fishlike Shrimp and Crawfish. |