Pages:<< prev 1 next >>
Fledgling

GroupMembers
Posts5
JoinedFeb 24, 2024
expands on the existing alias snippet.
at the top of alias.c - add the following block of code:
in comm.c, inside the nanny function where new characters are created. find this section:
add this new function call above the language checks:
make clean, make smaug and good luck!
at the top of alias.c - add the following block of code:
// system level aliases - based on spells given in class files
// Voodoo - 2024
#define MAX_SYSTEM_ALIASES 6
struct alias_struct
{
char* aliasName;
char* spellName;
};
// Declaration and initialization of _system_aliases
struct alias_struct _system_aliases[MAX_SYSTEM_ALIASES] =
{
{ "crli", "cure light"},
{ "crse", "cure serious"},
{ "stsk", "stone skin"},
{ "bles", "bless"},
{ "cali", "cause light"},
{ "curs", "curse"},
//... add more here
};
void loadSystemAliases(CHAR_DATA* ch)
{
char arg[MAX_INPUT_LENGTH] = "";
char buf[MAX_STRING_LENGTH] = "";
if (!ch)
return; // bad
char* spells[100] = { NULL }; // Initialize array with NULL pointers
int sn = 0;
// loop through class file of character
// make a list of skills
// if any of them match, add an alias
int count = 0;
for (sn = 0; sn < top_sn; sn++)
{
if (skill_table[sn]->skill_level[ch->class] != 0)
{
if (skill_table[sn]->type == SKILL_SPELL)
{
if (ch->pcdata->learned[sn] >= 1)
{
spells[count] = skill_table[sn]->name;
sprintf(buf, "loadSystemAliases. Found %s's %s", ch->name, spells[count]);
to_channel(buf, CHANNEL_MONITOR, "Debug", LEVEL_IMMORTAL);
count++;
}
}
}
}
int size = sizeof(spells) / sizeof(spells[0]); // Assuming spells is the array of spell names
int i = 0;
while (i < size)
{
if (spells != NULL)
{
int j = 0;
while (j < MAX_SYSTEM_ALIASES)
{
if (_system_aliases[j].aliasName != NULL && _system_aliases[j].spellName != NULL)
{
// Debugging output
// sprintf(buf, "spell name: %s, command name: %s", spells, _system_aliases[j].spellName);
// to_channel(buf, CHANNEL_MONITOR, "Debug", LEVEL_IMMORTAL);
// Compare spell name with alias name
if (strcmp(spells, _system_aliases[j].spellName) == 0)
{
// Construct the alias argument
sprintf(arg, "%s cast '%s'", _system_aliases[j].aliasName, _system_aliases[j].spellName);
// Call the do_alias function with the constructed alias argument
do_alias(ch, arg);
,// sprintf(buf, "loadSystemAliases. Making alias: %s.", arg);
// to_channel(buf, CHANNEL_MONITOR, "Debug", LEVEL_IMMORTAL);
}
}
j++;
}
}
i++;
}
}
in comm.c, inside the nanny function where new characters are created. find this section:
if (ch->level == 1)
{
OBJ_DATA* obj;...
add this new function call above the language checks:
loadSystemAliases(ch); // load em up! -Voodoo
if ((iLang = skill_lookup("common"
) < 0)
bug("Nanny: cannot find common language."
;
else
ch->pcdata->learned[iLang] = 100;
make clean, make smaug and good luck!
Fledgling

GroupMembers
Posts1
JoinedSep 15, 2026
Nice addition. I like the idea of generating the aliases automatically from the spells the character actually knows instead of having to configure them manually for each class. heardle
One thing I’d watch is the spells loop: inside the loop it probably needs to reference spells[i] rather than spells, otherwise the comparison is using the array pointer instead of the individual spell name. Other than that, this looks like a handy extension to the existing alias system.
One thing I’d watch is the spells loop: inside the loop it probably needs to reference spells[i] rather than spells, otherwise the comparison is using the array pointer instead of the individual spell name. Other than that, this looks like a handy extension to the existing alias system.
Pages:<< prev 1 next >>