Welcome to the Builder Academy

Question Percentage Load Patch

More
22 Nov 2016 05:34 - 22 Nov 2016 05:34 #6289 by Halenbane
The Percentage Loading patch that is on the repository went in without much issue and compiled fine. But I feel like there is something missing? Nothing was done to db.c in this patch? Regardless of what I set the % to not load to, it always loads so I feel there is some math missing or part of the patch isn't there.
Last edit: 22 Nov 2016 05:34 by Halenbane. Reason: typo

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

More
22 Nov 2016 19:48 #6290 by thomas
Replied by thomas on topic Percentage Load Patch
I think you're right - that patch seem to be missing something.
This is a snippet from the old oasisolc percentage patch found here: drive.google.com/open?id=0B40XbRH2Qbx5aUwta2tWdmkybHc
Code:
diff -uN src/db.c new-src/db.c --- src/db.c Mon Jan 17 22:36:46 2000 +++ new-src/db.c Thu Jan 20 00:41:22 2000 @@ -1439,7 +1439,7 @@ void load_zones(FILE * fl, char *zonename) { static zone_rnum zone = 0; - int cmd_no, num_of_cmds = 0, line_num = 0, tmp, error; + int cmd_no, num_of_cmds = 0, line_num = 0, tmp, error, arg_num; char *ptr, buf[256], zname[256]; char t1[80], t2[80]; @@ -1506,9 +1506,13 @@ ZCMD.sarg2 = str_dup(t2); } } else { - if (sscanf(ptr, " %d %d %d %d ", &tmp, &ZCMD.arg1, &ZCMD.arg2, - &ZCMD.arg3) != 4) - error = 1; + if ((arg_num = sscanf(ptr, " %d %d %d %d %d ", &tmp, &ZCMD.arg1, &ZCMD.arg2, + &ZCMD.arg3, &ZCMD.arg4)) != 5){ + if (arg_num != 4) + error = 1; + else + ZCMD.arg4 = 0; + } } ZCMD.if_flag = tmp; @@ -1832,47 +1836,61 @@ int room_vnum, room_rnum; struct char_data *tmob=NULL; /* for trigger assignment */ struct obj_data *tobj=NULL; /* for trigger assignment */ + int mob_load = FALSE; /* ### */ + int obj_load = FALSE; /* ### */ + for (cmd_no = 0; ZCMD.command != 'S'; cmd_no++) { - if (ZCMD.if_flag && !last_cmd) + if (ZCMD.if_flag && !last_cmd && !mob_load && !obj_load) continue; + if (!ZCMD.if_flag) { /* ### */ + mob_load = FALSE; + obj_load = FALSE; + } + switch (ZCMD.command) { case '*': /* ignore command */ last_cmd = 0; break; case 'M': /* read a mobile */ - if (mob_index[ZCMD.arg1].number < ZCMD.arg2) { + if ((mob_index[ZCMD.arg1].number < ZCMD.arg2) && + (number(1, 100) >= ZCMD.arg4)) { mob = read_mobile(ZCMD.arg1, REAL); char_to_room(mob, ZCMD.arg3); load_mtrigger(mob); tmob = mob; last_cmd = 1; + mob_load = TRUE; } else last_cmd = 0; break; case 'O': /* read an object */ - if (obj_index[ZCMD.arg1].number < ZCMD.arg2) { + if ((obj_index[ZCMD.arg1].number < ZCMD.arg2) && + (number(1, 100) >= ZCMD.arg4)) { if (ZCMD.arg3 >= 0) { obj = read_object(ZCMD.arg1, REAL); obj_to_room(obj, ZCMD.arg3); load_otrigger(obj); last_cmd = 1; tobj = obj; + obj_load = TRUE; } else { obj = read_object(ZCMD.arg1, REAL); obj->in_room = NOWHERE; last_cmd = 1; + obj_load = TRUE; } } else last_cmd = 0; break; case 'P': /* object to object */ - if (obj_index[ZCMD.arg1].number < ZCMD.arg2) { + if ((obj_index[ZCMD.arg1].number < ZCMD.arg2) && + obj_load && (number(1, 100) >= ZCMD.arg4)) { obj = read_object(ZCMD.arg1, REAL); if (!(obj_to = get_obj_num(ZCMD.arg3))) { ZONE_ERROR("target obj not found, command disabled"); @@ -1893,7 +1911,8 @@ ZCMD.command = '*'; break; } - if (obj_index[ZCMD.arg1].number < ZCMD.arg2) { + if ((obj_index[ZCMD.arg1].number < ZCMD.arg2) && + mob_load && (number(1, 100) >= ZCMD.arg3)) { obj = read_object(ZCMD.arg1, REAL); load_otrigger(obj); tobj = obj; @@ -1909,7 +1928,8 @@ ZCMD.command = '*'; break; } - if (obj_index[ZCMD.arg1].number < ZCMD.arg2) { + if ((obj_index[ZCMD.arg1].number < ZCMD.arg2) && + mob_load && (number(1, 100) >= ZCMD.arg4)) { if (ZCMD.arg3 < 0 || ZCMD.arg3 >= NUM_WEARS) { ZONE_ERROR("invalid equipment pos number"); } else { diff -uN src/db.h new-src/db.h --- src/db.h Fri Nov 26 23:02:54 1999 +++ new-src/db.h Thu Jan 20 00:36:16 2000 @@ -141,6 +141,7 @@ int arg1; /* */ int arg2; /* Arguments to the command */ int arg3; /* */ + int arg4; /* percentages variable */ int line; /* line number this command appears on */ char *sarg1; /* string argument */ char *sarg2; /* string argument */

I can't guarantee it will work as good as the other patch did, but it might just work.

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

More
23 Nov 2016 03:30 #6309 by Halenbane
Replied by Halenbane on topic Percentage Load Patch
I didn't end up using the code above but was certainly able to get some good reference from it. My % loads are now working great :) I will probably work up a snippet / tutorial for it soon.

Thanks!

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

More
23 Nov 2016 04:46 #6310 by Halenbane
Replied by Halenbane on topic Percentage Load Patch
The only other thing I see that I may need help with is multiple items on % loads.
Use the screenshot below for reference..
puu.sh/srvpR/bcb2ab9d95.png
When I put in the 2nd item to load onto the mob, it asked me if I wanted it to be dependent on the previous.
In this instance, I need it to be dependent, but not to the dagger but the bakers loading, just as the dagger is
based on him loading.

Without being confusing, I need to find a way to tell the game if there is more than one item having a chance to load
to a mob, don't base the dependency on another item unless specified. So in the screenshot , Run Command #2 even if #1 doesn't fire, but as long as #0 does.

Does that make any sense?

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

More
23 Nov 2016 04:47 #6311 by Halenbane
Replied by Halenbane on topic Percentage Load Patch
So maybe somehow make it so When you choose the Y/N for the dependency check in zedit, it then asks you which Command List # you want to base that dependency on. Until % loads this was never a problem.

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

More
23 Nov 2016 18:41 - 23 Nov 2016 18:44 #6312 by JTP
Replied by JTP on topic Percentage Load Patch
Sounds great with a tbamud working snippet for procentage load.
Good play test first.
Last edit: 23 Nov 2016 18:44 by JTP.

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

Time to create page: 0.207 seconds