• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Need help with time measurement during landscenes

CouchcaptainCharles

COO (Chief Oddity Officer)
Storm Modder
Pirate Legend
How can I measure the time that has elapsed DURING a landscene?

What I would like to do is make a weapon that stuns characters for a certain time, so i need to measure the time when the character was knocked out in order to reanimate him some time later.

The time attributes that i have found - environment.time and worldmap.time - always have the same value during the whole landscene. Only if you load another location does the time "jump" on.

Can anyone help ?
 
In quests_reaction.c there are `time-elapse` indicators between events - thus:

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->LAi_ActorGoToLocator(PChar, "goto", "goto7", "", 4.0);<!--c2--></div><!--ec2-->

Where 4.0 measures time in some way to create a delay.

In quests.c there are several references to time - delay and PostWait.

I don't know much about these commands (NK should know more!), but I hope this helps! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/onya.gif" style="vertical-align:middle" emoid=":onya" border="0" alt="onya.gif" />
 
loctmptime is a float that tracks the number of something (ticks? seconds? I _think_ it's seconds but it behaves kinda weird...) elapsed since loading the location.

I've modified its handling and added a switch (so that you can have time update automatically, i.e. once/sec it increases environment.time by a second, or en masse (like in normal POTC, update on change locations).

Just do a global search for all files with locTmpTime in them.

The place you want to look at mostly is locations_loader.c, and especially the last function (which is called every once a--well, it's not exact. Somewhere between 0.`2-1`.0 or so seconds).

Note that this will not work in locations that have time disabled (if any do).
 
Hey, thanks you two <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />

That loctmptime is just what I need for the knockouts (seems to count seconds), and that "run with timedelay" will be great for a tool or function that scares enemies away.
 
You could create your own event handler to do that.
at the top of some file:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->#event_handler("scareaway","ScareAway_Event");<!--c2--></div><!--ec2-->

later, in some file:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->void ScareAway_Event()

{

    int chridx = GetEventData();

    aref chr = GetCharacter(chridx);

    string group = GetEventData();

    string locator = GetEventData();

    LAi_ActorRunToLocator(chr, group, locator, "", 10.0); //tweak last value to taste

}<!--c2--></div><!--ec2-->

and lastly, when you want to create the event:
(in wherever your code is that generates the runaway need)
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->int chridx = Character_index_you_want_to_run;

string locator = locator_to_run_to;

string group = that_locator_group;

float delay = milliseconds_to_wait_before_running;

PostEvent("scareaway", delay, "lss", chridx, group, locator);<!--c2--></div><!--ec2-->
 
Back
Top