Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Sil

Reply
 
Thread Tools Display Modes
Old June 28, 2021, 11:29   #1
Gothmog
Apprentice
 
Join Date: Sep 2016
Posts: 90
Gothmog is on a distinguished road
Need some help with code - specifically adding fire arrows

As far as I can tell I have the ability pretty much finished, however any monster that I have added the flag for the spell to I keep getting the message "A monster tried to cast a spell that has not yet been defined."

I think the problem may be in relation to the execution of the range attack, here is the code that I think is responsible.

Taken from line 1920 of the the melee1.c file
Code:
/*** Execute the ranged attack chosen. ***/	

switch (attack)
	{
		/* RF4_ARROW1, RF4_ARROW2 */
		case 96+0:
		case 96+1:
		case 96+19:
		{
            int dd = (attack == 96+0) ? 1 : 2;

			disturb(1, 0);
			if (spower < 2)
			{
				if (blind) msg_print("You hear a twang.");
				else msg_format("%^s fires an arrow.", m_name);
			}
			else
			{
				if (blind) msg_print("You hear a loud thwang.");
				else msg_format("%^s fires an arrow.", m_name);
			}
			if (spower > 18)
			{
				if (blind) msg_print("You hear a whoosh of fire.");
			else msg_format("%^s fires a flaming arrow.", m_name);
		}


			mon_bolt(m_idx, GF_ARROW, dd, get_sides(attack), -1);

			break;
		}
The "if (spower > 18)" is set so high because pre-existing abilities number 1-18, so I have the flame arrow ability labelled "96+19"

If it's relevant, the code that triggers the display of the message "A monster tried to cast a spell that has not yet been defined." can be found in melee.c line 2247

Code:
		default:
		{
			msg_print("A monster tried to cast a spell that has not yet been defined.");
		}
	}
Any pointer would be appreciated. Thanks

Last edited by Gothmog; June 28, 2021 at 12:18.
Gothmog is offline   Reply With Quote
Old June 28, 2021, 14:05   #2
Nick
Vanilla maintainer
 
Nick's Avatar
 
Join Date: Apr 2007
Location: Canberra, Australia
Age: 56
Posts: 9,167
Donated: $60
Nick will become famous soon enoughNick will become famous soon enough
I'm not very familiar with Sil code, but here are my guesses:
  • The pre-existing ability numbers have nothing to do with spell power. They are listed in defines.h under "Monster racial flags - 'spells'" - you need to add one at the end for fire arrows (there are a bunch of unused ones labelled things like RF4_RF4XXX17). Pick the next unused one, which should correspond to the first number n not used as 96+n in the big switch statement you quoted (n=15 in my copy of the code, but that may be old).
  • You will need to put entries for your new spell in the spell_info_RF4 table in tables.c
My advice would be to search for RF4_ARROW1, and mimic all the things that the code does for that.
__________________
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
Nick is offline   Reply With Quote
Old June 30, 2021, 12:11   #3
Gothmog
Apprentice
 
Join Date: Sep 2016
Posts: 90
Gothmog is on a distinguished road
Thanks Nick! however I've made sure that the new flame arrow is coming up the same amount of times in just as many files as Arrow1, so I know wherever Arrow1 is mentioned Arrow3 (the flame arrows) is also mention in the exact same way.

I'm nearly certain the issue is still in the code from melee1.c above, where the ability is not being "announced" correctly so it's being cancelled and replaced with "A monster tried to cast a spell that has not yet been defined."
Gothmog is offline   Reply With Quote
Old June 30, 2021, 18:04   #4
backwardsEric
Adept
 
Join Date: Aug 2019
Posts: 217
backwardsEric is on a distinguished road
Quote:
Originally Posted by Gothmog View Post
I'm nearly certain the issue is still in the code from melee1.c above, where the ability is not being "announced" correctly so it's being cancelled and replaced with "A monster tried to cast a spell that has not yet been defined."
What's the value of attack in make_attack_ranged() when a fire arrow is attempted? From what you've posted, it's not 115 (96 + 19). Since that value is being selected in melee2.c's choose_ranged_attack() from the monster spell flags, that points to a mismatch between the value of the spell flag for the fire arrow spell and the integer, 96 + 19, you used in make_attack_ranged() for the fire arrow. To match, it looks like the monster spell flag in defines.h for a fire arrow should be 0x80000 (i.e. 1 << 20 to match the rule that the flag is the 1 << (attack - 95)). If the value of the monster spell flag looks correct, then the problem is likely the conversion of the spell string used in monster.txt (i.e. "ARROW1" for RF4_ARROW1) to the spell flag value.
backwardsEric is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Downloading Variants(TOME and Zangband Specifically) edward_rollo Variants 4 June 20, 2016 15:57
Adding terrain to V Therem Harth Development 14 March 22, 2013 22:15
Adding 3 dimensions to a 2D roguelike xibalba Idle chatter 12 February 22, 2012 13:41
Adding a new shop to Angband 3.1.1 Kyle Development 9 October 30, 2010 21:56
Adding Effects to Angband PaulBlay Development 0 March 28, 2009 13:08


All times are GMT +1. The time now is 13:17.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.