Author Topic: Bomb detection  (Read 1771 times)

0 Members and 1 Guest are viewing this topic.

Offline MadProf

  • 24
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]

 

Offline Halleck

  • 24
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...

 

Offline The E

  • He's Ebeneezer Goode
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
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:
Code: [Select]
weapon* wp; // Assumed to be a pointer to a weapon

bool is_bomb = (Weapon_info[wp->weapon_info_index].wi_flags & WIF_BOMB) > 0;
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Halleck

  • 24
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.