Friday, April 13, 2012

[FA]Force an unit to go on surface when it have a target ?

[:1]Hi :)
I would to know if it is possible to force a sub unit to go on surface when the weapon have a target ?
Thanks|||Er, isn't that what auto-surface mode does? Right-click the surface button.|||Mithy|||That's just the UI code that handles turning auto mode on and off for the appropriate units in a group. It doesn't actually handle the auto-surfacing once turned on, that's all up to the engine.
I seem to recall auto-surfacing working for e.g. the Cybran T1 subs, but in the event that it doesn't, your only available option would be to manually check the current layer in the script against current weapon targets, and do an IssueClearCommands and then an IssueDive to force a surface.
This would clear any orders that unit had, however, including an attack order. There's also no small amount of difficulty to determining when a surface target is available. You'd need to create a dummy weapon with a valid script class that simply does no damage (blank out its OnFire), and can target surface targets from underwater, then use this weapon's OnGotTarget (which isn't 100% reliable, but works most of the time) to run a function that checks whether or not the unit's underwater weapons have targets, and if not, issues a surface. This is kind of messy and complicated, but it's really the only way to get a unit to auto-surface/dive if the built-in auto mode doesn't work.
The surface-targeting dummy weapon would probably need to be disabled while the unit is moving, otherwise if you gave it a normal move order underwater, it would immediately halt, surface, and start attacking if it encountered a surface target - basically, you'd totally lose control of the unit.|||ok thks :)
And a new question now :D
What determine the dive duration ?|||If you mean the time it takes to dive/surface when the command is issued, probably something in the unit's bp.Physics. I haven't actually timed it, but I think the Atlantis takes a bit longer to dive/surface than the T1 subs, so compare those two blueprints' Physics tables and experiment with some of the settings that are different between them.|||Hi,
Just some general info really,
This could be usefull for this type of thing,
in DMS v7 (not released yet), you can give a unit a "unit sensor" which detects units within the sensors range and updates the distance and unit detected via a function, you could use this sensor to make the sub surface when a unit on "layer" is detected ..|||That's not the difficult part, the difficult part is telling it when NOT to surface, otherwise you get a unit that's 100% uncontrollable and surfaces and attacks any time you try to move it near enemy surface units.
In my experience, trying to automatically issue orders is not something that will ever produce desirable results, because it requires reams of manual scripting (and performance-intensive checks) for every possible situation where you might not want the auto-order to occur. What if you want the sub to move silently past surface targets, instead of attacking them? You're SOL. You can try to base the auto-behavior on movement, but even then, you have to keep it moving non-stop (and not on a patrol) to keep it from auto-surfacing.
The only thing I can think to try would be to make the primary weapon the subsurface-to-surface dummy weapon, and give it whichever blueprint flag prevents it from auto-acquiring targets. If that flag actually works (I don't recall), you could make the sub surface by giving it an attack order on a surface target, but that might negatively impact its target behavior w/r/t sub-surface or water targets assuming it has torpedoes as well-- because those would no longer be the primary weapon, and it would have difficulty knowing which range to position itself at when given an attack order against sub targets.

No comments:

Post a Comment