Exult Logo
 
Home | Download | Documentation | FAQ | Studio | Screen Shots
Development | Discussion | About Us | Letters | History | Links
 
Exult Discussion
Before posting, make sure you've read the FAQ and searched the message board for previous discussions. When reporting problems/bugs, please include details about your setup (Exult version, OS, sound and video cards).

 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Newer Topic  |  Older Topic 
 scripting question
Author: donttalk2commies (---.localdomain)
Date:   10-16-09 22:50

Hi all,

I'm trying to do some scripting for a mod I am making. I have been fiddling around with one for a mage who will sell spells. In the conversation, I have it set up like the following script:
case "spell":
say("@This spell will cost 30 gold, agreeable?@");
if (askYesNo())
	{
	if (hasGold(30))
		{
		UI_add_spell(5, 0, -761);	  
//random spell and spellbook shape number, i read it is supposed 
//to be negative?		
	chargeGold(30);
	say("After accepting your gold, he teaches you a  spell.");
	                }
							
	else say("@No spellbook on Avatar@");
	}
	else say("@Not enough gold@");		
}
elsel say("Avatar doesn't want spell");


Everything compiles fine on my script. I haven't compiled this particular script since this is just a random example, so I don't give away any details on my mod just yet. When I ask the npc about the spell, it -should- teach the spell, but it does not. I even tried the 'find_object' intrinsic for the spellbook but that doesn't seem to work either. Where did I go wrong?

Reply To This Message
 
 Re: scripting question
Author: Marzo Sette Torres Junior 
Date:   10-17-09 02:56

		UI_add_spell(5, 0, -761);	  
//random spell and spellbook shape number, i read it is supposed 
//to be negative?

The problem is here: negative numbers convert to *npcs*. You are supposed to find the spellbook in the NPC's inventory (e.g., the find_object intrinsic) and use the return of that intrinsic as the spellbook object. For example:
	if (hasGold(30))
	{
		const int AVATAR = -356; // If already defined elsewhere, skip this
		const int QUALITY_ANY = -359; // If already defined elsewhere, skip this
		const int FRAME_ANY = -359; // If already defined elsewhere, skip this

		var spellbook = AVATAR->find_object(761, QUALITY_ANY, FRAME_ANY);
		if (!spellbook)
			say("@No spellbook on Avatar@");
		else if (!UI_add_spell(5, 0, spellbook))
			say("@You already have the spell!@");
		else
		{
			chargeGold(30);
			say("After accepting your gold, he teaches you a  spell.");
		}
	}
	else say("@Not enough gold@");


For more information on intrinsics, please see the intrinsic documentation.

------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
How To Ask Questions The Smart Way

Reply To This Message
 Go to Top  |  Go to Topic  |  Threaded View   Newer Topic  |  Older Topic 


 
 Reply To This Message
 Your Name:
 Your E-mail:
 Subject:
 Subject:
   
 
SourceForge   phorum.org
 
Problems with Exult or this webpage? Contact us.
Last modified: 24 Oct 2001(GMT)