Welcome to the Builder Academy

Idea Ahh my weakness.

More
08 Aug 2013 04:34 - 08 Aug 2013 04:40 #3741 by Liko
Ahh my weakness. was created by Liko
Hello,

So I have defined a new stat variable like hit points called tech and max_tech. Works like mana. Now the only problem I am having is having it save to NPC. I know exactly when I will have problems is when it comes to programming the line saving line



This is a fresh out of the batch 3.64 tbamud.

Note: I know it's not much, but its best way to describe the problem and I live on medication these days.
Code:
fprintf(fd, "%d %d %d %d %d %d %d %d %d E\n" "%d %d %d %dd%d+%d %dd%d+%d\n", MOB_FLAGS(mob)[0], MOB_FLAGS(mob)[1], MOB_FLAGS(mob)[2], MOB_FLAGS(mob)[3], AFF_FLAGS(mob)[0], AFF_FLAGS(mob)[1], AFF_FLAGS(mob)[2], AFF_FLAGS(mob)[3], GET_ALIGNMENT(mob), GET_LEVEL(mob), 20 - GET_HITROLL(mob), GET_AC(mob) / 10, GET_HIT(mob), GET_MANA(mob), GET_MOVE(mob), GET_NDD(mob), GET_SDD(mob), GET_DAMROLL(mob));

Randian(0.0.0)
Owner/Developer
Last edit: 08 Aug 2013 04:40 by Liko.

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

More
08 Aug 2013 04:41 #3742 by Liko
Replied by Liko on topic Ahh my weakness.
What I'm wanting to do is add Tech and Max Tech to be edited on Npcs(which is simple) my problem is it saving.

Randian(0.0.0)
Owner/Developer

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

More
08 Aug 2013 04:51 - 08 Aug 2013 04:54 #3743 by Liko
Replied by Liko on topic Ahh my weakness.
Sorry posting my own replies, but if I added

GENMOB.C
Code:
fprintf(fd, "%d %d\n" "%d %d %d\n", "%d %d\n", GET_GOLD(mob), GET_EXP(mob), GET_POS(mob), GET_DEFAULT_POS(mob), GET_SEX(mob), GET_TECH(mob), GET_MAX_TECH(mob) );

DB.C
Under where sex/default position stuff ends
Code:
if (!get_line(mob_f, line)) { log("SYSERR: Format error in mob #%d, second line after S flag\n" "...expecting line of form '# #', but file ended!", nr); exit(1); } if (sscanf(line, " %d %d ", t, t + 1) != 2) { log("SYSERR: Format error in mob #%d, second line after S flag\n" "...expecting line of form '# #'", nr); exit(1); } GET_TECH(mob_proto + i) = t[0]; GET_MAX_TECH(mob_proto + i) = t[1];

I haven't programmed any of this. This is just me trying to remember if this is how it as to be done. Please chime in :)

Randian(0.0.0)
Owner/Developer
Last edit: 08 Aug 2013 04:54 by Liko.

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

More
09 Aug 2013 02:14 - 09 Aug 2013 02:19 #3752 by Vatiken
Replied by Vatiken on topic Ahh my weakness.
That looks about right but you will have issues loading your current npc files if they dont match up. Id recommend you just add the extra 2 variables to a previously established line and make it conditional. This way it will automatically upgrade any pretech npcs to your current file format. This is an example of how parse_object () handles it.
Code:
   if (!get_line(obj_f, line)) {     log("SYSERR: Expecting third numeric line of %s, but file ended!", buf2);     exit(1);   }  if ((retval = sscanf(line, "%d %d %d %d %d", t, t + 1, t + 2, t + 3, t + 4)) != 5) {    if (retval == 3) {       t[3] = 0;       t[4] = 0;     } else if (retval == 4)       t[4] = 0;     else {       log("SYSERR: Format error in third numeric line (expecting 5 args, got %d), %s", retval, buf2);       exit(1);     }   }   GET_OBJ_WEIGHT(obj_proto + i) = t[0];   GET_OBJ_COST(obj_proto + i) = t[1]; GET_OBJ_RENT(obj_proto + i) = t[2];   GET_OBJ_LEVEL(obj_proto + i) = t[3];   GET_OBJ_TIMER(obj_proto + i) = t[4]; 

tbaMUD developer/programmer
Last edit: 09 Aug 2013 02:19 by Vatiken.

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

More
09 Aug 2013 21:43 - 09 Aug 2013 21:46 #3766 by Liko
Replied by Liko on topic Ahh my weakness.

Vatiken wrote: That looks about right but you will have issues loading your current npc files if they dont match up. Id recommend you just add the extra 2 variables to a previously established line and make it conditional. This way it will automatically upgrade any pretech npcs to your current file format. This is an example of how parse_object () handles it.

Code:
   if (!get_line(obj_f, line)) {     log("SYSERR: Expecting third numeric line of %s, but file ended!", buf2);     exit(1);   }  if ((retval = sscanf(line, "%d %d %d %d %d", t, t + 1, t + 2, t + 3, t + 4)) != 5) {    if (retval == 3) {       t[3] = 0;       t[4] = 0;     } else if (retval == 4)       t[4] = 0;     else {       log("SYSERR: Format error in third numeric line (expecting 5 args, got %d), %s", retval, buf2);       exit(1);     }   }   GET_OBJ_WEIGHT(obj_proto + i) = t[0];   GET_OBJ_COST(obj_proto + i) = t[1]; GET_OBJ_RENT(obj_proto + i) = t[2];   GET_OBJ_LEVEL(obj_proto + i) = t[3];   GET_OBJ_TIMER(obj_proto + i) = t[4]; 


Got it working. I wonder why isn't model for all lines of loading variables. It would make adding stats and other things easier.

Randian(0.0.0)
Owner/Developer
Last edit: 09 Aug 2013 21:46 by Liko.

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

Time to create page: 0.205 seconds