Login
User Name:

Password:



Register

Forgot your password?
Create a tag/flag and store values in it?
Jun 19, 2024 10:24 pm
By finekite
IMC??
Jun 14, 2024 11:39 pm
By Samson
Any Smaug muds running?
Jun 1, 2024 1:47 pm
By Zedethar
Any Chances at making a new Mud
Jun 1, 2024 1:42 pm
By Zedethar
delete this?>
May 30, 2024 7:38 pm
By Elwood
do_owhere recursive
Author: Khonsu
Submitted by: Khonsu
Changes list / Addchange
Author: Khonsu
Submitted by: Khonsu
6Dragons mp3 sound pack
Author: Vladaar
Submitted by: Vladaar
AFKMud 2.2.3
Author: AFKMud Team
Submitted by: Samson
SWFOTEFUSS 1.5
Author: Various
Submitted by: Samson
Users Online
CommonCrawl, AhrefsBot

Members: 0
Guests: 14
Stats
Files
Topics
Posts
Members
Newest Member
489
3,797
19,655
603
LouveniaU5

Today's Birthdays
There are no member birthdays today.
» 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
Posts4
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!


Pages:<< prev 1 next >>