Page 1 of 2

UCC Errors/Issues/Comments/etc.

Posted: Tue Jan 31, 2006 2:13 pm
by Wizardry Dragon
As Dr. Code suggested, here's a thread for UCC and UCC-related problems, errors, issues, and hell even maybe a feature request or two.

What I'm currently wondering is how I assign a usecode to a shape so that when an egg generates a monster of that shape, that the usecode will be attached, such as guards.

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Tue Jan 31, 2006 2:23 pm
by Wizardry Dragon
Also, as an addendum, Ye Olde UCC Docs are now available again at http://lfs.lfhost.com/ucc_doc.txt This is the original version, so not much ^_~

Will get around to adding to it as I tinker around more in usecode.

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Tue Jan 31, 2006 2:36 pm
by marzo
You just write the usecode with the same function # as the shape (if shape #= 1024) to shape X; when you double-click the shape, Exult will execute the correct usecode function for it.

Re: UCC Errors/Issues/Comments/etc.

Posted: Tue Jan 31, 2006 2:54 pm
by Wizardry Dragon
So to ensure Im doing the right thing,

Guard shape#720 ()
{
// stuff here
}

That look good?

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Tue Jan 31, 2006 4:35 pm
by marzo
Put the '720' between parenthesis and you're good to go:

Guard shape#(720) ()
{
// stuff here
}

Re: UCC Errors/Issues/Comments/etc.

Posted: Tue Jan 31, 2006 4:40 pm
by Wizardry Dragon
Ah, I was wondering why it was saying it was expecting ( ... gave entirely the wrong line number, though.

Thanks! ^_^

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Tue Jan 31, 2006 5:50 pm
by drcode
'Course, this means that all guards will execute that usecode when double-clicked. I wonder if we should have a 'monster' egg that also has a usecode # that gets associated with the NPC we create...

Re: UCC Errors/Issues/Comments/etc.

Posted: Tue Jan 31, 2006 5:57 pm
by marzo
Would be good to add that and, at the same time, make monster eggs able to create objects with shape>1023, as both would likely require a special extended egg irreg.

Re: UCC Errors/Issues/Comments/etc.

Posted: Wed Feb 01, 2006 9:49 am
by Wizardry Dragon
On the topic of eggs, Transmap eggs don't seem to work correctly, and normal Teleporter eggs always take me to Map #00.

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Wed Feb 01, 2006 10:09 am
by marzo
On the topic of eggs, Transmap eggs don't seem to work correctly,
Can you be more specific?
and normal Teleporter eggs always take me to Map #00.[/qupte]
Fixed.

Re: UCC Errors/Issues/Comments/etc.

Posted: Wed Feb 01, 2006 11:17 am
by Wizardry Dragon
They seem to take me to the wrong map.

Specifically, I have an egg thats supposed to transport you past the defences of Virtue's Hold into the besieged city that surrounds it, and it takes me to the right location, on a nonexistent map 3. (And yes, I made sure that I was specifying the correct map, 2)

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Wed Feb 01, 2006 12:17 pm
by Wizardry Dragon
Are the protcullis something that I have to handle with a usecode script or is there something Im missing in their construction to make them work without usecode?

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Wed Feb 01, 2006 12:55 pm
by marzo
They already have their own usecode; if you put a winch near a portcullis or drawbridge, and set their qualities equal, they should work together. There is a catch, however: portcullis and winches only work together if you (1) know the Trinsic password (flag 0x3d) AND have used the password at least once (flag 0x57).

Re: UCC Errors/Issues/Comments/etc.

Posted: Wed Feb 01, 2006 1:05 pm
by Wizardry Dragon
Hmm ... I suddenly see a potential problem with adding the Gypsy bit at the introduction. If you need a password to get in and out, then how do you get into Trinsic to begin with? Hmm.

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Wed Feb 01, 2006 1:17 pm
by Wizardry Dragon
Hmm, is there a function to get the map a shape is on?

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Wed Feb 01, 2006 1:42 pm
by marzo
Easy, you get in via Moongate. The way I interpret the encounter with the gypsy at the start of U5 and U6 (and the interpretation is supported by the intro text) is as a recollection of the beginning of the quest of the avatar in U4. You could have the encounter with the gypsy be much like that. My idea was that you start in a different map, near the gypsy's cart and with nowhere else to go really; after talking to her, and doing the test, there is some intro text and the screen goes dark; then, you are back into the normal BG start.
Hmm, is there a function to get the map a shape is on?
obj->get_map_num()

To teleport an object to another map, use the standard functions with a 4-coordinate position vector; the fourth is the map #.

Re: UCC Errors/Issues/Comments/etc.

Posted: Wed Feb 01, 2006 1:49 pm
by marzo
Specifically, I have an egg thats supposed to transport you past the defences of Virtue's Hold into the besieged city that surrounds it, and it takes me to the right location, on a nonexistent map 3. (And yes, I made sure that I was specifying the correct map, 2)
Just out of curiosity: in stdout, there should be a line beginning with "Should teleport to map ". Can you confirm that the line lists the correct/wrong map # and coordinates?

Re: UCC Errors/Issues/Comments/etc.

Posted: Wed Feb 01, 2006 1:51 pm
by Wizardry Dragon
I was actually wondering because the guard script above would be slightly different between Britannia and the Lands of the Feudal Lords.

So, ...

var map_num;

map_num = obj->get_map_num();

if (map_num == 0) then
{
//Britannia convo
}

else if (map_num == 1) then
{
//TFL convo
}

else
{
//fallthrough case
}

Would that work? (Could item->get_map_num() work as well?)

As well, how can I display a face not attached to a NPC (the guard in this case) in a conversation?

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Wed Feb 01, 2006 2:00 pm
by marzo
I should have been clearer; by 'obj' I meant any NPC number or reference or object reference. For example:

const int AVATAR = -356;

//Get avatar's map; any of these work:
AVATAR->get_map_num();
(AVATAR->get_npc_object())->get_map_num();
UI_get_avatar_ref()->get_map_num();

//To get the map # for item:
get_map_num();
item->get_map_num(); //Equivalent to the above line


Thus, if 'item' refers to the guard in the above example, you can simply use

map_num = get_map_num();

Other than that, the example works as long as 'obj' is a reference to an object or NPC.

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 3:15 am
by marzo
Specifically, I have an egg thats supposed to transport you past the defences of Virtue's Hold into the besieged city that surrounds it, and it takes me to the right location, on a nonexistent map 3. (And yes, I made sure that I was specifying the correct map, 2)
I just had an idea about a possible source for the problem, which I want to confirm with you. The map numbers are zero-based -- the default map is #0, the second map is #1, the third map is #2 and so on; did you specify map # 2 because you wanted the teleport to take the avatar to the second map or do you really have a third map to which the avatar should be taken?

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 8:18 am
by Wizardry Dragon
I have
map #00 - Britannia
map #01 - Keyring mod miscellania
map #02 - The Lands of the Feudal Lords

Its going from a position on map #02 to another position on map #02.

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 8:36 am
by marzo
I am asking because I have been unable to reproduce it here; both intermap and teleport eggs are working as they should (with the fix for the normal teleport eggs, of course)...

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 8:39 am
by Wizardry Dragon
Im unsure either. I have other intermap eggs that work properly, just not that one. Its most odd.

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 8:49 am
by drcode
Just added a ucc feature long-ago suggested by Ryan (Colourless). Previously, ucc defaulted to Blackgate intrinsics unless you passed it the "-s" option, in which case it used Serpent Isle. Now you can specify at the top of your source file which one you want:
#game "blackgate"
#game "serpentisle"

If you don't, it will still default to Blackgate, but you'll get a warning.

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 8:50 am
by Wizardry Dragon
Don't suppose you can specify both? ^_~

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 8:53 am
by Dominus
btw, seems Kirben is again taking care to update the tools snapshot when needed. (Thanks Kirben!)

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 8:55 am
by Wizardry Dragon
Okay, so Im at a loss to whats wrong with this script ... can someone tell me why its giving me this error?

npcs/maihanna.uc:86: 'including' not declared
npcs/maihanna.uc:86: parse error, expecting `')''

************

/*
* This source file contains usecode for the Feudal Lands.

* Specifically, this is the conversation for the Maihanna.
*

* Author: Peter Dodge
* Last Modified: 2006-01-29
*/
Maihanna 0x529 ()
{
var bark;
var answers;

if (UI_get_schedule_type(item) == 14)
{
UI_item_say(item, "@...ZZzzZZZzzZ...@");
return;
}

if (event == 0)
{
bark = UI_get_random(3);
if (bark == 1)
UI_item_say(item, "@Dum dee dum@");
else if (bark == 2)
UI_item_say(item, "@Ho hum@");
else
UI_item_say(item, "@Looks like rain...@");
return;
}

answers = ["name", "job"];

if (UI_get_item_flag(item, 28)) // 28 == is_met)
{
item.say("Maya smiles widely. @Back to test the Gragoyles again?@");
}
else
{
item.say("This black-haired woman is armed from foot to toe, and scarred significantly on the exposed parts of her arms and legs.");
UI_set_item_flag(item, 28, true);
}

converse([answers, "bye"])
{
case "bye":
say("@Fare thee well,@ she says with a bow.");
break;

case "name":
say("She bows deeply. @Maihanna, at thy service. Thou canst call me Maya.@");

case "job":
say("@I am the keeper of the Shrine of Valor.@");
add("Shrine");
add("Valor");

case "Shrine" (remove):
say("@The Shrine of Valor lies in the hands of the gargoyles, so my only duty is to guard the portal in my home that lies in my house.");
say("If thou doth seek to meditate in the Shrine, then I offer thee this advice: do not. The gargoyle attacks are too frequent.");
say("And even then, thou wouldst still need the Rune and the Mantra.@");
add("portal");
add("Rune");
add("Mantra");

case "portal" (remove):
say("@Should thou wish to test thy Valor, thou canst enter the portal in my house entryway. It shall take thee right to the Shrine.");
say("Be careful - the Shrine is a fair distance away from the beachhead, and only a token handful of guards keep the Shrine in any semblance of peace.@");
add("beachhead");

case "beachhead" (remove):
say("Maya gives you a quizzical look. @Well, I doth suppose 'beachhead' is not the best term for it. At the foot of the entry gates to Virtue's Hold there is a strong point in the defence.");
say("There the guard have entrenched themselves behind sandbags, and work all the hours of the day and night to ensure it isn't breached.@");
say("You could swear you can see a sparkle of admiration in Maya's eyes.");

case "Rune" (remove):
say("Maya lowers her eyes. @The rune used to be in my possession. It is lost to me now.@");
add("lost?");

case "Mantra" (remove):
say("@If thou canst push back the gargoyles from the Shrine to my satisfaction, I shall tell thee the Mantra. Until then, I shall not.@");

case "lost?" (remove):
say("Maya's usually vibrant tone becomes suddenly subdued. @I didst try to go to the Shrine to reclaim it myself, and I was cast down during that battle. I lost many of my belongings then,");
say(including the Rune.@ She sighs, and almost appears to be holding back tears for a moment.");
say("The only saving graces I suppose art that the guards did not question me about the Rune, and that no one would have use of it until the Shrine wert reclaimed anyways.");

case "Valor" (remove);
say("Maya's eyes light up. @Valor is the courage to stand up for thyself; in battle, in words, both. Valor is the absence of fear and the presence of confidence.");
say("Valor fears naught but fear itself.@");
}
item.hide();
}

(I take no responsibility for Phorum destroying my formatting)

~ Wizardry

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 9:05 am
by marzo
It is missing a double quote in line 86: put a double-quote between the '(' and the word 'including'.

Also, the ' case "Valor" (remove);' is finished with a ';' instead of a ':'.

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 9:07 am
by Wizardry Dragon
Ahh, damn. Kay, definetely no programming before coffee for me. Thanks.

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 10:59 am
by Wizardry Dragon
Here's a stupid question, because I remember having done this before but I cannot remember how: how do I test if someones in the party, and perhaps just as importantly that theyre conscious?

Specifically, I have one scripted sequence where a caster tries to put your party to sleep, but it leaves you and one randomly determined party member awake, and I want to have different reactions based on who it was that survives the spell.

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 11:23 am
by marzo
Using the constants from headers/constants.uc, use this:

npc->get_item_flag(ASLEEP)

npc->get_item_flag(IN_PARTY)

Where 'npc' can be a reference to any NPC (and can be 'item' as well, if it refers to an NPC).

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 11:26 am
by Wizardry Dragon
Would this be correct?

if (get_item_flag(ASLEEP) && get_item_flag(IN_PARTY == true)
{
//witty response
}

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 11:28 am
by marzo
The '== true' is in the wrong place (and you're missing a ')'), but yeah, it is correct. Haven't you gotten coffee yet? :-D

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 11:35 am
by Wizardry Dragon
Im out :'(

So, perhaps to help my caffine deprived brain out, I have

if (get_map_num() == 2)
{
// Iolo's conversation in TFL
}
else
{
IOLO.original();
}

but the if never executes, even on map #02?

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 11:42 am
by marzo
It is probably failing to compile because IOLO is a constant and not a function; replace it with Iolo's function name (extremely likely to be the name of the function the above fragment is in) and try compiling again.

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 11:47 am
by Wizardry Dragon
Its not failing to compile, however. It works fine. The 'if' condition is just never executing, it always falls through to the original conversation.

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 12:02 pm
by marzo
Hmmm... The reason I said the above is that I tested it and it failed to compile. When I fixed the error, it worked. Try putting something like a 'IOLO.say("Testing 1, 2, 3")' right before the 'IOLO.original()' and see if it displays in-game.

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 12:08 pm
by Wizardry Dragon
The only error I got is one I had to fix with your gargoyle egg script xD .. and no, he doesnt say the testing bit. Hmm. Here's the whole script, if it helps:

/*
* This source file contains usecode for the Feudal Lands.

* Specifically, this is the FL conversation for Iolo.
*

* Author: Peter Dodge
* Last Modified: 2006-01-29
*/

Iolo 0x401 ()
{
var bark;
var answers;

if (UI_get_schedule_type(item) == 14)
{
UI_item_say(item, "@...ZZzzZZZzzZ....@");
return;
}

if (event == 0)
{
bark = UI_get_random(3);
if (bark == 1)
UI_item_say(item, "@Dum dee dum@");
else if (bark == 2)
UI_item_say(item, "@Looks like rain@");
else if (bark == 3)
UI_item_say(item, "@Ho hum@");
return;
}

if (get_map_num() == 2)
{

answers = ["name", "job"];
item.say("@Yes, my friend?,@ Iolo asks.");

converse([answers, "bye"])
{
case "bye":
say("@'Tis always a pleasure to speak with thee, my friend.@");
break;

case "name":
say("Your friend Iolo snorts. @What, art thou joking, milord? Thou dost not know thine old friend Iolo?@");

case "job":
say("@Why, right now 'tis adventuring with the most legendary of all heroes, the Avatar!@");
add("Avatar");

case "Avatar" (remove):
say("@Why, there is no doubt that -thou- art the Avatar, Xantar. However, in this strange land, the Quest endures. 'Tis most curious.@");
say("Iolo thinks for a moment and adds, @Nonetheless, that doth not mean that thy friend have forgotten thy title!");
say("Still, it's almost nostalgistic travelling in this strange place, where the Questof the Avatar is ongoing. I doth suppose the people need some hope in these dark times.");
add("dark times");

case "dark times" (remove):
say("@Everywhere we doth go there seem to be people suffering from some malady or afflicition, whether 'twould be of the soul or of the enemy. 'Tis deeply troubling.");
say("No doubt thou shalt help put this land back to its rights!@");
}
}
else
{
say("Testing, 1, 2, 3");
Iolo.original(); // original Iolo dialogue
}
item.hide();
}

(Phorum - your code formatting messed up or your money back! TM)

Compiling doesn't throw errors for me.

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 12:20 pm
by marzo
Doesn't throw any errors here in the present form. The dialogue works fine for me; if you add a "item." before the testing line ('say("Testing, 1, 2, 3")'), it displays correctly too.

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 12:21 pm
by Wizardry Dragon
Strange... it doesnt for me? *blink*

Map == 02 should meain if Map is map #002, right? or is that the second map? (#001)

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 12:24 pm
by Wizardry Dragon
I should add that the testing line is working as well, just not the if statement, still.

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 12:25 pm
by marzo
It should mean map #02.

Hmm... is your Exult version up-to-date?

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 12:29 pm
by Wizardry Dragon
It is whatever snapshot version was available this past Monday, so it should be. Its not built from source or anything...

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 12:33 pm
by marzo
I believe that the monday snapshot had it working already; but just in case, try updating Exult to the new version just in case.

Re: UCC Errors/Issues/Comments/etc.

Posted: Thu Feb 02, 2006 12:44 pm
by Wizardry Dragon
Will do, hopefully that fixes it. Mayhaps even the waiter schedule will be fixed :D (well probably not, but I can hope eh?)

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Fri Feb 03, 2006 9:41 am
by drcode
I'm thinking about adding support for usecode-driven schedules... They'd probably need to work like the hard-coded ones in 'schedules.cc'. So it might look like this:

schedule beggar { // "Beggar" schedule. item == NPC.
var state; // Variables for each instance of "Beggar" sched.
var starving;

init() {
// Initialize schedule when NPC first enters it.
state = 0;
starving = 0;
}

now_what() {
// Main code, where you specify what the NPC should do next.
// Might need some new intrinics for this, like for timing:
if (starving) {
say("Please! I haven't eaten in days.");
}
if (random()%3 == 0) {
// Pick random nearby spot and walk to it.
// Is this possible now?
} else
wait(5000); // Wait for 5 secs.
}

ending() {
// Schedule is ending. Use this to clean up, like
// deleting something the NPC was using for the schedule.
}
} // End of schedule code.

It would take a fair amount of work for this, including support within Exult itself.

Re: UCC Errors/Issues/Comments/etc.

Posted: Fri Feb 03, 2006 9:42 am
by Wizardry Dragon
That would be a 20/10 on the cool factor if you could implement it ^_^

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Fri Feb 03, 2006 9:56 am
by marzo
Since this is being discussed: why not change ALL schedules to be usecode schedules? That way, they might be changed for a given specific mod too.

Re: UCC Errors/Issues/Comments/etc.

Posted: Fri Feb 03, 2006 10:02 am
by Wizardry Dragon
That would ba a 40/10 xD

Also, that way when we have complaints about schedules we can change it ourselves ^_~

~ Wizardry Dragon

Re: UCC Errors/Issues/Comments/etc.

Posted: Tue Feb 07, 2006 8:04 am
by Wizardry Dragon
So, a problem I ran into with UCC that I'll crosspost from my own forum in hopes that someone can fix it:

Static variables only seem to retain their value in the scope of the function that changed them.

~ Wizardry Dragon