Remort - return to level 1, with some tweaks. Increased mana move hits currently this function works fine.
Trying to add a function to give skills to a character that are not in their class list.
Found that answer. I have it working that far now.
I knew it could be done. Was mainly getting practice and list_skill to show the actual skills a character had.
Code:
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "handler.h"
#include "db.h"
#include "remort.h"
#include "spells.h"
extern const char *class_menu;
int parse_class(char arg);
void do_remort_start(struct char_data *ch);
/* Remort snippet bramage */
ACMD(do_remort) {
char arg[MAX_STRING_LENGTH];
char buf[MAX_INPUT_LENGTH];
if(GET_LEVEL(ch) < 51 || GET_LEVEL(ch) > 51){
send_to_char(ch, "You cannot remort at this time!");
return;
}
one_argument(argument, arg);
if(GET_REMORT_LEVEL(ch) < 20) {
switch(*arg)
{
case 'n':
case 'N':
send_to_char(ch, "\r\nYour not going to remort at this time.");
send_to_char(ch, "\r\nThe immortals have allowed you to stay at your level");
break;
case 'y':
case 'Y':
send_to_char(ch, "\r\nCongrulations!");
send_to_char(ch, "\r\nYou have decided to remort!");
send_to_char(ch, "\r\nYou are now leaving you old body, to start a new!");
send_to_char(ch, "\r\nA new journey has begun for you!\r\n");
GET_LEVEL(ch) = 1;
log("DEBUG: Setting remort level for %s to %d", GET_NAME(ch), GET_REMORT_LEVEL(ch) + 1);
GET_REMORT_LEVEL(ch) = GET_REMORT_LEVEL(ch) + 1;
if (GET_REMORT_LEVEL(ch) == 1)
ch->points.max_hit = 100 + (GET_REMORT_LEVEL(ch) * 50);
ch->points.max_mana = 100 + (GET_REMORT_LEVEL(ch) * 50);
ch->points.max_move = 100 + (GET_REMORT_LEVEL(ch) * 50);
ch->points.hit = 100;
ch->points.mana = 100;
ch->points.move = 100;
ch->points.exp = 1;
do_remort_start(ch);
log("DEBUG: Saving character %s after remort", GET_NAME(ch));
save_char(ch);
sprintf(buf, "%s has remorted to level 1.", GET_NAME(ch));
/* mudlog(buf, NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE); TEMP REMOVAL */
break;
default:
send_to_char(ch, "\r\n(type: \"remort y\" if u DO OR \"remort n\" if you DON'T!");
send_to_char(ch, "\r\nAre you sure you want to remort: ");
return;
}
} else {
send_to_char(ch, "\r\nYou can't remort anymore!");
send_to_char(ch, "\r\nContact Management if you need help!");
}
}
void do_remort_start(struct char_data *ch) {
int sortpos;
/* Debug: Confirm do_remort_start is called */
log("DEBUG: do_remort_start called for %s (class: %d, remort level: %d)", GET_NAME(ch), GET_CLASS(ch), GET_REMORT_LEVEL(ch));
/* Initialize based on do_start */
set_title(ch, NULL);
GET_LEVEL(ch) = 1;
GET_EXP(ch) = 1;
/* Set stats (minimal, to be adjusted in class.c or elsewhere) */
GET_MAX_HIT(ch) = 100 + (GET_REMORT_LEVEL(ch) * 50);
GET_MAX_MANA(ch) = 100 + (GET_REMORT_LEVEL(ch) * 50);
GET_MAX_MOVE(ch) = 100 + (GET_REMORT_LEVEL(ch) * 50);
GET_HIT(ch) = GET_MAX_HIT(ch);
GET_MANA(ch) = GET_MAX_MANA(ch);
GET_MOVE(ch) = GET_MAX_MOVE(ch);
/* Assign class-specific skills */
switch (GET_CLASS(ch)) {
case CLASS_MAGIC_USER:
break;
case CLASS_CLERIC:
break;
case CLASS_THIEF:
break;
case CLASS_WARRIOR:
SET_SKILL(ch, SKILL_SNEAK, 10); /* Test non-Warrior skill with max proficiency */
SET_SKILL(ch, SPELL_IDENTIFY, 10); /* Test non-Warrior skill with max proficiency */
log("DEBUG: Assigned SNEAK to %s (Warrior): SNEAK=%d, IDENTIFY=%d", GET_NAME(ch), GET_SKILL(ch, SKILL_SNEAK), GET_SKILL(ch, SPELL_IDENTIFY));
break;
case CLASS_BARD:
break;
default:
log("DEBUG: No skills assigned for %s (unknown class: %d)", GET_NAME(ch), GET_CLASS(ch));
break;
}
/* Debug: Verify skills after assignment */
log("DEBUG: Post-assignment skills for %s: SNEAK=%d, IDENTIFY=%d", GET_NAME(ch), GET_SKILL(ch, SKILL_SNEAK), GET_SKILL(ch, SPELL_IDENTIFY));
/* Set conditions (drunk can be 0, no hunger/thirst) */
GET_COND(ch, THIRST) = -1;
GET_COND(ch, HUNGER) = -1;
GET_COND(ch, DRUNK) = 0;
/* Save character with debug */
log("DEBUG: Saving character %s", GET_NAME(ch));
save_char(ch);
log("DEBUG: Save completed for %s", GET_NAME(ch));
/* Debug: Verify skills after save */
log("DEBUG: Post-save skills for %s: SNEAK=%d, IDENTIFY=%d", GET_NAME(ch), GET_SKILL(ch, SKILL_SNEAK), GET_SKILL(ch, SPELL_IDENTIFY));
/* Log completion */
log("DEBUG: do_remort_start completed for %s. Final stats: Level=%d, HP=%d, Mana=%d, Move=%d",
GET_NAME(ch), GET_LEVEL(ch), GET_MAX_HIT(ch), GET_MAX_MANA(ch), GET_MAX_MOVE(ch));
}
Just in my other tinkering I somehow lost the character saving itself. If I log out and back in, I lose the save. Even if I do a SAVE before logging out.