Hard Light Productions Forums
Modding, Mission Design, and Coding => The Scripting Workshop => Topic started by: MadProf on January 15, 2011, 03:33:21 pm
-
While attempting to figure out a script for "Prioritised Auto Targeting" (think of the default "Auto Target" but in the order bombs->bombers->fighters), I hit a snag - couldn't figure out a *generic* method of detecting which weapon was a bomb. Originally thought that a TargetLOD > -1 would do it, until a harpoon missile ended up targeted.
In the end I ended up figuring out a patch to add an isBomb function to the weapon class - easier than I expected. (see attachment for patch)
If anyone can think of another way, I'm all ears.
---
*generic* -- meaning would work with mods that alter the weapons as well the standard FS2 weapons.
"Prioritised Auto Targeting" - I'm not a good pilot :) so trying to gain a little in game assist
[attachment deleted by ninja]
-
Sorry to be bumping such an old thread, but what happened to this patch? Did it get applied? Was this only a change to the scripting API or also to the internal Weapons struct? I just ask because I'm working on bomb scoring now but I don't see any direct bomb booleans in the weapon struct - that information is typically obtained from the weapon_info flags. But I could add that if needed, or if this patch already does that, it could save me some time doing that...
-
Umm, Halleck, that's what WIF_BOMB is for. In other words, to figure out whether a given weapon is a bomb, you need to look up it's weapon info.
Like so: weapon* wp; // Assumed to be a pointer to a weapon
bool is_bomb = (Weapon_info[wp->weapon_info_index].wi_flags & WIF_BOMB) > 0;
-
Yeah, I know. I was asking if this feature was needed for the scripting API. I haven't used it at all and I'm not sure if the necessary variables, bitwise operators and constants are available on the lua side. I just figured that it would be simple to add something like this from the engine side since I'm already messing with this area for the bomb scoring mechanism.