Welcome to the Builder Academy

Question Autosplit not working

More
19 Mar 2018 03:06 #7714 by Nero
Autosplit not working was created by Nero
Hi,

For some reason autosplit doesn't work in group if I do not have autoloot on. Whoever loots the coins from the corpse keeps them. The only way I can get it to work is if autoloot is on and it autoloots/autosplits the coins. How do I resolve this? I thought the autoloot code for groups resides in fight.c but I could be wrong.

I honestly don't find it a huge deal because most people will have autoloot on however, there are some zones in this MUD where if you loot the corpse without disabling the traps first by thief, you will die so some people may prefer autoloot to be turned off.

Any help would be appreciated!

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

More
19 Mar 2018 04:07 #7715 by Papaya Pete
Replied by Papaya Pete on topic Autosplit not working
I think autosplit is meant to be used with autoloot, could be wrong. Without having looked at it myself yet (just glancing at the forums and unidling after months of lurking), my first guess is, if you have to make changes in the code, you would have to look at how autosplit and split are handled. In the function for getting objects/coins, when picking up coins have it run a check to see if autosplit is on. From there, run autosplit function. That's the logic I would use and start with, anyways.

I apologize ahead of time for not knowing the exact functions. Can look into it later on if you're still having trouble.

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

More
19 Mar 2018 05:08 #7717 by Nero
Replied by Nero on topic Autosplit not working
Thanks for the quick reply,

The issue I am having is with happyhour specifically. Autogold does seem to autosplit which I am fine with. If the leader, or the person who kills the mob does not have autogold enabled, it will not autosplit the coins when looted. It's not an absolute huge deal. The real issue is when happyhour gold is enabled, it does not split the happy hour gold..it still just continues to split the initial amount of gold that the mob had before the bonus. The person who gets the killing blow on the mob gets the bonus..how do I split the happy hour gold to the group as well?

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

More
19 Mar 2018 05:45 - 19 Mar 2018 05:48 #7718 by Papaya Pete
Replied by Papaya Pete on topic Autosplit not working
Here is where happygold is handled, in fight.c within the int damage() function.
So let's say a mob has 10 gold. When he dies, that is when the happy gold is applied, it seems:
Code:
/* Uh oh. Victim died. */ if (GET_POS(victim) == POS_DEAD) { if (ch != victim && (IS_NPC(victim) || victim->desc)) { if (GROUP(ch)) group_gain(ch, victim); else solo_gain(ch, victim); } if (!IS_NPC(victim)) { mudlog(BRF, LVL_IMMORT, TRUE, "%s killed by %s at %s", GET_NAME(victim), GET_NAME(ch), world[IN_ROOM(victim)].name); if (MOB_FLAGGED(ch, MOB_MEMORY)) forget(ch, victim); } /* Cant determine GET_GOLD on corpse, so do now and store */ if (IS_NPC(victim)) { if ((IS_HAPPYHOUR) && (IS_HAPPYGOLD)) { happy_gold = (long)(GET_GOLD(victim) * (((float)(HAPPY_GOLD))/(float)100)); happy_gold = MAX(0, happy_gold); increase_gold(victim, happy_gold); } local_gold = GET_GOLD(victim); sprintf(local_buf,"%ld", (long)local_gold); } die(victim, ch);

So at this point, the gold is increased if it is a mob that has died.

Now right after that, this occurs (until the end of the int damage() function):
Code:
if (GROUP(ch) && (local_gold > 0) && PRF_FLAGGED(ch, PRF_AUTOSPLIT) ) { generic_find("corpse", FIND_OBJ_ROOM, ch, &tmp_char, &corpse_obj); if (corpse_obj) { do_get(ch, "all.coin corpse", 0, 0); // <------ So we know this works, if all those coins are getting picked up do_split(ch, local_buf, 0, 0); // <------------ Now, why is this not working? Perhaps equal to old gold value, pre-happygold? } /* need to remove the gold from the corpse */ } else if (!IS_NPC(ch) && (ch != victim) && PRF_FLAGGED(ch, PRF_AUTOGOLD)) { do_get(ch, "all.coin corpse", 0, 0); } if (!IS_NPC(ch) && (ch != victim) && PRF_FLAGGED(ch, PRF_AUTOLOOT)) { do_get(ch, "all corpse", 0, 0); } if (IS_NPC(victim) && !IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOSAC)) { do_sac(ch,"corpse",0,0); } return (-1); } return (dam);

So it looks like you don't need autogold or autoloot set at all; if you have autosplit toggled, it will automatically grab all.coins from the corpse and then perform a split. I added in the comments that call those functions for getting those coins and then splitting them. Now, question is, where is local_buf set at?

First, we see local_buf defined at the start of int damage()...
Code:
int damage(struct char_data *ch, struct char_data *victim, int dam, int attacktype) { long local_gold = 0, happy_gold = 0; char local_buf[256]; // <------ Defined here struct char_data *tmp_char; struct obj_data *corpse_obj; if (GET_POS(victim) <= POS_DEAD) {

Then we see it further down, actually at a bit of code already quoted earlier.
Code:
if (IS_NPC(victim)) { if ((IS_HAPPYHOUR) && (IS_HAPPYGOLD)) { happy_gold = (long)(GET_GOLD(victim) * (((float)(HAPPY_GOLD))/(float)100)); happy_gold = MAX(0, happy_gold); increase_gold(victim, happy_gold); } local_gold = GET_GOLD(victim); sprintf(local_buf,"%ld", (long)local_gold); // <--------- used in sprintf }

And then where we see it used within the split() function.

I'm not too familiar with that function and how it works exactly, but looking into that is a very good start! Well, at least, that's where I would look. As for Thomas and Vart, though... I would trust their expertise more than my lack thereof.
Last edit: 19 Mar 2018 05:48 by Papaya Pete. Reason: Formatting. Again.

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

More
19 Mar 2018 07:29 #7719 by Nero
Replied by Nero on topic Autosplit not working
Okay so maybe that is the problem. In fight.c I have this:
Code:
/* Uh oh. Victim died. */ if (GET_POS(victim) == POS_DEAD) { // send_to_char(ch, "DEAD\r\n"); if (ch != victim && (IS_NPC(victim) || victim->desc)) { if (AFF_FLAGGED(ch, AFF_GROUP)) group_gain(ch, victim); else solo_gain(ch, victim); } if (!IS_NPC(victim)) { mudlog(BRF, LVL_IMMORT, TRUE, "%s killed by %s at %s", GET_NAME(victim), GET_NAME(ch), world[IN_ROOM(victim)].name); if (IS_AGGRESSIVE(ch, AGGR_TYPE_MEMORY)) forget(ch, victim); } /* Cant determine GET_GOLD on corpse, so do now and store */ if (IS_NPC(victim)) { if ((IS_HAPPYHOUR) && (IS_HAPPYGOLD)) { happy_gold = (long)(GET_GOLD(victim) * (((float)(HAPPY_GOLD))/(float)100)); happy_gold = MAX(0, happy_gold); } local_gold = GET_GOLD(victim); sprintf(local_buf,"%ld", (long)local_gold); } die(victim, ch, death_msg); switch_to_attack_new_char(ch, NULL); if (AFF_FLAGGED(ch, AFF_GROUP) && (local_gold > 0) && !IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOSPLIT)) { generic_find("corpse", FIND_OBJ_ROOM, ch, &tmp_char, &corpse_obj); if (corpse_obj) { do_get(ch, "all.coin corpse", 0, 0); do_split(ch, local_buf, 0, 0); for (coin_obj = corpse_obj->contains; coin_obj; coin_obj = next_obj) { next_obj = coin_obj->next_content; if (CAN_SEE_OBJ(ch, coin_obj) && isname("coin", coin_obj->name)) extract_obj(coin_obj); } } /* need to remove the gold from the corpse */ } else if (!IS_NPC(ch) && (ch != victim) && PRF_FLAGGED(ch, PRF_AUTOGOLD)) { do_get(ch, "all.coin corpse", 0, 0); } if (!IS_NPC(ch) && (ch != victim) && PRF_FLAGGED(ch, PRF_AUTOLOOT)) { do_get(ch, "all corpse", 0, 0); } if (IS_NPC(victim) && !IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOSAC)) { do_sac(ch,"corpse",0,0); } return (-1); } return (dam); }

As you can see, I do not have increase_gold(victim, happy_gold); which may be my problem.
But when I try to use that - I get this error when trying to compile:
fight.o: In function `damage':
/cygdrive/e/apoc/cwe/src/fight.c:1200: undefined reference to `_increase_gold'

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

More
19 Mar 2018 18:10 #7720 by Papaya Pete
Replied by Papaya Pete on topic Autosplit not working
Interesting... I did a little bit of searching. The increase_gold function is found in limits.c; take a look over there and see if you can find it?

It should look like this (added in decrease_gold as well):

Code:
/* Note: amt may be negative */ int increase_gold(struct char_data *ch, int amt) { int curr_gold; curr_gold = GET_GOLD(ch); if (amt < 0) { GET_GOLD(ch) = MAX(0, curr_gold+amt); /* Validate to prevent overflow */ if (GET_GOLD(ch) > curr_gold) GET_GOLD(ch) = 0; } else { GET_GOLD(ch) = MIN(MAX_GOLD, curr_gold+amt); /* Validate to prevent overflow */ if (GET_GOLD(ch) < curr_gold) GET_GOLD(ch) = MAX_GOLD; } if (GET_GOLD(ch) == MAX_GOLD) send_to_char(ch, "%sYou have reached the maximum gold!\r\n%sYou must spend it or bank it before you can gain any more.\r\n", QBRED, QNRM); return (GET_GOLD(ch)); } int decrease_gold(struct char_data *ch, int deduction) { int amt; amt = (deduction * -1); increase_gold(ch, amt); return (GET_GOLD(ch)); }

If this function is there, then for some reason fight.c doesn't have access to it.

Ahhh... here we are. Open up utils.h and take a look there for the following:
Code:
/* in limits.c */ int mana_gain(struct char_data *ch); int hit_gain(struct char_data *ch); int move_gain(struct char_data *ch); void set_title(struct char_data *ch, char *title); void gain_exp(struct char_data *ch, int gain); void gain_exp_regardless(struct char_data *ch, int gain); void gain_condition(struct char_data *ch, int condition, int value); void point_update(void); void update_pos(struct char_data *victim); void run_autowiz(void); int increase_gold(struct char_data *ch, int amt); //<----------------- int decrease_gold(struct char_data *ch, int amt); int increase_bank(struct char_data *ch, int amt); int decrease_bank(struct char_data *ch, int amt);

Up at the top of fight.c, utils.h should be listed among the files <include>d. If that line in utils.h isn't there, add it in. Seems rather odd to be missing that, however; are you using an older version of circle/tbaMUD?

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

Time to create page: 0.196 seconds