Hack request - multi-line attack_preference fix
-
No rest for the weary.
There seems to be a bug with multiple attack_preference lines under a JobBlock in pilots_population. When defining the weapon preferences, only the first line’s prefs seem to be read. In other words, if setting up the following:
attack_preference = FREIGHTER, 4800, GUNS | GUIDED | TORPEDO | UNGUIDED attack_preference = FIGHTER, 4800, GUNS | GUIDED | UNGUIDED attack_preference = JUMPGATE | DESTROYABLE_DEPOT | WEAPONS_PLATFORM | SOLAR, 2400, GUNS | GUIDED | TORPEDO | UNGUIDED ```Here, NPCs are instructed to use GUNS, GUIDED, TORPEDO and UNGUIDED (whatever those are) against FREIGHTER ships. Moving down the next line, NPCs are instructed to use only GUNS, GUIDED and UNGUIDED against FIGHTER ships - no torpedoes should be used. But alas, NPCs go right ahead and slug torpedoes at everything, even a Starflier. Switching it around to
attack_preference = FIGHTER, 4800, GUNS | GUIDED | UNGUIDED
attack_preference = FREIGHTER, 4800, GUNS | GUIDED | TORPEDO | UNGUIDED
attack_preference = JUMPGATE | DESTROYABLE_DEPOT | WEAPONS_PLATFORM | SOLAR, 2400, GUNS | GUIDED | TORPEDO | UNGUIDEDIt should be noted, however, that everything else about the 2nd, 3rd, etc. attack_preferences lines - that is, ship types and ranges, respectively - appear to work fine. It's just the weapon prefs that are only being read from the first line. So, any solutions? ^_^;
-
Firstly, the third line is junk - it doesn’t work that way. Secondly, due to a simple parser, UNGUIDED contains GUIDED, so it’s not (yet) possible to just have UNGUIDED (should you wish; for the C programmers, it uses strstr for testing). Third, it must be a bug where it handles it, because everything is read the same way. I’ll try tracking it down later.
-
I actually noticed the third line got borked when I set it up like that. I normally run a preferences setup of:
attack_preference = FIGHTER | FREIGHTER, 4800, GUNS | GUIDED | TORPEDO | UNGUIDED attack_preference = JUMPGATE | DESTROYABLE_DEPOT | WEAPONS_PLATFORM | SOLAR, 2400, GUNS | GUIDED | TORPEDO | UNGUIDED ```I was surprised to find out ship types OR together fine, but after reading the bit definitions I suppose it all makes sense. Thanks for looking into it. Along with the other stuff I posted today, this'll probably be my last request for a while. Thanks for all the incredible work you've done so far adoxa.
-
Okay, I think there are three things it could be.
1. Your ORed types aren’t recognised, but it still adds one to the list, so you end up with the default setting (anything, 5000, everything). That means it might use anything rather than fighter/freighter.
2. Jobs get shifted around. I initially tested with just basic_job_no_formation, but it was using other jobs (I saw scavenger_job and assault_leader_job, then I just changed everything).
3. The player is always tested as FIGHTER | FREIGHTER. If that’s how you were testing, then that’s it.
1 can be fixed by separating the types. 2 can’t be fixed (it’s not broken), you just have to know where the jobs come from. 3 can be fixed by common.dll, 08E6D8, 74->EB. That ignores the player test (for this particular routine).
-
Thanks man, I’ll take a look. Since UNGUIDED contains GUIDED, all I should need for the weapons tab is GUNS | UNGUIDED | TORPEDO, correct?
I think you’re right on the money with the FIGHTER | FREIGHTER testing - that is in fact how I was testing, so I guess it would make sense then.
As for the jobs, I have default_job called from the pilot_default (used for everything) job_id, unless superseded by a higher pilot such as pilot_trader (which inherits pilot_default but defines a new job_id), or defined explicitly in the encounter’s “pilot_job” line (which overwrites everything). They all seem to work fine (traders, capitals, and player-wingmen behave like they’re supposed to, anyway), but I’ll check for possible job confusion as well.
-
No worries mate. And your #3 fix worked wonders - I was in fact testing with my ship (FREIGHTER) versus other NPCs (FIGHTER) - now everything works exactly as it should! Awesome stuff.
Just to clarify, when you said the third line was junk - were you referring to the ORed ship types? Or are only the first two attack_preferences read?