* Automatically generate the isValid() Lua API function for handle types
If an ADE object's stored type has an isValid() member, ade_obj now registers an isValid function for it automatically. An explicit ADE_FUNC(isValid, ...) declared after the ADE_OBJ replaces the generated one, so types with special semantics (e.g. sound) keep their own. The 67 hand-written functions that merely delegated to the member are removed, and 26 types that previously exposed no isValid() gain one.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
* Add ADE_OBJ_VALIDATOR for index-based Lua handles
Int-index handles (shipclass, weaponclass, team, etc.) can now declare their validity predicate with a single ADE_OBJ_VALIDATOR or ADE_OBJ_VALIDATOR_RANGE line after the ADE_OBJ. The registered validator drives the generated isValid() function and is also honored by ade_set_args when the mod table asks for nil instead of invalid objects, which previously never applied to these handles. The 19 hand-written range-check functions are replaced, and loadout_ship, default_primary, default_secondary, and support_rearm_pool_team gain isValid(). Add a validator to HudGauge while we're at it.
Also fully qualify the scripting namespace in LuaConvert.h so its templates can be instantiated from the unit tests.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
---------
Co-authored-by: Claude Fable 5.1 <[email protected]>
Fix a regression from #7393: `last_targeted_subobject` must be updated when the player's target and target subsystem are changed, or the subsystem will be retargeted due to `hud_target_change_check`.
Also fix related issues:
- the `ship.Target` and `ship.TargetSubsystem` scripting setters now use the standard `set_target_objnum` function and also correctly handle the new target subsystem
- fix an indexing error in `order.TargetSubsystem`
Co-Authored-By: Claude Fable 5 <[email protected]>
* Back in business hopefully
* Refactor
* Resolve CI issue in aigoals.cpp
* Updating order.cpp
* Whoops
* Updated objecttypes.tbl to incorporate attack ship type
* Fix clang-tidy issue
* Forgot one other instance
---------
Co-authored-by: wookieejedi <[email protected]>
Several refinements:
1. Make the case labels consistent between the setting and getting of the virtvar, for ease of comparison and troubleshooting.
2. Consolidate CHASE_WING and GUARD_WING for setting, like they already are for getting.
3. Consolidate STAY_STILL for getting, using one simple trick.
4. Remove the KEEP_SAFE_DISTANCE goal, since it has no target. Fixes#6761
5. Fix CHASE_SHIP_CLASS which put the getting case in the setting section, and consequently did not handle setting.
The new enum class collection of AI goal modes did not handle the superposition of states that could occur when multiple ships were selected in FRED. Add a special FRED-only state for this purpose.
Allow waypoint orders to target a specific waypoint and go in reverse. Add script access to waypoints and waypoint lists belonging to orders.
Fix assignment of targets and goal start times. Assign targets when they are different (and thus need to be assigned), not when they are the same.
Several locations in the code (notably `ai_info` and `waypoint_h`) previously stored pointers for waypoints and waypoint lists that need to be valid for more than one frame. Since both waypoint lists and waypoint paths may change size, resulting in vector reallocation, the information should be stored as indexes instead.
Fixes#6353.
This refactors the object_h struct to store objects as indexes rather than pointers. This is a prerequisite for making the collection of objects dynamic in the future. See also #6100.
Follow-up to #5800 and #5829.
Add "tactical" versions of disable and disarm goals which only perform the specific task without implying anything else. The target ship is not protected and attack goals are not cleared from other ships.
There is also a new AI profiles flag to make this the default hud squad message command instead of the classic disable/disarm.
* Adds safety checks to scripting orders with waypoints
Turns out setting a waypoint order then trying to get to target of that order in the same frame triggers a crash in the scripting API for ship orders (`order.cpp` line 295). This was due to invalid lookups which lacked safety checks.
This PR adds those safety checks. Now, if this situation is encountered, it leaves `objnum` at -1 and thus returns an object for which `isValid` is false.
Fix is tested and works as expected. Also fixes#5172
* appease clang
* cleanup thanks to Goober
* clang again
* forgot to re-add the nullptr
* remove redundant checks
* add subsystem indexer and ensure that ship_get_indexed_subsys and ship_get_first_subsys are independent
* also add reverse lookup from subsys to index
* update indexer to accommodate subsystem pointers being changed
* use clearer function names, and fix the type of subsys_list_indexer
* add assertions
* address latest feedbcak
This adds a new AI goal which is equivalent to play-dead except that it "sticks". It doesn't clear the goal list
so it will continue playing dead until the goal is removed or another goal with a higher priority is added.