Welcome to the Builder Academy

Question rand_number forage skill

More
22 Mar 2016 13:28 #5645 by JTP
rand_number forage skill was created by JTP
Code:
if(rand_number(1,101) < GET_SKILL(ch, SKILL_FORAGE)) {


Is this what controls how often i will find something ?

If it is, then i found 1 food item in like 300 attempts...how can i improve the chance ?
I tried to use rand_number(1,2) still didnt help

Please Log in or Create an account to join the conversation.

More
22 Mar 2016 13:48 - 22 Mar 2016 14:20 #5646 by Kyle
Replied by Kyle on topic rand_number forage skill
Something else is affecting your chances of success. Please post the full function.

The number 101 is chosen so that whatever your practiced level of SKILL_FORAGE, that is the percentage of times you will succeed.

For reference, here is the implementation of the forage skill from Augmented Dimension (which is not currently run of course). You have my full permission to use it however you see fit. Hope it helps.
Code:
/* VNUMS of food objects that can be found on successful forage */ #define FORAGE_BERRY 20 #define FORAGE_ROOTS 21 #define FORAGE_GREENS 22 #define FORAGE_BARK 23 #define FORAGE_NUTS 24 ACMD(do_forage) { int move_cost = 10; int success; const obj_vnum forage_possibilities[] = { FORAGE_BERRY, FORAGE_ROOTS, FORAGE_GREENS, FORAGE_BARK, FORAGE_NUTS }; const int num_possibilities = sizeof(forage_possibilities)/sizeof(forage_possibilities[0]); int food = rand_number(0, num_possibilities - 1); if (GET_SKILL(ch, SKILL_FORAGE) < rand_number(1, 101)) success = FALSE; else success = TRUE; if (world[IN_ROOM(ch)].sector_type != SECT_FOREST) { send_to_char(ch, "You can only forage in the woods!\r\n"); return; } if (GET_MOVE(ch) < move_cost) { send_to_char(ch, "You are too tired to forage.\r\n"); return; } if (success) { struct obj_data *found = read_object(forage_possibilities[food], VIRTUAL); send_to_char(ch, "You forage and find a %s!\r\n", found->short_description); obj_to_char(found, ch); improve_skill(ch, SKILL_FORAGE); } else send_to_char(ch, "You forage for a while and find nothing.\r\n"); GET_MOVE(ch) -= move_cost; WAIT_STATE(ch, PULSE_VIOLENCE * 2); }
Last edit: 22 Mar 2016 14:20 by Kyle. Reason: added comment for clarification

Please Log in or Create an account to join the conversation.

More
22 Mar 2016 13:50 - 22 Mar 2016 14:04 #5647 by JTP
Replied by JTP on topic rand_number forage skill
Code:
if(rand_number(1,101) < GET_SKILL(ch, SKILL_FORAGE)) { WAIT_STATE(ch, PULSE_VIOLENCE * 2); GET_MOVE(ch) -= (100 - GET_LEVEL(ch)); send_to_char(ch, "\r\nYou have no luck finding anything to eat.\r\n"); return; } else { item_no = foodItems[rand_number(1,sizeof foodItems/sizeof(int) - 1)]; WAIT_STATE( ch, PULSE_VIOLENCE * 2); /* Not really necessary */ GET_MOVE(ch) -= (150 - GET_LEVEL(ch)); item_found = read_object(item_no, VIRTUAL); obj_to_char(item_found, ch); sprintf(buf, "%sYou have found %s!\r\n", buf, item_found->short_description); send_to_char(ch, buf); act("$n has found something in his forage attempt.\r\n", FALSE, ch, 0, 0, TO_ROOM); return; } }
Last edit: 22 Mar 2016 14:04 by JTP.

Please Log in or Create an account to join the conversation.

More
22 Mar 2016 13:51 #5648 by JTP
Replied by JTP on topic rand_number forage skill
never found anything on my imp at all

on a test char with 90 in forage skill i found 1 in 300 attempts

Please Log in or Create an account to join the conversation.

More
22 Mar 2016 13:53 - 22 Mar 2016 13:57 #5649 by Kyle
Replied by Kyle on topic rand_number forage skill
please use code tags. this is very difficult to read. also take a look at the edit i made up above. I posted some code as a reference

EDIT: I copied and pasted your code into an editor and formatted it for myself. The conclusion is there is way too much information missing for me to really help you. I can say the more effort you put into your question, the more help you will get.

If you would like me to help you debug your code, be sure to post both the entire relevant code section, as well as a sample of the test output from the MUD so I can see what is actually happening. Otherwise it is 100 times more difficult for me to figure what is going wrong than it would be if I had access to your code.
Last edit: 22 Mar 2016 13:57 by Kyle.

Please Log in or Create an account to join the conversation.

More
22 Mar 2016 13:54 #5650 by zusuk
Replied by zusuk on topic rand_number forage skill
You have your if-statement checking for a less-than instead of greater-than... just change the '<' to '>'

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100

Please Log in or Create an account to join the conversation.

Time to create page: 0.287 seconds