Login
User Name:

Password:



Register

Forgot your password?
SWFotEFUSS 1.5.4
Author: Various
Submitted by: Samson
SWRFUSS 1.4.4
Author: Various
Submitted by: Samson
SmaugFUSS 1.9.9
Author: Various
Submitted by: Samson
AFKMud 3.0.0
Author: AFKMud Team
Submitted by: Samson
SillyMUD 1.2a
Author: J. Brothers, J. Sievert, et al
Submitted by: Samson
Users Online
Anthropic, DotBot, Amazonbot, Bing

Members: 0
Guests: 48
Stats
Files
Topics
Posts
Members
Newest Member
518
3,814
19,730
592
fetilem

» SmaugMuds » General » Smaug Snippets » Expanding on Alias snippet - ...
Forum Rules | Mark all | Recent Posts

Expanding on Alias snippet - adding system level aliases (works with 1.4a)
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 May 3, 2024 4:59 pm   
Go to the top of the page
Go to the bottom of the page

Gdub
Fledgling
GroupMembers
Posts5
JoinedFeb 24, 2024

 
expands on the existing alias snippet.

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!


Post is unread #2 Sep 15, 2026 11:56 pm   
Go to the top of the page
Go to the bottom of the page

fetilem
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.

Pages:<< prev 1 next >>