Jump to content
Eternal Lands Official Forums
bluap

Patch: New #commands for aliases and user menus

Recommended Posts

In the thread on user menus, we discussed adding some new #commands. These would potentially be useful for the existing alias system and the new user menus I'm working on. I have submitted patch #2754 which adds the following new #commands:

 

#open_url <a url string>

This command simply opens the specified url just like the F2 key and using the URL window.

 

#show_spell

Shows information about the last spell you cast; or a message if there was no previous spell. The spell name and a hex version of the the spell server message are given. For example "Heal 27020317". The information can be used with the new "#cast_spell" command.

 

#cast_spell <anything> 27XXXXXX

This command creates a new server message from the hex bytes given. Everything up until the CAST_SPELL byte (27hex) is ignored. The remaining text is parsed for valid hex bytes. If the message looks valid, it is sent to the server - casting the spell. Note if you try to cast a spell using sigils you do not have, you will be disconnected form the server so be careful if you construct the message by hand. Getting disconnected BTW, is no different than using a quickspell icon for a spell you can cast.

 

The additions were relatively simple so if no one objects and no bugs are found, I'll commit this change in a few days.

 

I have however, already commited a change to the spells code. This fixes a bug whereby spells cast from the quickbar could not be repeated using the repeat spells key; CTRL+R by default.

 

Edit:

These changes have been commited to CVS.

Edited by bluap

Share this post


Link to post
Share on other sites

parsing uppercase hex is broken

 

diff --git a/console.c b/console.c
index cde863b..ec63a90 100644
--- a/console.c
+++ b/console.c
@@ -1075,7 +1075,7 @@ static int command_cast_spell(char *text, int len)
		  else if (d[i] >= 'a' && d[i] <= 'f')
			  d[i] -= 'a'-10;
		  else if (d[i] >= 'A' && d[i] <= 'F')
-				d[i] -= 'F'-10;
+				d[i] -= 'A'-10;
		  else
		  {
			  valid_looking_message = 0;

Share this post


Link to post
Share on other sites
parsing uppercase hex is broken

Broken implies it worked once, which it clearly never did. Thanks for spotting the error, its fixed in CVS now.

Share this post


Link to post
Share on other sites
#cast_spell <anything> 27XXXXXX

Does anyone have a list of the hex codes for spells? I'm sure I've seen a list for most magic spells somewhere but I can't find it. Documenting them somewhere (in this thread) would save a lot of people (including me) the effort of manually collecting them.

Share this post


Link to post
Share on other sites
#cast_spell <anything> 27XXXXXX

Does anyone have a list of the hex codes for spells? I'm sure I've seen a list for most magic spells somewhere but I can't find it. Documenting them somewhere (in this thread) would save a lot of people (including me) the effort of manually collecting them.

This list is derived from the new spells.xml file.

NOTE: if you do not have the sigils to cast a spell but try anyway, the server will disconnect you! Of course the command could check your sigils before casting but why complicate things. The #show_spell was meant to be where the information came from so it was not an issue.

 

Heal||#cast_spell 27020317
Remote Heal||#cast_spell 2703090317
Restoration||#cast_spell 27020118
Heal Summoned||#cast_spell 27040802170e
Teleport to Range||#cast_spell 270407000802
Bones to Gold||#cast_spell 270306000f
Teleport to Portal Room||#cast_spell 270407000902
True Sight||#cast_spell 2703130f14
Intercontinental Teleport||#cast_spell 2703000902
Invisibility||#cast_spell 2703160f14
Poison||#cast_spell 2703050418
Harm||#cast_spell 27021617
Life Drain||#cast_spell 2703070018
Smite Summoned||#cast_spell 270408021618
Mana Drain||#cast_spell 2703070011
Magic Protection||#cast_spell 2703131115
Shield||#cast_spell 2703130f15
Magic Immunity||#cast_spell 270413031115
Heat Shield||#cast_spell 2703130a15
Cold Shield||#cast_spell 2703130b15
Radiation Shield||#cast_spell 2704130f1015

Share this post


Link to post
Share on other sites
#cast_spell <anything> 27XXXXXX

Does anyone have a list of the hex codes for spells? I'm sure I've seen a list for most magic spells somewhere but I can't find it. Documenting them somewhere (in this thread) would save a lot of people (including me) the effort of manually collecting them.

This list is derived from the new spells.xml file.

NOTE: if you do not have the sigils to cast a spell but try anyway, the server will disconnect you! Of course the command could check your sigils before casting but why complicate things. The #show_spell was meant to be where the information came from so it was not an issue.

 

Heal||#cast_spell 27020317
Remote Heal||#cast_spell 2703090317
Restoration||#cast_spell 27020118
Heal Summoned||#cast_spell 27040802170e
Teleport to Range||#cast_spell 270407000802
Bones to Gold||#cast_spell 270306000f
Teleport to Portal Room||#cast_spell 270407000902
True Sight||#cast_spell 2703130f14
Intercontinental Teleport||#cast_spell 2703000902
Invisibility||#cast_spell 2703160f14
Poison||#cast_spell 2703050418
Harm||#cast_spell 27021617
Life Drain||#cast_spell 2703070018
Smite Summoned||#cast_spell 270408021618
Mana Drain||#cast_spell 2703070011
Magic Protection||#cast_spell 2703131115
Shield||#cast_spell 2703130f15
Magic Immunity||#cast_spell 270413031115
Heat Shield||#cast_spell 2703130a15
Cold Shield||#cast_spell 2703130b15
Radiation Shield||#cast_spell 2704130f1015

Looking at this in detail, do NOT allow the 27 to be part of the command to reduce the chances for errors or abuse. Think about what happens if someone uses a different value for the first hex pair!!!

Share this post


Link to post
Share on other sites
...

Looking at this in detail, do NOT allow the 27 to be part of the command to reduce the chances for errors or abuse. Think about what happens if someone uses a different value for the first hex pair!!!

The #cast_spell command already checks that the first number is 0x27. The command will not be used if the 0x27 is not there so I think we are OK.

Edited by bluap

Share this post


Link to post
Share on other sites

Testing the ones I have sigils for:

 

Life Drain - Invalid spell string

 

I wasn't able to verify heat/cold/radiation shield, truesight/invisibility, heal/smite summoned. All the rest complained about missing essence, but I didn't verify it was the right missing essence. :)

Share this post


Link to post
Share on other sites
Life Drain - Invalid spell string
Odd, that works for me.

I figured it out: non input tolerant code. I had a extra space after that one spell. Removed the space and it worked ok.

Share this post


Link to post
Share on other sites
I figured it out: non input tolerant code.

Aka user error. Seriously though, I'll have a look at improving the parsing. :pirate:

OK, sorry I forgot about this but CVS now has more space tolerant parsing. Any space at the end of the string is ignored. For free, you can also have space between hex digit pairs now.

 

I actually came to this thread to report a change to the processing of bool configuration file variables. At the console you can change any config variable using the syntax "%name=value". I've changed the parsing for bool variables so that in addition, "%name=!" toggles the value. This allows a user menu entry or alias to toggle a value rather than having separate on/off entries.

Share this post


Link to post
Share on other sites

is it practical to add ability to comment lines out?

Since Menu can not be structured (multiple levels like a tree) I'd like to be able to comment out unused lines.

 

Double dashes (--) or hash marks (##) would be convenient.

Share this post


Link to post
Share on other sites

is it practical to add ability to comment lines out?

Since Menu can not be structured (multiple levels like a tree) I'd like to be able to comment out unused lines.

 

Double dashes (--) or hash marks (##) would be convenient.

OK, done. Lines that start with ## are now ignored.

Share this post


Link to post
Share on other sites

is it practical to add ability to comment lines out?

Since Menu can not be structured (multiple levels like a tree) I'd like to be able to comment out unused lines.

 

Double dashes (--) or hash marks (##) would be convenient.

OK, done. Lines that start with ## are now ignored.

 

Appreciated. One arm in sling so this will cut down on typing.

When will it be in effect?

Share this post


Link to post
Share on other sites

When will it be in effect?

It's a client change so next client update or now if you build or get hold of a client built from git.

Share this post


Link to post
Share on other sites

I've just added another #command to allow the user menus to do things previously only available with key presses or code changes. The command is #keypress and the parameter is a string of the form used by the keys.ini file. Here are some examples:

Ranging Window||#keypress #K_RANGINGWIN
Mini Map||#keypress #K_MINIMAP
# assuming you have the restore spell as your first and spirit restorations potions in the first inventory slot
Heal & Mana||#keypress #K_SPELL1||#keypress #K_ITEM1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×