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.