diff -BbuprN -x '*.o' tbamud-master/src/mud_event.c UnEarthed/src/mud_event.c --- tbamud-master/src/mud_event.c 2026-01-22 12:16:13.773062900 +0000 +++ UnEarthed/src/mud_event.c 2026-01-26 19:36:08.292119900 +0000 @@ -1,9 +1,9 @@ /************************************************************************** -* File: mud_event.c Part of tbaMUD * -* Usage: Handling of the mud event system * -* * -* By Vatiken. Copyright 2012 by Joseph Arnusch * -**************************************************************************/ + * File: mud_event.c Part of tbaMUD * + * Usage: Handling of the mud event system * + * * + * By Vatiken. Copyright 2012 by Joseph Arnusch * + **************************************************************************/ #include "conf.h" #include "sysdep.h" @@ -14,18 +14,24 @@ #include "constants.h" #include "comm.h" /* For access to the game pulse */ #include "mud_event.h" +#include "regen.h" /* The mud_event_index[] is merely a tool for organizing events, and giving * them a "const char *" name to help in potential debugging */ struct mud_event_list mud_event_index[] = { - { "Null" , NULL , -1 }, /* eNULL */ - { "Protocol" , get_protocols , EVENT_DESC }, /* ePROTOCOLS */ - { "Whirlwind" , event_whirlwind, EVENT_CHAR }, /* eWHIRLWIND */ - { "Spell:Darkness",event_countdown, EVENT_ROOM } /* eSPL_DARKNESS */ -}; + + {"Null", NULL, -1}, /* eNULL */ + {"Protocol", get_protocols, EVENT_DESC}, /* ePROTOCOLS */ + {"Whirlwind", event_whirlwind, EVENT_CHAR}, /* eWHIRLWIND */ + {"Spell:Darkness", event_countdown, EVENT_ROOM}, /* eSPL_DARKNESS */ + {"Move Regen", event_move_regen, EVENT_CHAR}, + {"Mana Regen", event_mana_regen, EVENT_CHAR}, + {"Hit Regen", event_hit_regen, EVENT_CHAR} + + }; diff -BbuprN -x '*.o' tbamud-master/src/regen.c UnEarthed/src/regen.c --- tbamud-master/src/regen.c 1970-01-01 01:00:00.000000000 +0100 +++ UnEarthed/src/regen.c 2026-01-26 19:36:08.293118500 +0000 @@ -0,0 +1,208 @@ +/* ************************************************************************ + * File: regen.c * + * * + * Usage: Contains routines to handle event based point regeneration * + * * + * Written by Eric Green (ejg3@cornell.edu) * + ************************************************************************ */ + +#include "conf.h" +#include "sysdep.h" +#include "structs.h" +#include "utils.h" +#include "spells.h" +#include "comm.h" +#include "handler.h" +#include "dg_event.h" +#include "mud_event.h" +#include "regen.h" + +extern void update_pos(struct char_data *victim); + +EVENTFUNC(event_move_regen) +{ + struct char_data *ch; + struct mud_event_data *pMudEvent; + int gain; + + /* This is just a dummy check, but we'll do it anyway */ + if (event_obj == NULL) + return 0; + + /* For the sake of simplicity, we will place the event data in easily + * referenced pointers */ + pMudEvent = (struct mud_event_data *)event_obj; + ch = (struct char_data *)pMudEvent->pStruct; + + if (!ch) + return 0; + + /* Character gone or invalid → stop */ + if (IS_NPC(ch) || !ch->desc) + return 0; + + /* Regen logic */ + + if (GET_MOVE(ch) < GET_MAX_MOVE(ch)) + { + GET_MOVE(ch) = MIN(GET_MAX_MOVE(ch), GET_MOVE(ch) + 1); + } + + if (GET_MOVE(ch) >= GET_MAX_MOVE(ch)) + return 0; + + /* Requeue: */ + gain = move_gain(ch); + return (PULSES_PER_MUD_HOUR / (gain ? gain : 1)); +} + +EVENTFUNC(event_mana_regen) +{ + struct char_data *ch; + struct mud_event_data *pMudEvent; + int gain; + + if (!event_obj) + return 0; + + pMudEvent = (struct mud_event_data *)event_obj; + ch = (struct char_data *)pMudEvent->pStruct; + + if (!ch) + return 0; + + if (IS_NPC(ch) || !ch->desc) + return 0; + + if (GET_MANA(ch) < GET_MAX_MANA(ch)) + GET_MANA(ch) = MIN(GET_MAX_MANA(ch), GET_MANA(ch) + 1); + + if (GET_MANA(ch) >= GET_MAX_MANA(ch)) + return 0; + + gain = mana_gain(ch); + return (PULSES_PER_MUD_HOUR / (gain ? gain : 1)); +} + +EVENTFUNC(event_hit_regen) +{ + struct char_data *ch; + struct mud_event_data *pMudEvent; + int gain; + + if (!event_obj) + return 0; + + pMudEvent = (struct mud_event_data *)event_obj; + ch = (struct char_data *)pMudEvent->pStruct; + + if (!ch) + return 0; + + if (GET_HIT(ch) < GET_MAX_HIT(ch)) + GET_HIT(ch) = MIN(GET_MAX_HIT(ch), GET_HIT(ch) + 1); + + if (GET_HIT(ch) >= GET_MAX_HIT(ch)) + return 0; + + gain = hit_gain(ch); + return (PULSES_PER_MUD_HOUR / (gain ? gain : 1)); +} + + + +/* + * subtracts amount of moves from ch's current and starts points event + */ +void alter_move(struct char_data *ch, int amount) +{ + int gain; + + if (!ch) + return; + + /* Deduct move safely */ + GET_MOVE(ch) = MAX(0, GET_MOVE(ch) - amount); + + /* Queue regen if not already running */ + if (!char_has_mud_event(ch, eMOVE_REGEN)) + { + gain = move_gain(ch); + NEW_EVENT(eMOVE_REGEN, ch, NULL, (PULSES_PER_MUD_HOUR / (gain ? gain : 1))); + } +} + +void alter_mana(struct char_data *ch, int amount) +{ + int gain; + + if (!ch) + return; + + GET_MANA(ch) = MAX(0, GET_MANA(ch) - amount); + + if (!char_has_mud_event(ch, eMANA_REGEN)) + { + gain = mana_gain(ch); + NEW_EVENT(eMANA_REGEN, ch, NULL, + (PULSES_PER_MUD_HOUR / (gain ? gain : 1))); + } +} + +void alter_hit(struct char_data *ch, int amount) +{ + int gain; + + if (!ch) + return; + + GET_HIT(ch) = MIN(GET_HIT(ch) - amount, GET_MAX_HIT(ch)); + + update_pos(ch); + + if (!char_has_mud_event(ch, eHIT_REGEN)) + { + gain = hit_gain(ch); + NEW_EVENT(eHIT_REGEN, ch, NULL, + (PULSES_PER_MUD_HOUR / (gain ? gain : 1))); + } +} + + + +/* updates regen rates. Use when big regen rate changes are made */ +void check_regen_rates(struct char_data *ch) +{ + int gain; + + if (!ch) + return; + + if (GET_HIT(ch) < GET_MAX_HIT(ch)) + { + if (!char_has_mud_event(ch, eHIT_REGEN)) + { + gain = hit_gain(ch); + NEW_EVENT(eHIT_REGEN, ch, NULL, (PULSES_PER_MUD_HOUR / (gain ? gain : 1))); + } + } + + if (GET_MANA(ch) < GET_MAX_MANA(ch)) + { + if (!char_has_mud_event(ch, eMANA_REGEN)) + { + gain = mana_gain(ch); + NEW_EVENT(eMANA_REGEN, ch, NULL, (PULSES_PER_MUD_HOUR / (gain ? gain : 1))); + } + } + + + if (GET_MOVE(ch) < GET_MAX_MOVE(ch)) + { + if (!char_has_mud_event(ch, eMOVE_REGEN)) + { + gain = move_gain(ch); + NEW_EVENT(eMOVE_REGEN, ch, NULL, (PULSES_PER_MUD_HOUR / (gain ? gain : 1))); + } + } +} diff -BbuprN -x '*.o' tbamud-master/src/regen.h UnEarthed/src/regen.h --- tbamud-master/src/regen.h 1970-01-01 01:00:00.000000000 +0100 +++ UnEarthed/src/regen.h 2026-01-26 19:36:08.293118500 +0000 @@ -0,0 +1,16 @@ +#ifndef _REGEN_H_ +#define _REGEN_H_ + +#include "dg_event.h" + +EVENTFUNC(event_move_regen); +EVENTFUNC(event_mana_regen); +EVENTFUNC(event_hit_regen); + +extern void check_regen_rates(struct char_data *ch); +extern void alter_move(struct char_data *ch, int amount); +extern void alter_mana(struct char_data *ch, int amount); +extern void alter_hit(struct char_data *ch, int amount); + + +#endif /* _REGEN_H_ */