scripts awarding equipments with high TL

An area for discussing new ideas and additions to Oolite.

Moderators: another_commander, winston

Post Reply
dybal
---- E L I T E ----
---- E L I T E ----
Posts: 294
Joined: Mon Feb 10, 2020 12:47 pm
Location: São Paulo, Brasil

scripts awarding equipments with high TL

Post by dybal »

EquipmentInfo.techLevel has, as per the wiki, "The raw tech level required to purchase this item" (emphasis mine).

When Ship Storage Helper OXP is restoring a ship and tries to award an equipment with higher EquipmentInfo.techLevel than the currents system's, the awardEquipment fails. It then changes the system's tech level to a higher value so the awardEquipment succeeds, but that is a costly change, I've seen it taking 0.5s going up and 0.1s going down.

Since the wiki says that techLevel limitation is for purchasing, and scripts can get around it anyway, if costly, wouldn't it be better to not check tech level on awardEquipment?

User avatar
phkb
Commodore
Commodore
Posts: 2675
Joined: Tue Jan 21, 2014 10:37 pm
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...

Re: scripts awarding equipments with high TL

Post by phkb »

If the only check for TL is in an awardEquipment script, that's probably true. However, there might be multiple factors that make checking TL in the script preferable (for instance, a combination of TL and Eco, or government type).

In the case of Ship Storage Helper, changing the system TL is a bit of a last-ditch attempt to give the equipment to the player, due to it failing earlier in the process. Ultimately, what would be ideal is for all awardEquipment scripts to do a check for context == "scripted" and then return true before any other checks are made. That would allow the equipment to be awarded by scripts, regardless of location or TL or any other limitation.

dybal
---- E L I T E ----
---- E L I T E ----
Posts: 294
Joined: Mon Feb 10, 2020 12:47 pm
Location: São Paulo, Brasil

Re: scripts awarding equipments with high TL

Post by dybal »

Sorry people, the problem was a bug in Ship Storage Helper that prevented it from trying again if any awarding failed (because of required equipments and awarding in not-the-optimal order), so instead of awarding those equipments that didn't require anything (the ones that have requirements would fail), then trying to award those that failed (because of requirements) until it could award anything, is was going directly from the first pass to the "let's change the context" last-ditch attempts...

My bad... (not the bug, but assuming it was a core game issue...)

On the plus side, with that fixed even my iron-assed (kitted with everything and the kitchen sink :lol: ) escorts are now being restored in 0.012s :D

Post Reply