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 
 My usecode questions
Author: Crowley 
Date:   11-24-09 15:50

I thought I'd make a separate thread for asking about ways to figure out my usecode ambitions, or even if they are possible.

First up is the plan to make a Chaos Sword that acts similar to how it did in Ultima V. At the base is the charmed condition, which seems to accomplish neatly the effect of making a party member attack the rest of the group. However, I was thinking of mixing it up a little. Would it be possible to have the game run an additional check every time combat mode is entered, and only then set the charmed status on the person wielding the sword? That I think would be a more effective and subtle solution that simply make the charmed state last indefinitely as long as someone wields the sword.

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   11-24-09 17:10

Hmm, while I do not see it mentioned in the usecode itself anywhere, would it be possible to make a script that monitors the toggle_combat function?

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   11-27-09 21:00

No comments? Well, now I have a specific sample of usecode and wonderment over why it doesn't work. I have a Skull Key which is supposed to unlock magically locked doors, but it doesn't. Furthermore, the game only exits the targeting mode after I click twice, and I can only get out the second message about not using the key on a door.

void SkullKey shape#(0x400) ()
{
if (event == DOUBLECLICK)
{ UI_close_gumps();
UI_click_on_item();
var target = UI_click_on_item();
var lock_shapes = [SHAPE_DOOR_HORIZONTAL, SHAPE_DOOR_VERTICAL, SHAPE_DOOR2_HORIZONTAL, SHAPE_DOOR2_VERTICAL, SHAPE_CHEST, SHAPE_LOCKED_CHEST];
var target_shape = target->get_item_shape();
if (target_shape in lock_shapes)
{
var target_frame = target->get_item_frame();
if (((target_frame + 1) % 4) == 0)
{
var unlock_frame = (target_frame - 3);
set_item_frame(target, unlock_frame);
return;
}
else
{
avatarBark("@The key doesn't fit.@");
return;
}
}
else
{
randomPartyBark("@There is no lock on that.@");
return;
}
}
}

Reply To This Message
 
 Re: My usecode questions
Author: Marzo Sette Torres Junior 
Date:   11-28-09 00:29

Here is the cleaned up, formatted and corrected code:
void SkullKey shape#(0x400) ()
{
	if (event == DOUBLECLICK)
	{
		UI_close_gumps();
		// This is only needed once:
		// UI_click_on_item();
		var target = UI_click_on_item();
		// This is the case where nothing is clicked:
		if (!target)
		{
			randomPartyBark("@That is the ground, avatar!@");
			return;
		}
		var lock_shapes = [SHAPE_DOOR_HORIZONTAL, SHAPE_DOOR_VERTICAL, SHAPE_DOOR2_HORIZONTAL, SHAPE_DOOR2_VERTICAL, SHAPE_CHEST, SHAPE_LOCKED_CHEST];
		var target_shape = target->get_item_shape();
		if (target_shape in lock_shapes)
		{
			var target_frame = target->get_item_frame();
			if (((target_frame + 1) % 4) == 0)
			{
				var unlock_frame = (target_frame - 3);
				// This is wrong:
				// set_item_frame(target, unlock_frame);
				// It is equivalent to
				// item->set_item_frame(target);
				// This is the correct form:
				target->set_item_frame(unlock_frame);
				// Also correct would be:
				// UI_set_item_frame(target, unlock_frame);
				return;
			}
			else
			{
				avatarBark("@The key doesn't fit.@");
				return;
			}
		}
		else
		{
			randomPartyBark("@There is no lock on that.@");
			return;
		}
	}
}


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

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   11-28-09 00:53

Thank you. That helps me figure things out. There is one oddity left. Using the key on a non-magically locked door or chest with this code doesn't cause the line about key not fitting to show up, or any line at all. However, there was no problem if I simply switch it to randomPartyBark.

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   12-06-09 17:46

All right, next up is the code for the feeding function of my Horn of Plenty. At first it seems to work fine, but something about it breaks the feeding slightly. Afterwards, trying to feed normal food to someone who is above the "hunger threshold" (food level above 24, I believe) still raises the NPC's food level, though it does not consume the food item.

void HornOfPlenty shape#(0x402) ()
{
	if (event == DOUBLECLICK)
	{	
		var target = UI_click_on_item();
		var party = UI_get_party_list();
		if (!target)
		{
			UI_flash_mouse(1);
			return;
		}
		else if (!(target in party))
		{
			UI_flash_mouse(1);
			return;
		}
		else
		{
			var targetfood = (target->get_npc_prop(9));
			if (targetfood > 24)
			{
				target->item_say("@No, thank thee.@");
				return;
			}
			else
			{
				target->set_npc_prop(9, (targetfood + 31));
				target->item_say("@Ahh, I am full now.@");
				return;
			}
		}
	}
}

Reply To This Message
 
 Re: My usecode questions
Author: Marzo Sette Torres Junior 
Date:   12-06-09 18:18

You are overfeeding them enourmously with this line:
target->set_npc_prop(9, (targetfood + 31));

What you want is this:
target->set_npc_prop(9, (31-targetfood));

Your version increases the food level to targetfood+targetfood+31, while the version I gave raises it to 31.

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

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   12-06-09 18:46

Oh yes, I didn't think of doing it that way. It seems that the feeding glitch doesn't have anything to do with my code, but is exists in the original as well (at least when running an unmodded game in Exult). It does seem to be fixed in the Keyring Mod, which I used as comparison and it made me think I had broken something.

Now onwards to try and figure out the infinite reagents behaviour and Chaos Sword. Sadly it seems that toggle_combat cannot be used in usecode.

Reply To This Message
 
 Re: My usecode questions
Author: Malignant Manor 
Date:   12-06-09 20:22

Infinite reagents is currently hard-coded in the engine.

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   12-06-09 20:55

I completely forgot that is already in the game in the form of Wizard Mode in the cheats. I guess the question is then, is infinite reagents hardcoded into the game in a way that custom usecode could be used to toggle it on and off without also enabling the full spellbook and infinite mana?

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   12-06-09 21:06

Alternatively, perhaps the effect could be achieved by making an unopenable container which has 99 of each reagent, and usecode which refills them?

Reply To This Message
 
 Re: My usecode questions
Author: Malignant Manor 
Date:   12-06-09 21:10

It's set to shape 296, frame 3 in SI being worn on a finger spot. It's not in the usecode at all. You'd have to make a text based spell book. It's on Marzo's ever expanding to do list. It's planned to be a frame power setting. It's pretty easy to setup but Marzo planned to dehardcode the entire spellbook as much as easily feasible.

Reply To This Message
 
 Re: My usecode questions
Author: Malignant Manor 
Date:   12-06-09 21:20

A container like that would be 8+ pounds. I'm not sure if the container can refill overtime while in a container but double clicking it would be an easy way to refill it since it wouldn't need refilled very often if at all. If readied it could likely be easily updated over time.

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   12-06-09 21:28

Good thing then that I already intended the Horn of Plenty to be big and heavy. I'll look into what I could do with usecode. Thanks for all the information.

Reply To This Message
 
 Re: My usecode questions
Author: Malignant Manor 
Date:   12-06-09 23:15

One problem I just thought of is how Marzo fixed locked containers to make the contents inaccessible. The spellbook seems to be able to access and detect the reagents (a bug), but I'm not sure that usecode will be able to detect the contents properly to update it. I think the find intrinsics might not return the contents inside a container.

Reply To This Message
 
 Re: My usecode questions
Author: Wizardry Dragon (---.cpe.net.cable.roger)
Date:   12-07-09 04:12

Just use the usecode container and use a script to put reagents in it. The game should search it too.

Wizardry Dragon

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   12-07-09 06:18

I was hoping that the custom usecode for double-clicking would override opening the gump, but that was not meant to be. Perhaps I shall simply wait for Marzo's new code for spells, and hopefully he has made progress in implementing the anti-magic effect as well.

Reply To This Message
 
 Re: My usecode questions
Author: Wizardry Dragon (---.cpe.net.cable.roger)
Date:   12-07-09 07:01

You can freely peruse his spells code in the TFL repository :)

Wizardry Dragon

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   12-07-09 07:42

Ooh, what lovely progress he has made. It would be very nice to eventually have hostile (human) spellcasters who actually do say the incantations and have reagents they have to use. There does not seem to be anything about the consumption of reagents in Marzo's code yet, though.

Reply To This Message
 
 Re: My usecode questions
Author: Wizardry Dragon (---.cpe.net.cable.roger)
Date:   12-07-09 07:46

If I recall correctly, reagents are considered only by the game engine. I'm entirely unsure how difficult it would be to modify the engine to allow usecode to override this behaviour. It certainly wouldn't be hard to destroy the appropriate items in the NPC's inventory.

And TFL already has hostile spellcasters, and not just with the "spell weapon" hack that U7 used. I really need to get my real internet to work enough to commit - Im posting from my iPhone >.>

Wizardry Dragon

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   12-07-09 07:56

Interesting. What about the spellcasting creatures which (at least in my opinion) should skip things like incantations and reagent consumption, like dragons, gazers and reapers?

Reply To This Message
 
 Re: My usecode questions
Author: Wizardry Dragon (---.cpe.net.cable.roger)
Date:   12-07-09 08:01

My spellcasting NPCs - true spellcasting that is - are exceptions. I have not rewritten the base NPC code or taken away the spellcasting "items" from existing NPCs - that would be an awful lot of work for very little "payout".

Instead I simply wrote usecode based on the party companion usecode, to allow my new NPCs to also cast spells intelligently with a spellcasting item.

Wizardry Dragon

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   12-07-09 08:10

I can understand that. Personally I might be crazy enough to do the grunt work of going through every NPC, spawn egg and pre-existing monster in the game and switch things around accordingly.

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   12-07-09 08:11

And I guess you meant to say "cast spells intelligently without a spellcasting item"?

Reply To This Message
 
 Re: My usecode questions
Author: Wizardry Dragon (---.cpe.net.cable.roger)
Date:   12-07-09 08:36

No, actually, in that case I meant spellcasting item as in the context of the specific item that is used as a spellbook item for NPCs, the same shape incidentally as Laurianna's spellbook - it just uses different quality frames for different items.

I do apologise for the mixed terminology though, I'm here in the late night/early morning out of insomnia, and probably aren't making much sense :)

Wizardry Dragon

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   12-07-09 13:46

Gotcha. I guess I'll be waiting for that projected February release then.

Reply To This Message
 
 Re: My usecode questions
Author: Marzo Sette Torres Junior 
Date:   12-07-09 13:49

A few notes: the spellcasting code in Keyring/TFL has a 'spellbook' of sorts which allows NPCs to cast spells. It checks for reagents and mana if the NPC is in party or waiting around; but assumes that the NPC can rest and gather reagents (i.e., cast infinitely many spells) if not in party.

Re: the changes I am making: when they are finished (which won't be for some time, sadly), you will be able to make custom spellbooks, drawn from a pool of 16 spells per circle. Each spellbook can have from 1 to 16 spells per circle, and may come in 'minor caster' (up to circle 4) and 'caster' varieties (all circles); each can be flagged as not requiring mana nor reagents or as being exclusive to the avatar.

Also, there will be items you can flag as being the "ring" of reagents -- they must be equipped, however. I had thought about allowing specially customized reagents which would actually fit perfectly for that cornucopia (i.e., a shape could count as being several reagents), but decided that it was too much work for too little gain.

Finally, there will be a way to force a container to run usecode instead of opening a gump. There were some containers that did this (trapped chests, IIRC), so I decided to allow them for other purposes too.

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

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   12-07-09 15:02

Fair enough, I can live without enemies using reagents. I am mainly interested in the possibilities of implementing an anti-magic effect which affects enemies and an infinite reagents item.

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   12-08-09 15:44

I just had a thought: with new code for spellcasting, couldn't I tie refilling the cornucopia to casting every spell? Preferably to the end after checking the number of reagents and consuming them is done. Now, if only showing the infinity symbol in the spellbook could be separated from wearing a reagent supply, then I could vary the weight of the cornucopia.

Reply To This Message
 
 Re: My usecode questions
Author: Wizardry dragon (24.114.234.---)
Date:   12-08-09 16:13

You'd have to rewrite the usecode handler for spellcasting, but it is possible.

Wizardry dragon

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   12-08-09 17:10

Are you referring to the refilling, infinity symbol display, or both?

Reply To This Message
 
 Re: My usecode questions
Author: Wizardry dragon (24.114.235.---)
Date:   12-08-09 18:07

Specifically, to have the cornocopia refill when you cast a spell, the best approach would be to take marzos implementations of the spells, and add a call to a function that does whatever you want the spell effe t to be (in this case the refilling effect)

In regards to the infinity symbol you could just make a new font and use that one - on of the things I requested Marzo to add to the ucc language was the ability to use different fonts with ui_dispay_gump. If memory serves he did indeed add that functionality.

Wizardry dragon

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   12-08-09 18:11

Regarding spells and refilling, that is precisely what I had in mind.

Reply To This Message
 
 Re: My usecode questions
Author: Marzo Sette Torres Junior 
Date:   12-08-09 18:11

Since -- for NPCs -- the spellcasting code from Keyring/TFL does its own reagent management, you could easily add a check for the cornucopia and don't use reagents. For the avatar, though, it would be trickier.

Re: infinity symbol: you will be able to set one for spellbooks when I finally commit, but it will require a font change. Also, it can't currently be done in BG.

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

Reply To This Message
 
 Re: My usecode questions
Author: Wizardry dragon (24.114.234.---)
Date:   12-08-09 18:29

Haven't I been bothering you for the better part of a year to add that to bg? :p

Wizardry dragon

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   12-08-09 20:38

Now for some of my other questions: Is it possible to trigger a script to run when you enter combat mode or for when you exit it? For example, make a character who has never been in combat before, and the first time it happens he or she freezes, and then vomits once you end combat.

Reply To This Message
 
 Re: My usecode questions
Author: Wizardry dragon (24.114.235.---)
Date:   12-09-09 16:59

There is a usecode function called when you enter combat though I can't recall what number. Just rewrite its functionality and include that.

Wizardry dragon

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   12-09-09 19:48

I guess it would be something like get current schedule, if not in_combat, set schedule to in_combat, otherwise set schedule to follow_avatar?

Reply To This Message
 
 Re: My usecode questions
Author: Marzo Sette Torres Junior 
Date:   12-09-09 20:00

Actually, the only way to detect what you want would be for a script block to "permanently" run periodically checking for combat; there is no other way to trigger an event on a schedule change.

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

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   12-09-09 20:21

All right.

One more thing regarding the cornucopia came to mind. If I go with the "unopenable replenishing container" method, how might I ensure that if the Avatar is carrying both the cornucopia and regular reagents, only reagents from the former are used?

Reply To This Message
 
 Re: My usecode questions
Author: Wizardry Dragon (---.cpe.net.cable.roger)
Date:   12-09-09 23:42

I remember bothering Jeff for an "event" functionality to be incorporated into Exult waaay back when we first got UCC, to trigger usecode off it, but the project had more pressing issue bac then. I'm not sure it would be too difficult to add, just add usecode functions that the Exult engine calls in addition to its normal calls - functions which mod authors could then override.

Wizardry dragon

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   12-09-09 23:45

It would help enormously if I could just set the code to run when toggle_combat is called.

Reply To This Message
 
 Re: My usecode questions
Author: Wizardry dragon (24.114.235.---)
Date:   12-10-09 16:08

I'll see if I can't patch that functionality in though it would be unofficial since Im not a member if the exult team :)

Wizardry dragon

Reply To This Message
 
 Re: My usecode questions
Author: Marzo Sette Torres Junior 
Date:   12-11-09 01:35

If you do, please submit it to the patch tracker for consideration.

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

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   04-29-10 19:37

This isn't strictly usecode-related, but I thought I'd ask it here. I remember some discussion about including the map of Britannia in Serpent Isle and it was mentioned that you couldn't add a different map sprite to be displayed when using it. So, is the use of "slots" in sprites.vga hardcoded so that you can't just add a completely new sprite to be displayed when using something?

Reply To This Message
 
 Re: My usecode questions
Author: Malignant Manor 
Date:   04-30-10 00:46

You can easily include different maps.

Both Games:
UI_display_map_ex(int mapshp, bool show_loc)

SI only:
UI_si_display_map(int num)

Reply To This Message
 
 Re: My usecode questions
Author: Malignant Manor 
Date:   04-30-10 00:56

Those maps still use the same shape though, but it's not like you can't have a huge amount of frames.

Sprite display can use different shapes. Only some things called by the engine are hardcoded.


** All Games **

teleport", 7); // used when npc teleports and attacks with a fire field at the same time
invisible", 12); // used when npc turns invisible
music", 24); //used by play music usecode intrinsic


** BG **

crystalball", 10); // crystal ball sprite called by display area usecode intrinsic (Last I knew this was BG only but that may have changed)

Reply To This Message
 
 Re: My usecode questions
Author: Malignant Manor 
Date:   04-30-10 01:02

Actually, the map uses shape number so there is no hard coding there. There's likely several more hard coded like 2, 3, and 6 for weather.

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   05-10-10 00:54

Now, I'm trying to tie code to when an item is picked up. I figure there must already exist the functionality for that given peoples' reactions to "thievery". It's probably something simple like (event == get_item) or (event == move), but I can't find any mention of that online or in the examples provided.

Reply To This Message
 
 Re: My usecode questions
Author: Malignant Manor 
Date:   05-10-10 04:14

You should be able to use usecode eggs like SI does in the Monitor smith.

In this example, they are Criteria->Something on, Flags->Once-only, probability->100, Distance->1, and the usecode tab contains the function called when triggered plus a Quality setting (I'm unsure of its use offhand). Then place the item on top of the egg.



The normal theft reactions are hard coded in the engine. Exult checks if an item is OKAY_TO_TAKE (flag 11) and you are not IN_DUNGEON (flag 23). If there is a witness, they give out warnings until theft_warnings exceed 2 + rand()%3. Then the person attacks if there are no local guards or calls them if there are available.

Usecode function 0x625 (guard shape is object and doubleclick is event) is used when guards arrive.

// calling guards and attacking a thief messages in exultmsg.txt
0x3c:"Stop, thief!"
0x3d:"Thieving scoundrel!"
0x3e:"Guards! Guards!"

text.flx offsets for theft warnings are 0x6e through 0x70.

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   05-11-10 03:40

Ah, I didn't think of eggs. "Something on" and "once-only" parameters should work for my purposes. I think.

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   11-10-11 16:03

Time to dust this thread off again... I've been trying to implement Chaos Sword's functionality by giving its wielder charmed status. I would prefer to do this when combat mode is entered, but that seems to be beyond my abilities currently. So I settled for trying to make the wielder charmed when attacking with the weapon. Here's the code I have:

void ChaosSword shape#(0x403) ()
{
	if (event == WEAPON)
	{
		var wielder = UI_get_container(ChaosSword);
		wielder->set_item_flag(CHARMED);
		UI_set_attack_mode(wielder, 0);
		return;
	}
}


However, the charmed status does not occur. I tried testing this with just event == READIED also, but that also failed.

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   11-10-11 16:37

Also, how do I make cursor flash "blocked"?

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   05-29-12 18:47

I would still appreciate input to my last couple of questions.

In the meantime, I had the thought of linking using the spellbook to replenishing the contents of the cornucopia. I put together the following code, which... doesn't work.

void SpellBook shape#(0x2f9) ()
{
	if (event == DOUBLECLICK)
	{
		var HornOfPlenty = UI_find_object(PARTY,0x402,QUALITY_ANY,FRAME_ANY);
		HornOfPlenty->remove_cont_items(10,0x34a,QUALITY_ANY,FRAME_ANY);
		HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,0);
		HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,1);
		HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,2);
		HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,3);
		HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,4);
		HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,5);
		HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,6);
		HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,7);
		SpellBook.original();
	}
}

Reply To This Message
 
 Re: My usecode questions
Author: Wizardry Dragon (---.cpe.net.cable.roger)
Date:   05-29-12 19:35

When you say it doesn't work, does it just not do anything, or does it malfunction, or..?

Cheers,
Wizardry Dragon

Reply To This Message
 
 Re: My usecode questions
Author: Marzo Sette Torres Junior 
Date:   05-29-12 21:39

By default, the spellbook does not call usecode; it instead shows a gump. So it not working is expected :-)

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

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   05-30-12 00:24

Oh yes, I had already learned that opening the gump causes the game to ignore usecode associated with the double click. Just didn't make that connection here. Silly me.

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   05-30-12 17:56

I did some testing with how containers work. Take all the reagents, put them into a chest and then change the chest's shape to the locked chest. Stick the chest into the Avatar's hand and try casting a spell. Result: The game does not allow using the reagents inside a locked chest you are carrying.

Next test: Uncheck the "locked" quality from a locked chest. Now the reagents can be used when the chest is in the Avatar's inventory, even though you still cannot actually open the chest. Thus in order to get the functionality I want out of the cornucopia, I should make it a container which has no gump but which is not locked either.

Now, on to the actual code issue. I tried attaching the above code to add reagents into the cornucopia to double-clicking it. Like this:

void HornOfPlenty shape#(0x402) ()
{
	if (event == DOUBLECLICK)
	{	
		HornOfPlenty->remove_cont_items(10,0x34a,QUALITY_ANY,FRAME_ANY);
		HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,0);
		HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,1);
		HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,2);
		HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,3);
		HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,4);
		HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,5);
		HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,6);
		HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,7);
	}
}


I also tried disabling the remove_cont_items part, but that didn't change anything. Speaking of which, what happens if you use that function and tell it to remove more items from a container than it has?

Also, I would still like help with my above Sword of Chaos code and how to make the cursor flash the "blocked" message.

Reply To This Message
 
 Re: My usecode questions
Author: Wizardry Dragon (---.cpe.net.cable.roger)
Date:   05-30-12 21:45

The usecode will fail if the container does not have the item. However if the container selected has containers within it, it should also check those subcontainers. Ie if you tell it to remove something from a pack that has a pouch in it, unless the behaviours change in the past year, it should also check the pouch.

Cheers,
Wizardry Dragon

Reply To This Message
 
 Re: My usecode questions
Author: agentorangeguy (---.27.190.173.dynamic.ip.windstream.net)
Date:   05-31-12 10:55

Crowley, look up the thread where I asked about the storm cloak code. I believe that might help you with your chaos sword, like finding the outside container to give themt he attributes of it. the cursor flashing i remember seeing somewhere in the intrinsics or one of the files... i'll check on that when i get home from work.

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   05-31-12 16:48

Thanks for pointing that out. It worked much better when I used this to denote the wielder:

var wearer = getOuterContainer(item);

Unfortunately, that got me to notice that unlike every other party member, a charmed Avatar will not fight the rest of the party. Dang.

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   05-31-12 17:21

Also, the cornucopia replenishing code worked once I changed HornOfPlenty->add_cont_items to item->add_cont_items. Regarding the remove_cont_items function, it seems to be that if I tell the game to remove 10 items of a type from a container and it has less, it will still remove all of that type from the container.

Reply To This Message
 
 Re: My usecode questions
Author: DominusMobile1 
Date:   05-31-12 17:59

Avatars charmed behaviour is the same as in the original. Users can change this by using the "hard" charmed option in thein game menu.

--
Read the documentation and the FAQ are your friends! There is no excuse for not reading them! RTFM
Read the Rules!
We do not support Piracy/Abandonware/Warez!

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   05-31-12 22:08

Well, I have found a solution to at least one of my problems. While I could not attach refilling the cornucopia to opening spellbook in itself, I can attach it to individual spells. It's fairly simple, just time-consuming since I need to do it separately for all 64 spells which require reagents. For example, cure poison:

void CurePoison object#(0x649) ()
{
	var HornOfPlenty = UI_find_object(PARTY,0x402,QUALITY_ANY,FRAME_ANY);
	HornOfPlenty->remove_cont_items(10,0x34a,QUALITY_ANY,0);
	HornOfPlenty->remove_cont_items(10,0x34a,QUALITY_ANY,1);
	HornOfPlenty->remove_cont_items(10,0x34a,QUALITY_ANY,2);
	HornOfPlenty->remove_cont_items(10,0x34a,QUALITY_ANY,3);
	HornOfPlenty->remove_cont_items(10,0x34a,QUALITY_ANY,4);
	HornOfPlenty->remove_cont_items(10,0x34a,QUALITY_ANY,5);
	HornOfPlenty->remove_cont_items(10,0x34a,QUALITY_ANY,6);
	HornOfPlenty->remove_cont_items(10,0x34a,QUALITY_ANY,7);
	HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,0);
	HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,1);
	HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,2);
	HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,3);
	HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,4);
	HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,5);
	HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,6);
	HornOfPlenty->add_cont_items(10,0x34a,QUALITY_ANY,7);
	CurePoison.original();
}

Reply To This Message
 
 Re: My usecode questions
Author: Wizardry Dragon (---.cpe.net.cable.roger)
Date:   06-01-12 03:03

This could be alleviated somewhat by the idea I floated some years ago about having different action "hooks" available, ie in this case one for 'casts spell'.

As far as UCC goes we've come a HUGE way from when I started obstensibly hacking stuff for the project that would become TFL, but there's still a lot of ways we could improve.

Cheers,
Peter M Dodge
aka Wizardry Dragon

Reply To This Message
 
 Re: My usecode questions
Author: agentorangeguy (---.27.190.173.dynamic.ip.windstream.net)
Date:   06-01-12 16:01

Crowley, I found this in the bg_externals.uc file on the flashing cursor you've been asking about: extern flashBlocked 0x8FD(var cursor);

I guess you could probably just put: flashBlocked(var cursor); and probably just the number of the 'x' cursor in it or something.

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   06-01-12 21:12

I noticed that each spell function runs through function 0x906 (if I remember the number right), which appears to check whether the current weather condition is the anti-magic mist. I did consider linking the cornucopia refill to that as a shortcut, but at least my initial attempt did not work.

Thanks for the information, agenrorangeguy. Marzo's site lists all other cursor flashes except the "blocked" one.

Now, I shall have to take a look at the usecode to see if toggling the combat status is a specific function, so I might link the Chaos Sword to that...

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   06-01-12 23:04

This is a bit odd. I tried searching for the war cries your party makes in combat, but those are nowhere to be found in the decompiled Ultima VII usecode. I tried searching for any functions which contain setting a character's schedule to combat, but those did not help either.

In other news, trying to add to function 0x906 brings up the following error message while compiling:

Function 0x906 already used for 'inMagicStorm' with 0 params.

Is there any way to attach usecode to functions which are already in use by Exult like that?

Reply To This Message
 
 Re: My usecode questions
Author: Wizardry Dragon (---.cpe.net.cable.roger)
Date:   06-02-12 14:51

The combat AI is hardcoded, including battlecries, IIRC. I was looking into this at one point to give gargoyles gargish battlecries but couldn't make any headway as a result.

You can redefine the function, do your stuff, and then do originalFunction.original() to add new content. One caveat: you have to do your stuff first, the caller will also be dropped when the original return()s.

(Unless that behaviour's been changed, I haven't touched UCC in a bit)

Cheers,
Peter M Dodge
aka Wizardry Dragon

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   06-02-12 17:30

I guess I'll wait and hope that those action hooks will some day allow me to have custom usecode triggered by toggling combat. My plan was to have the wielder of the Chaos Sword charmed when combat mode switches on, and pass out when it's switched off. Admittedly it's (at least currently) a lot of work for such a useless item.

I believe I tried redefining the function exactly as you explain, but still got the error message. Like this:

void AntiMagic object#(0x906) ()
{
	<custom stuff here>
	AntiMagic.original();
}


Doing something like that appears to conflict with this line in bg_externals.uc:

extern var inMagicStorm 0x906();

Finally, I tried applying flashBlocked(var cursor); but didn't manage to do anything more with it than as an alternative to UI_flash_mouse(int cursor). I have no idea how the get the "blocked" message out of that.

Reply To This Message
 
 Re: My usecode questions
Author: Wizardry Dragon (---.cpe.net.cable.roger)
Date:   06-02-12 18:10

Yes, when you declare an extern, the way that UC does this, assume it's basically like a php require() statement where it attempts to import the code of the named function wholesale. So essentially you have two definitions of the same function twice in your code, by having both that and your own.

Cheers,
Peter M Dodge
aka Wizardry Dragon

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   06-02-12 19:04

Sorry for being thick, but I still do not understand how to go about in practice solving this conflict of having two definitions for the same function.

Reply To This Message
 
 Re: My usecode questions
Author: Wizardry Dragon (---.cpe.net.cable.roger)
Date:   06-02-12 19:13

It's fine :) As to a fix, try commenting out the extern reference and see if your other function works.

Cheers,
Peter M Dodge
aka Wizardry Dragon

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   06-02-12 23:48

I just found the part of Exult Studio which lists usecode entries, and it shows CombatToggle as 0x6AC. However, attaching my usecode to that does not seem to do anything when the party does combat. Maybe that's for when NPCs enter combat mode or something.

Reply To This Message
 
 Re: My usecode questions
Author: Wizardry Dragon (---.cpe.net.cable.roger)
Date:   06-03-12 00:49

What are you trying to do exactly, re: that? There might be a workaround.

Cheers,
Peter M Dodge
aka Wizardry Dragon

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   06-03-12 02:53

I was hoping to have it work like this: When combat begins, the wielder of the Chaos Sword is charmed. When combat ends, the wielder falls down asleep. That seems like a close enough adaptation of how the sword functioned in Ultima V.

Reply To This Message
 
 Re: My usecode questions
Author: Wizardry Dragon (---.cpe.net.cable.roger)
Date:   06-03-12 02:59

Hmm. I THINK the combat toggle code is hardcoded into the engine, which is why the usecode isnt really doing much. A workaround might be to attach usecode to the avatar/party members to check if it's equipped on occassion. That would involve a lot of overhead however. I'm not sure, other than that. Marzo may have a better solution.

Cheers,
Peter M Dodge
aka Wizardry Dragon

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   06-03-12 15:38

I did consider implementing this by a constantly running code which holds two variables, and runs something like this at each tick:

Variable 2 = Variable 1.
Variable 1 = current schedule of the wielder.
If Variable 1 is "in combat" and Variable 2 is "follow Avatar", then set the wielder to charmed. If vice versa, put the wielder to sleep.

Having that running all the time seems excessive. I guess I could attach it to begin and end on READIED and UNREADIED events with the sword.

Reply To This Message
 
 Re: My usecode questions
Author: Crowley 
Date:   06-20-12 03:53

I got to thinking of disabling the backpack slot for Beh Lem by way of an invisible and immovable item. First, how do you get an item to disappear from the inventory of a character upon death like the NPC spell items do?

Reply To This Message
 
 Re: My usecode questions
Author: Malignant Manor 
Date:   06-20-12 13:20

Could add the following event to the character's usecode.

if (event == DEATH)

Then add removal code. You would then need scripting to restore the item upon resurrection though and resurrection is done through various functions.

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)