Tuesday, April 17, 2012

[FA] [SOLVED] Change Blueprint values on the fly in the unit

Is there a way to change unit bp values (for example, elevation or max air speed for air units) on the fly with scripting. I.E. If i wanted to make a custom UI button that changes weapons on a air unit, and changes its elevation, is that possible? (i know how to handle the buttons, it's changing the BP values i don't know how to do)|||You can, but that would just make all future units produced take that change.|||No, you can't. __blueprints is a copy of the actual blueprint table in the engine. The lua has zero write access to blueprints once RuleInit has finished. The exception to this is the engine's blueprint reloading system (/EnableDiskWatch), which is for debugging only, only responds to altered files on disk, and horribly breaks multiplayer. Shift-F6 in debug mode has the same issues (and then some - it also requires cheating to be enabled).
I don't think it's possible to change elevation mid-game, but changing weapons is easy, they just have to be created initially and then disabled in the unit's OnStopBeingBuilt - look at how the ACU script and blueprint handle overcharge.|||Logic your sig says a lot but we didnt see anything from you :) can we say are you gettin ready to surprise us :D|||If there isn't an explicit engine function provided for this purpose, then no, you can't alter the blueprint on the fly. Of course, there are explicit functions for many purposes, like enabling/disabling weapons. Arbitrary BP values, no.|||Actually, it is possible to alter air units' elevation on the fly using Gilbot's StatsSlider mod. However, there's some easy coding to do before you get it to work properly.|||Huh, you're right. There are SetElevation and RevertElevation engine methods. I didn't know about those at all.
So yes, you can change both weapons and elevation on the fly in the unit's script, but not via blueprint modification.|||Pyrrha|||Shouldn't that only be the case if it has a CirclingElevationChangeRatio or an AttackElevation in bp.Air?
Regardless, it would still be possible to brute-force it with a thread that runs every ~0.3 seconds and maintains elevation, and it would still be useful for weapons-disable getaway modes that increase or decrease elevation and increase speed, or something like that.|||Mithy|||would it be possible then, to make a script bit that would simply replace the unit with another unit that flies at a higher elevation, and vice versa. wouldn't it then simply float up to the new elevation, and back down when switched again? Only problem would be passing veterency and shield status. dunno how to do that.|||LogicSequence|||Passing orders is much, much more involved yet. It can be done, but not perfectly, and it introduces a lot of performance overhead. A bit overkill for what amounts to a cosmetic change (elevation doesn't really affect anything practical unless you're going for extreme values that the engine wasn't really meant to handle).
I would suggest experimenting with the SetElevation function before you try anything like unit replacement - you might have different results depending on how your unit functionality differs from the unit that Resin was testing it with. It might also be possible to assign the unit a dummy primary weapon that has zero range while at its altered elevation, preventing it from going into a true attack mode while still allowing its other weapons to fire normally.

No comments:

Post a Comment