Detect if the player enters a system

Freeform discussion about anything related to modding Transcendence.
Post Reply
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

Is it possible to detect if the player enters an already created system? If the player leaves a system, all recurring timer events stop, I would like to turn them back on if the player re-enters a system.
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

Actually F50 the timers will continue when you enter again.

If you have a recurring timer in a system and leave the system then come back, the timer continues from where it was. (well, it continues! If it is just doing something every N frames, it continues- if that something is incrementing a value, it would continue from where it left off)

You can easily implement a tracking system- simply have a timer that stores the system id on a holder in the player ship or some similar object.

Have every system in the game start a tracking timer when it is created, and simply update the data holder.

Since each system timer will continue to run when the system is active, you will have a way to update the position of the player- you can also run a check to see if the system has been changed recently and build from that to perform functions such as an 'on enter system' event.

Essentially what you want to create is a timer for each system that access the same set of data, stored somewhere handy.

No matter which system you are in, this set of data provides a 'global' or universal reference for handling time, and other global data.

You can do a lot with it once you have built the basic global reference system. One of the first things I managed to do with the global timer system was to update the player position in the navigation computer, and track the last 5 systems visited and the duration of the visits.

Creating the OnEnter event is a logical extension of player position tracking- included in the timer method could be a function that compares the current system id to the previous stored id each timer cycle- when the player enters a system, the timer in that system would find that the previous id is different than the current id and can then perform an OnEnter event for that system- you could even have different types of events for different purposes and systems.

Hope that helps.
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

well I guess this is a moot point then :oops:

Thanks Periculi.
User avatar
Prophet
Militia Captain
Militia Captain
Posts: 826
Joined: Tue Nov 18, 2008 6:09 pm

I hate to res an old post but I was thinking of somthing similar today.

I want to creat a Factory station similar to the Teraton Fabricator but less complicated. A place to 'build' common consumables and perhaps some unique/rare items.

The player would dock with the station and be prompted to transfer ore into the station's inventory. Depending on the level and amount the player could then pay to have that ore made into the items. I don't want it to be a 'store' using ore as credit so to create a wait time during which the items are being processed I thought of using some sort of OnSystemEnter event to actually create the item(s).

What sort of complexity would I be looking at to implement something like this?
Coming soon: The Syrtian War adventure mod!
A Turret defense genre mod exploring the worst era in Earth's history.
Can you defend the Earth from the Syrtian invaders?
Stay tuned for updates!
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

I don't know about finding if the player is entering the system, but it would be more realistic and easier to make a certain amount of time pass before it is created:

(sysAddObjTimerEvent 100 gPlayerShip "CreateItem")

Of course, 100 is far too fast...
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

Just timestamp your transactions. You won't have any need of system level tracking that way. No sense in setting up a timer that uses cpu resources better spent drawing frames when you can just handle everything inside the station itself. (if you need to be informed your order is done remotely that's a much different tricky problem)

You can get the time in ticks using unvGetTicks or something like that, and then you will need to do some math- a second is 30 ticks, I think, so if you want a minute you need unvGetTicks[current time] + (30 * 60). Store the timestamp on the station and add a few perks like a queue display of projects/time remaining. EZ!
User avatar
Prophet
Militia Captain
Militia Captain
Posts: 826
Joined: Tue Nov 18, 2008 6:09 pm

Thanks for all the input but I went in another direction using Dvalin's research as a template.
I made my own items and added a 'research' modifier, adjusted Dvalin's script to search for only these items and when you have collected enough he will give you a reward.
I'm still debugging it now.
One problem I have is that he will only take 1 of each item instead of the 5 that the original will. I considered leaving it and just change the xp gain from 0 to 1 for any duplicates but am still trying to mash my way through the code.

is seems the problem is somewhere in setting the 'haveCount' variable.

Code: Select all

;see if we've already got the item that the player donated
(setq haveCount 0)
(enum (objGetItems gSource "*U +research;") theItem
(if (eq (itmGetUNID theItem)(itmGetUNID gItem))
(block Nil
((setq haveCount (add haveCount (itmGetCount gItem)))
((if itmIsDamaged theItem)
(setq haveDamaged True)
(setq haveUndamaged True)))))
This is identical to the original in the rasiermesser file except for the item field which was originally "aswU +NotForSale; F:rv-;"

Any ideas?
Coming soon: The Syrtian War adventure mod!
A Turret defense genre mod exploring the worst era in Earth's history.
Can you defend the Earth from the Syrtian invaders?
Stay tuned for updates!
Post Reply