Usecode 'events' functionality
Forum rules
NOTICE: This forum is archived as read only.
Please use the Github Discussions at https://github.com/exult/exult/discussions
NOTICE: This forum is archived as read only.
Please use the Github Discussions at https://github.com/exult/exult/discussions
-
- Posts: 1241
- Joined: Thu May 14, 2020 1:34 pm
Usecode 'events' functionality
As mentioned in Crowley's usecode thread, I think I will make a patch for Exult that will enable the allowance for "events" in usecode.
What I'd like to ask of you is what events in the engine you think would be helpful to be able to trigger usecode on.
Once I have a better idea what people want for that, I'll take a look at the Exult code and see what I can and can't do.
Wizardry dragon
What I'd like to ask of you is what events in the engine you think would be helpful to be able to trigger usecode on.
Once I have a better idea what people want for that, I'll take a look at the Exult code and see what I can and can't do.
Wizardry dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Re: Usecode 'events' functionality
As I mentioned, being able to reference toggle_combat would help my project greatly. Looking through the key bindings, including "useitem " would at least streamline things (specifically it occurred to me that I could tie refilling the cornucopia to opening the spellbook).
-
- Posts: 1241
- Joined: Thu May 14, 2020 1:34 pm
Re: Usecode 'events' functionality
Its probably conceivable to run usecode for any of the keybindings and possible keybindings, but I'm unsure how feasible it would be, ie. if it would slow the engine down by any appreciable degree. Do any others stand out as helpful?
Wizardry dragon
Wizardry dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Re: Usecode 'events' functionality
It's probably one of thsoe times that when you ask about it nothing comes to anyone's mind. Only later will they remember what other uses they thought of
(like being in the supermarket, trying hard to think of what else you need to buy - to only remember the most important thing when you return home)
(like being in the supermarket, trying hard to think of what else you need to buy - to only remember the most important thing when you return home)
--
Read the documentation and the FAQ! There is no excuse for not reading them! RTFM
Read the Rules!
We do not support Piracy/Abandonware/Warez!
Read the documentation and the FAQ! There is no excuse for not reading them! RTFM
Read the Rules!
We do not support Piracy/Abandonware/Warez!
Re: Usecode 'events' functionality
It might help a layman like me to explain a bit what exactly events are, and perhaps give a short list of examples.
-
- Posts: 1241
- Joined: Thu May 14, 2020 1:34 pm
Re: Usecode 'events' functionality
I could conceivably add usecode hooks to any point in the game where something happens in the Exult code, in the game meaning not in the main menu. There are some points where this would obviously be determental, and if there were too many such hooks it could hamper the interpreter on slower systems, so the reason I'm asking here is to get a list of what we want so that I can prioritize what things I'll add.
In this context I'm thinking of events as in "player clicks on item x" "time of day becomes y" sort of things.
Wizardry dragon
In this context I'm thinking of events as in "player clicks on item x" "time of day becomes y" sort of things.
Wizardry dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Re: Usecode 'events' functionality
Those sound like reasonable and useful things. You could have something like the bellringer in U6 announcing hours or roosters crowing at six in the morning for ambiance.
-
- Posts: 1241
- Joined: Thu May 14, 2020 1:34 pm
Re: Usecode 'events' functionality
Okay, here's what I have in my head that I want to ad to or change with UCC:
- Event functions for time of day
- Event functions for click, doubleclick, and schedule changes.
- Support for modules similar to that of Python.
- Builtin functions to determine the existance of BG and SI.
- Builtin functions to manipulate the shape and flex files.
Hopefully I'll be able to do all of this
Wizardry dragon
- Event functions for time of day
- Event functions for click, doubleclick, and schedule changes.
- Support for modules similar to that of Python.
- Builtin functions to determine the existance of BG and SI.
- Builtin functions to manipulate the shape and flex files.
Hopefully I'll be able to do all of this
Wizardry dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
-
- Posts: 384
- Joined: Thu May 14, 2020 1:34 pm
Re: Usecode 'events' functionality
I'm not sure if these are within the scope of what you are doing, due to my lack of knowledge of programming and scripting, but:
-Have checks for portraits to determine time of day and npc location, and then display different portrait frames accordingly (like in the original S.E.)
-Checks or hacks to allow more than 32 npc/pc frames. I have objects that work in E.S. in-game that have up to 90+animation frames, such as flickering torches. At the very least, a check to change shape when certain weapons are equipped, to create new frames for ranged weapons rather than have them be swung. Having characters able to sit on the ground ,indian style, or other ways would be very helpful (for mats and rafts, horse riding, etc.).
-Changes to sleeping so that one party member stands watch, while a fire is built and the other party members camp as well, like in earlier Ultimas. I have frames for logs stacking and the fire starting (W.I.P.)
I'm sure other things will come to mind over time.
-Have checks for portraits to determine time of day and npc location, and then display different portrait frames accordingly (like in the original S.E.)
-Checks or hacks to allow more than 32 npc/pc frames. I have objects that work in E.S. in-game that have up to 90+animation frames, such as flickering torches. At the very least, a check to change shape when certain weapons are equipped, to create new frames for ranged weapons rather than have them be swung. Having characters able to sit on the ground ,indian style, or other ways would be very helpful (for mats and rafts, horse riding, etc.).
-Changes to sleeping so that one party member stands watch, while a fire is built and the other party members camp as well, like in earlier Ultimas. I have frames for logs stacking and the fire starting (W.I.P.)
I'm sure other things will come to mind over time.
Re: Usecode 'events' functionality
That is easily done in usecode.Have checks for portraits to determine time of day and npc location
That would probably be more work than is worth: the bit corresponding to 32 is used for 'rotation' flag (north to west, south to east), which would need to be reworked (current shapes with more than 32 frames do not rotate this way).Checks or hacks to allow more than 32 npc/pc frames.
That can be done with usecode: by ticking the 'usecode events' flag, the weapon will raise usecode events when equipped/unequipped which could set new shapes for the characters in question. Setting adequate weapon-in-hand offsets, and having specially designed frames for the weapons would give the result you want. It would involve a lot of data duplication, though.At the very least, a check to change shape when certain weapons are equipped, to create new frames for ranged weapons rather than have them be swung.
That can be done through usecode.Changes to sleeping so that one party member stands watch
------
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]
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]
-
- Posts: 384
- Joined: Thu May 14, 2020 1:34 pm
Re: Usecode 'events' functionality
Quote:
That is easily done in usecode.
Excellent! When the time comes to create character portraits, I'll create multiple frames with different backgrounds for each character:
-Rainforest portrait (day & night)
-Village portrait (day & night)
-cave portrait
Quote:
That would probably be more work than is worth: the bit corresponding to 32 is used for 'rotation' flag (north to west, south to east), which would need to be reworked (current shapes with more than 32 frames do not rotate this way).
The dilemma is the lack of chairs for certain cultures. The Nahuatla use woven mats, except for the Emperor, who has a throne. The Nahuatla market place was to have merchants kneeling on both knees in front of mats with their goods on them. Perhaps when a mat is double-clicked, the npc/pc could change shape to kneeling, returning to normal shape upon walking away? Plus, I'm not sure how to do the raft. A deed is unrealistic unless an oar acts as a deed, and there would be no chairs on the raft.
Quote:
That can be done with usecode: by ticking the 'usecode events' flag, the weapon will raise usecode events when equipped/unequipped which could set new shapes for the characters in question. Setting adequate weapon-in-hand offsets, and having specially designed frames for the weapons would give the result you want. It would involve a lot of data duplication, though.
I can redraw ranged weapon frames at some point. This option is also good for limited "paperdolling" in-game, such as a hat or backpack. The Avatar could have multiple shapes to depict the wearing or use of various items. Could be a lot of work, but make for a more atmospheric game.
Quote:
That can be done through usecode.
That is good news! I will finish the camp fire when I get back to drawing for Eodon. There should probbaly be checks to make sure all party members have a bedroll in their inventory.
I really like this thinking outside the box with regards to E.S.!!!
That is easily done in usecode.
Excellent! When the time comes to create character portraits, I'll create multiple frames with different backgrounds for each character:
-Rainforest portrait (day & night)
-Village portrait (day & night)
-cave portrait
Quote:
That would probably be more work than is worth: the bit corresponding to 32 is used for 'rotation' flag (north to west, south to east), which would need to be reworked (current shapes with more than 32 frames do not rotate this way).
The dilemma is the lack of chairs for certain cultures. The Nahuatla use woven mats, except for the Emperor, who has a throne. The Nahuatla market place was to have merchants kneeling on both knees in front of mats with their goods on them. Perhaps when a mat is double-clicked, the npc/pc could change shape to kneeling, returning to normal shape upon walking away? Plus, I'm not sure how to do the raft. A deed is unrealistic unless an oar acts as a deed, and there would be no chairs on the raft.
Quote:
That can be done with usecode: by ticking the 'usecode events' flag, the weapon will raise usecode events when equipped/unequipped which could set new shapes for the characters in question. Setting adequate weapon-in-hand offsets, and having specially designed frames for the weapons would give the result you want. It would involve a lot of data duplication, though.
I can redraw ranged weapon frames at some point. This option is also good for limited "paperdolling" in-game, such as a hat or backpack. The Avatar could have multiple shapes to depict the wearing or use of various items. Could be a lot of work, but make for a more atmospheric game.
Quote:
That can be done through usecode.
That is good news! I will finish the camp fire when I get back to drawing for Eodon. There should probbaly be checks to make sure all party members have a bedroll in their inventory.
I really like this thinking outside the box with regards to E.S.!!!
Re: Usecode 'events' functionality
I really need to play SI again to say this for real, but somehow this was doable for the iceraft, so it should work for you as well.Plus, I'm not sure how to do the raft. A deed is unrealistic unless an oar acts as a deed, and there would be no chairs on the raft.
The deed is probably not needed, just a usecode flag, once something happens in your game that sets this flag, your raft is free to use
--
Read the documentation and the FAQ! There is no excuse for not reading them! RTFM
Read the Rules!
We do not support Piracy/Abandonware/Warez!
Read the documentation and the FAQ! There is no excuse for not reading them! RTFM
Read the Rules!
We do not support Piracy/Abandonware/Warez!
-
- Posts: 1241
- Joined: Thu May 14, 2020 1:34 pm
Re: Usecode 'events' functionality
Just make the shape check a usecode flag when clicked on. It's what they do for the ice barge.
Wizardry dragon
Wizardry dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Re: Usecode 'events' functionality
Perhaps finer granularity than time of day: how about on_hour? (onHour, do you guys use camelcase? Oddly enough, I'm never actually looked at the Exult code, though I did give the Avatar Adventures a once-over to see how UU stored its dungeon information)
-
- Posts: 1241
- Joined: Thu May 14, 2020 1:34 pm
Re: Usecode 'events' functionality
Conceivably I could add functions for every hour/minute/etc but this exacting sort of time events would best be handled by a daemon process and not events.
Wizardry dragon
Wizardry dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Re: Usecode 'events' functionality
Now that I read paying some attention:
Anything else would be duplicate functionality for little to no gain: an usecode wrapper for this is exceedingly easy to make.
For all such cases (hour, minutes, ticks) you are better off using standard script blocks on a delay to call back the function -- i.e.,- Event functions for time of day
Code: Select all
script AVATAR after 10 ticks { nohalt; call myFunction; }
Except for schedule changes... you can check the event and re-rout the call. If you really want to make click and double-click separate, I think that changes in UCC might be better suited to this task -- it could be made to generate the code for the re-routing automatically. Although even this could be wrapped in an usecode function...- Event functions for click, doubleclick, and schedule changes.
Could you elaborate? Maybe UCC can already do this, but I don't know enough about Python to be sure.- Support for modules similar to that of Python.
You mean to check, from usecode, if BG and/or SI is installed to ensure copyright compliance or something? It is possible, and not that hard.- Builtin functions to determine the existance of BG and SI.
From usecode? That is probably better not done... it would be far to easy to wreak havoc with this from usecode.- Builtin functions to manipulate the shape and flex files.
------
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]
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]
-
- Posts: 1241
- Joined: Thu May 14, 2020 1:34 pm
Re: Usecode 'events' functionality
"From usecode? That is probably better not done... it would be far to easy to wreak havoc with this from usecode."
It would be, but it's really up to programmers to write safe code. I'm thinking of doing it on the fly specifically to allow/deny certain content to people who do or don't have SI installed.
"Could you elaborate? Maybe UCC can already do this, but I don't know enough about Python to be sure."
If it does I'm unaware of the functionality. Every file in python gets divided into a module. Each module has private and public functions. Some are predefined and others aren't.
An example:
We have a file, money.uc. This makes a module "money". It might have a component class "currency" and then we could go:
filari = money.currency()
monetari = money.currency()
We could also have some helper functions, such as get_party_gold(). We could then access them through the module:
party_gold = money.get_party_gold()
In python you could then use the import keyword in a few different ways:
import money
would import all the public classes and functions of the money module for example.
In python we can use the from keyword to import only select keywords:
from money import get_party_gold
which would just import the get_party_gold function into the current script's scope.
We can even rename them if we have conflicts, again with the from keyword:
from money import get_party_gold as UI_get_party_gold
This would import the get_party_gold function, but with the name UI_get_party_gold.
It's something that's not strictly neccesary, but I find it helpful when it comes to organising the code - it also helps manage memory which isn't an issue on pcs, I suppose, but it would make the code a little easier on the phones and pocket PCs we see people porting to lately.
For me, when I see all the builtin function with UI_whatever, and I think it would be fairly helpful to organise them a little, ie, random.get_die_roll face.display face.hide and so on.
Wizardry dragon
It would be, but it's really up to programmers to write safe code. I'm thinking of doing it on the fly specifically to allow/deny certain content to people who do or don't have SI installed.
"Could you elaborate? Maybe UCC can already do this, but I don't know enough about Python to be sure."
If it does I'm unaware of the functionality. Every file in python gets divided into a module. Each module has private and public functions. Some are predefined and others aren't.
An example:
We have a file, money.uc. This makes a module "money". It might have a component class "currency" and then we could go:
filari = money.currency()
monetari = money.currency()
We could also have some helper functions, such as get_party_gold(). We could then access them through the module:
party_gold = money.get_party_gold()
In python you could then use the import keyword in a few different ways:
import money
would import all the public classes and functions of the money module for example.
In python we can use the from keyword to import only select keywords:
from money import get_party_gold
which would just import the get_party_gold function into the current script's scope.
We can even rename them if we have conflicts, again with the from keyword:
from money import get_party_gold as UI_get_party_gold
This would import the get_party_gold function, but with the name UI_get_party_gold.
It's something that's not strictly neccesary, but I find it helpful when it comes to organising the code - it also helps manage memory which isn't an issue on pcs, I suppose, but it would make the code a little easier on the phones and pocket PCs we see people porting to lately.
For me, when I see all the builtin function with UI_whatever, and I think it would be fairly helpful to organise them a little, ie, random.get_die_roll face.display face.hide and so on.
Wizardry dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
-
- Posts: 565
- Joined: Thu May 14, 2020 1:34 pm
Re: Usecode 'events' functionality
More than one NPC set of schedules... I remember seeing the U6 editor that someone made where you could edit NPC schedules by the day. For example, with the U6 gypsies, day one they would be in Britain, then I believe on the third day, they would be in Yew, then day six they would be in Paws, etc. You could edit what their shedule types would be on certain days.
It would be really cool to have NPC schedules editable by the day, so you could create stuff like shopkeepers availiable only on certain days, or the travelling NPC's, and NPCs who may appear in a town or shop on a certain day, but not others.
It would be really cool to have NPC schedules editable by the day, so you could create stuff like shopkeepers availiable only on certain days, or the travelling NPC's, and NPCs who may appear in a town or shop on a certain day, but not others.
-------------------------------------------------------------------------------------
Ultima 6 Mod for Exult site: http://www.ultima6.realmofultima.com/
Ultima 6 Mod for Exult site: http://www.ultima6.realmofultima.com/
-
- Posts: 384
- Joined: Thu May 14, 2020 1:34 pm
Re: Usecode 'events' functionality
Quote:
I really need to play SI again to say this for real, but somehow this was doable for the iceraft, so it should work for you as well.
The deed is probably not needed, just a usecode flag, once something happens in your game that sets this flag, your raft is free to use
Quote:
Just make the shape check a usecode flag when clicked on. It's what they do for the ice barge.
I completely forgot about the ice raft. It has been years since I played S.I. Thanks guys! I will have to find my old raft and tweak it up. I also forgot that the magic carpet doesn't need a deed. Maybe a hot air balloon isn't out of the realm of possibility...
Quote:
It would be really cool to have NPC schedules editable by the day, so you could create stuff like shopkeepers availiable only on certain days, or the travelling NPC's, and NPCs who may appear in a town or shop on a certain day, but not others.
Traveling NPC's would be great! In fact, the S.E.T.C. will require this, as Dokray and Shamuru do travel between villages in the original. The expanded story requires neutral natives to smuggle certain goods between warring tribes. It also "forces" traveling and exploration if you need that npc, but they aren't where you expect them to be.
I truly hope to make sense of UCC someday. I think that I could, given enough examples, help, and resources.
I really need to play SI again to say this for real, but somehow this was doable for the iceraft, so it should work for you as well.
The deed is probably not needed, just a usecode flag, once something happens in your game that sets this flag, your raft is free to use
Quote:
Just make the shape check a usecode flag when clicked on. It's what they do for the ice barge.
I completely forgot about the ice raft. It has been years since I played S.I. Thanks guys! I will have to find my old raft and tweak it up. I also forgot that the magic carpet doesn't need a deed. Maybe a hot air balloon isn't out of the realm of possibility...
Quote:
It would be really cool to have NPC schedules editable by the day, so you could create stuff like shopkeepers availiable only on certain days, or the travelling NPC's, and NPCs who may appear in a town or shop on a certain day, but not others.
Traveling NPC's would be great! In fact, the S.E.T.C. will require this, as Dokray and Shamuru do travel between villages in the original. The expanded story requires neutral natives to smuggle certain goods between warring tribes. It also "forces" traveling and exploration if you need that npc, but they aren't where you expect them to be.
I truly hope to make sense of UCC someday. I think that I could, given enough examples, help, and resources.
Re: Usecode 'events' functionality
Ah, so the answer would be 'no, UCC doesn't have it'.Every file in python gets divided into a module.[...]
U7 data does not support this, it only supports a single daily schedule. But an usecode function can be used to switch schedules every day. Travelling NPCs, likewise, can be done through usecode, but will require sprinkling eggs here and there to make sure.It would be really cool to have NPC schedules editable by the day
The entire usecode and other data for Keyring and SI Fixes mods are available with the Exult source, and have a decent number of comments. Likewise, TFL usecode is also available. And there is the Exult intrinsic reference in my website, as well as some information on script blocks and commands.I truly hope to make sense of UCC someday. I think that I could, given enough examples, help, and resources.
------
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]
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]
-
- Posts: 384
- Joined: Thu May 14, 2020 1:34 pm
Re: Usecode 'events' functionality
Quote:
The entire usecode and other data for Keyring and SI Fixes mods are available with the Exult source, and have a decent number of comments. Likewise, TFL usecode is also available. And there is the Exult intrinsic reference in my website, as well as some information on script blocks and commands.
I don't know how to view the source, or how to add usecode to stuff while using E.S. I'm a total newb. Though, I do look at code whenever it is posted on the phorum.
The entire usecode and other data for Keyring and SI Fixes mods are available with the Exult source, and have a decent number of comments. Likewise, TFL usecode is also available. And there is the Exult intrinsic reference in my website, as well as some information on script blocks and commands.
I don't know how to view the source, or how to add usecode to stuff while using E.S. I'm a total newb. Though, I do look at code whenever it is posted on the phorum.
-
- Posts: 1241
- Joined: Thu May 14, 2020 1:34 pm
Re: Usecode 'events' functionality
Go to the TFL sorceforge page and use the Web cvs viewer ther.
Wizardry dragon
Wizardry dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
-
- Posts: 384
- Joined: Thu May 14, 2020 1:34 pm
Re: Usecode 'events' functionality
I will Wizardry Dragon. Many thanks! Are there any basic tutorials out there? For example, "to create a conversation tree that sets flags, follow these steps..." I used tutorials like that when messing with Morrowind, such as creating a script that made deer run away from the player when the player got too close.
-
- Posts: 1241
- Joined: Thu May 14, 2020 1:34 pm
Re: Usecode 'events' functionality
Ucc.doc has some good basic information though it is a bit dated - I wrote it when UCC first was developed!
Wizardry Dragon
Wizardry Dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
-
- Posts: 1241
- Joined: Thu May 14, 2020 1:34 pm
Re: Usecode 'events' functionality
The ucc docs I mentioned, by the way, are here:
http://u7feudallands.cvs.sourceforge.ne ... vision=1.5
Man, I first wrote that in 2004. How time flies...
The root directory for usecode source in the web viewer is http://u7feudallands.cvs.sourceforge.ne ... s/tfl/src/
Wizardry dragon
http://u7feudallands.cvs.sourceforge.ne ... vision=1.5
Man, I first wrote that in 2004. How time flies...
The root directory for usecode source in the web viewer is http://u7feudallands.cvs.sourceforge.ne ... s/tfl/src/
Wizardry dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Re: Usecode 'events' functionality
Sorry to be digging up an earlier post a bit.
Maybe I understood this functionality wrong, but from what I can see, the standard delay causes things to happen after a certain amount of time has passed from starting the script, whereas the proposed function would cause stuff to happen at a certain time of day, and not in relation to anything else. I do not quite understand how that could be set up using delay, since that would be relative to the point in time the script is started.Now that I read paying some attention:
For all such cases (hour, minutes, ticks) you are better off using standard script blocks on a delay to call back the function -- i.e.,- Event functions for time of day
script AVATAR after 10 ticks { nohalt; call myFunction; }
Anything else would be duplicate functionality for little to no gain: an usecode wrapper for this is exceedingly easy to make.
Re: Usecode 'events' functionality
You delay it by exactly the amount of time needed for the script to happen at the time of day you want. For example:
Code: Select all
/*
* Sets a function to be called at the given hour:minute.
* If the current time is after the given time, the function
* will be called a day later.
* If you want to absolutely ensure that the function gets called,
* the object supplied should be the avatar; otherwise, the object
* or NPC in question may be deleted or set to dormancy (respectivelly)
* if the avatar gets far enough away.
*/
void scheduleFunction (var obj, var function, var hour, var minute)
{
// Validate input:
if (hour 23)
hour = 23;
if (minute 59)
minute = 59;
// Get current time:
var ch = UI_game_hour();
var cm = UI_game_minute();
// Determine delay:
var deltah = hour - ch;
var deltam = minute - cm;
// We need to wait a negative number of minutes:
if (deltam < 0)
{
// Wait another 60 minutes, but reduce the number
// of hours to wait by 1:
deltam += 60;
deltah -= 1;
}
// We need to wait a negative number of hours:
if (deltah < 0)
deltah += 24; // Add a whole day.
// Schedule the function:
script obj
{
nohalt;
wait deltah hours;
wait deltam minutes;
call function;
}
}
------
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]
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]
-
- Posts: 1241
- Joined: Thu May 14, 2020 1:34 pm
Re: Usecode 'events' functionality
Out of curiosity, will delayed actions for "dormant" NPCs recur at a later time or are they simply discarded?
Wizardry dragon
Wizardry dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Re: Usecode 'events' functionality
They are discarded. If the script has a 'finish' command, though, it will execute all remeining commands instantaneously instead of finishing.
------
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]
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]
-
- Posts: 1241
- Joined: Thu May 14, 2020 1:34 pm
Re: Usecode 'events' functionality
Hrm. It would be nice to have surviving NPC scripts without having to tack them all onto the Avatar.
Wizardry dragon
Wizardry dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
-
- Posts: 1241
- Joined: Thu May 14, 2020 1:34 pm
Re: Usecode 'events' functionality
Not directly related to the events, but as regards the module functions I mentioned before, I put down my thoughts in that regards in the TFL fora for those interested:
http://www.thefeudallands.ca/fora/topic.php?id=5#post-5
Wizardry dragon
http://www.thefeudallands.ca/fora/topic.php?id=5#post-5
Wizardry dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Re: Usecode 'events' functionality
Would it be possible to create an event for when a NPC is attacked in combat? So on top of having an event for double clicking when not in combat, have an event for double clicking when in combat.
Would something like this mess up the the way combat works if that event wasn't present in each NPC's usecode?
Would something like this mess up the the way combat works if that event wasn't present in each NPC's usecode?
Re: Usecode 'events' functionality
IN MANI CORP!
Has there been progress with this? I got around to dusting off my Exult modding projects, and as stated earlier, this stuff would help with that.
Has there been progress with this? I got around to dusting off my Exult modding projects, and as stated earlier, this stuff would help with that.
Re: Usecode 'events' functionality
Nope, no progress.
------
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]
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]