enum events

NOTICE: This forum is archived as read only.
Please use the Github Discussions at https://github.com/exult/exult/discussions
Forum rules
NOTICE: This forum is archived as read only.
Please use the Github Discussions at https://github.com/exult/exult/discussions
Locked
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

enum events

Post by Donfrow »

Hey,

Looking through some of the TFL code you have the enum events for things like double clicking, readied, scripted, etc. I'm curious where you actually got these values from. Is this documented somewhere?

The reason I ask is I am hoping there is a way to differentiate between a double click when not in combat and a double click when in combat. Is there a way to do that using the above or is it all based on the schedule type that the Avatar is in when double clicking, ie in combat vs follow avatar.

Thanks
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: enum events

Post by marzo »

The referred enum in TFL/Keyring/Q&I and SI Fixes was compiled by Alun Bestor from the values defined in the Exult source; the values in the Exult, in turn, are reverse-engineered from the usecode of the original games. These values can't be changed, and will always have those values in all cases. (but note that usecode can call usecode with any event, so you could re-use some values for other purposes).

The only way to differentiate between double-click in-combat and out-of-combat is only possible by checking the NPC's (or Avatar's) schedule, as appropriate.
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: enum events

Post by Donfrow »

Thanks.

Is the list that you have in above mentioned mods the full list or are there other values that are not present as you had no use for them?
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: enum events

Post by marzo »

Except for custom usecode, events 0-9 are the only event values generated by Exult; so yes, the list is complete (overcomplete, in fact). Note that event 8 is never generated by Exult except for custom usecode -- judging by its usecode, it seems that SI used it for polymorph when loading a game (but Exult does polymorph a lot better than SI did, and doesn't need it).
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Malignant Manor
Site Admin
Posts: 985
Joined: Thu May 14, 2020 1:34 pm

Re: enum events

Post by Malignant Manor »

Well, I would hardly call the original usecode "custom" since things like the bucket in SI use event 10.
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: enum events

Post by marzo »

Oh, you understood what I meant quite well; but if you want to be pedantic, add events 11 and 14 to the list as they are generated by many set_path_failure calls in SI. But fine, I should have said "usecode to the contrary" instead of "custom usecode".
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Malignant Manor
Site Admin
Posts: 985
Joined: Thu May 14, 2020 1:34 pm

Re: enum events

Post by Malignant Manor »

Sorry for the smart ass response.
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: enum events

Post by Donfrow »

Alright, so the documentation for those values is your code ;)

Thanks!
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: enum events

Post by Donfrow »

I must be missing something with the schedule type for double clicking.

I made a basic NPC as follows:

void NPC object#(0x5cf) ()
{

if(event == DOUBLECLICK)
{
var schedule_type = UI_get_schedule_type(AVATAR);
AVATAR.say(schedule_type);
}

}

Where Avatar is defined as -356.

It will return the value 31 for follow Avatar when not in combat, but if I have Avatar in combat schedule the text never says 0 for the in combat value and the Avatar runs over and starts combat.

I assume this has to do with the scripting for the Avatar running into combat, but I cannot figure out how to get around this (if that is indeed the case). Or do I have another glaringly obvious omission/mistake?
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: enum events

Post by marzo »

Sorry, my bad; the avatar's schedule (as well as that of party members) is always 'follow avatar' (unless you manually change it via cheat screen or via usecode), so that it can't be used to check if the avatar and friends are in combat or not. There is, however, an intrinsic that does the job: UI_in_combat.
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: enum events

Post by Donfrow »

Hmm, I still can't seem to get it to take.

if(UI_in_combat())
{
AVATAR.say("In combat");
}
else
{
AVATAR.say("Out of combat");
}

It works fine when out of combat, however when in combat the Avatar runs up and starts fighting still, never saying the "In combat" message.

However, if I set this on an egg and have the Avatar trigger the egg it does work as expected.

Also, when it does actually take, is using the line:

UI_set_schedule_type(AVATAR, FOLLOW_AVATAR);

The appropriate way to remove the Avatar from combat? It does seem to work but I'm not sure if that's the best way to do it.
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: enum events

Post by marzo »

Ah, I now see what you want, and I know that it will not work. First, an admission of error: when the avatar and party are in combat, their schedule is indeed set to combat. With that out of the way: when you are in combat, double-clicking something will never call the double-click usecode, ever; otherwise, you would always start a conversation with an NPC (or use an object) when you double-clicked him (it) instead of attacking, which would defeat the point of being in combat mode in the first place.
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Malignant Manor
Site Admin
Posts: 985
Joined: Thu May 14, 2020 1:34 pm

Re: enum events

Post by Malignant Manor »

What exactly are you trying to have accomplished with this code? This would help get a solution to whatever situation you intend to remove the party from combat if you haven't already found it.

On a related note, Func08F5 is what is used by the Xenkan Monks in SI to stop the attacking and it sets the party's schedule to follow Avatar and set_opponent to 0. I believe it sets the other npcs's schedules to STANDTHERE (you should use a more appropriate schedule) ,set_opponent = 0, and set_alignment = friendly (should change to neutral for most npcs). (It triggered on death of the monk.)
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: enum events

Post by Donfrow »

Ah alright. Too bad.

What I was actually trying to accomplish is if you are wearing a specific piece of gear you can attack, if not you are removed from combat. If you clicked it outside of combat it would start the usual conversation.

From what I gather from you MM, it may be possible by doing it somewhat backwards by allowing the avatar to kill the NPC thus calling the code in the event == death portion of the usecode of that npc?

In other words, on death of the NPC it called the death event, which actually made the NPC not die and set it to stand there?
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: enum events

Post by marzo »

The death event is only called if the NPC's tournament flag is set; note that this flag also has the effect of making the NPC immortal.
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: enum events

Post by Donfrow »

I think that will allow me to get it done in a rather backwards way.

Essentially I can have the npc have 2 hitpoints with the tournament flag set, and then when they "die" while in tournament I can check if the item is being worn.

If so I can either turn the flag off and up the hitpoints of the npc in question or use the intrinsic UI_kill_npc if I want it to just die instead.

If the item in question is not worn just have the Avatar removed from the combat mode and change the NPC's schedule so it is no longer in combat.
Locked