Hard Light Productions Forums
Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Admiral Nelson on January 03, 2006, 09:58:29 pm
-
Search is broken, so here's this question again. There was some code at one time, IIRC, to permit capships to shoot at asteroids. Also IIRC this code was removed as it made certain missions too easy. Would it be practical to make this a mission level flag? In one mission converted from FS1 an important ship can be destroyed simply by idling along until the asteroids smash it to bits. I suppose the other work around is to make it invulnerable for a while, or give it a few esort fighters. Nevertheless, I'll throw the idea out again... :)
-
I have a very strong suspicion that this is the sort of thing tied in to the new ai settings table. Unfortunately I've been here in presence only for almost the last month so I don't know the specifics of that.
-
I'm pretty sure that the asteroid firing code is still in there by default and isn't controlled by a flag or anything. It's set up in a way to affect balance as little as possible. That's not to say that it hasn't broken at some point but last time I checked it was working fine.
-
I thought about making it more and less flexible than that. Basically in ships.tbl you'd specify:
$Target precedence: ("weapon" "asteroid" "bomber" "figheter" "cruiser")
and so on, with flags that would let you set what the weapon would go for first. IE with the example above, the turret would go for bombs then asteroids.
Right now tho, I think the Asteroid code is just commented out, so it'd be easy enough to add some kind of flag toggle for it.
-
Right now tho, I think the Asteroid code is just commented out
It's not, just checked to make sure. Asteroids are always targetted last though.
-
Hmmm...so I see.
Although you could still make capships a little better at killing asteroids with
// don't use turrets that are better for other things:
// - no cap ship beams
// - no flak
// - no heat or aspect missiles
// - no spawn type missiles/bombs
// do use for sure:
// - lasers
// - dumbfire type missiles
// - AAA beams
-
Heat, aspect, and spawn weapons are useless against asteroids. Cap ship beams are far too overkill and the friendly fire is problematic. Same thing with flak and friendly fire. I got killed numerous times during testing because of friendly fire problems so the list of usable weapons got trimmed to just those three types. Every asteroid mission I've seen was also an escort mission so all of the fighters and other ships in the area require protection from the idiot AI. Good mission designers can get around this easily though and make the reduced weapon types against asteroids work for them.
-
This is partially OT but as WMC said:
I thought about making it more and less flexible than that. Basically in ships.tbl you'd specify:
$Target precedence: ("weapon" "asteroid" "bomber" "figheter" "cruiser")
and so on, with flags that would let you set what the weapon would go for first. IE with the example above, the turret would go for bombs then asteroids.
So if such a feature is ever going to be introduced... Wouldn't this kind of a change cause some probs or have possibility of causing probs with existing weapon flags (bomber+, huge) and also should this kind of change be rather included to the weapons instead of ships table. Just an opinion if this is planned to be added to the game.
-
Pretty much what Wanderer said. A change to the targetting precidence would be best in the weapons table as you could then have weapons that were anti-cap or anti-fighter only.
-
Surely asteroids though would always be at the back of the target precedence list. So that turrets would only target them if there were no more pressing threats (any kind of enemy) in their FOV? In which case a simple "turrets shoot asteroids" flag in the mission file would suffice.
-
In Rebels & Renegades for instance only the Vasudan bombers are a greater threat than the asteroids though because the fighters were ignoring the Iceni in order to take out the NTF fighters.
Maybe we need tables and a SEXP to alter them on a case by case basis.
-
Well in that case an ai-change-precedence SEXP or something might be a good idea. Never needed one myself though, but if you have you can bet I probably will one day.
-
Erhm.. the only thing that's needed for such a thing is a toggle SEXP, for instance set-asteroid-priority of 0 or 1, setting asteroids either as first or last in target priorities. A sign flip on the target priority list would probably suffice. A completely dynamic set-target-priority list is probably too difficult to implement, though. However, it would make the AI more .. well.. human, if you will.
- Selectah
-
Erhm.. the only thing that's needed for such a thing is a toggle SEXP, for instance set-asteroid-priority of 0 or 1, setting asteroids either as first or last in target priorities. A sign flip on the target priority list would probably suffice. A completely dynamic set-target-priority list is probably too difficult to implement, though. However, it would make the AI more .. well.. human, if you will.
- Selectah
It's best for non-programmers to stay out of it when deciding how difficult something will be to implement. Changing the priority of the asteroid targetting could very easily involve exactly the same functions regardless of whether it was done via your or my method.
Best to just suggest things and then let the coders decide which is more difficult.
Well in that case an ai-change-precedence SEXP or something might be a good idea. Never needed one myself though, but if you have you can bet I probably will one day.
I've never needed one but I can think of many occassions I'd have used one if I had it. There are quite a few missions where a capship will say we'll handle enemy x, you handle y. I wouldn't mind seeing it actually do that :)
-
Implementing either method would take roughly the same amount of work.
First you need an array.
char *Turret_order_names[NUM_TURRET_ORDER_TYPES] = {
"Bombs",
"Ships",
"Asteroids",
};
For each turret(ship? ship class? turret on a ship class?) you'd add another array:
int targeting_priority[NUM_TURRET_ORDER_TYPES];
Then in get_nearest_enemy_objnum():
for(int i = 0; i < NUM_TURRET_ORDER_TYPES; i++)
{
switch(targeting_priority[i])
{
case -1:
//Empty priority slot
break;
case 0:
//Return if a bomb is found
//...
case 1:
//Return if a ship is found
//...
case 2:
//Return if an asteroid is found
//...
default:
Int3(); //Means invalid number passed.
}
}
Then you just need to add the SEXP, which is time-consuming but not really hard. Essentially what the code will do then is iterate through the array, which stores a series of numbers that correspond to each target type. When it hits the number corresponding to a type, then it'll target that object if one of that type exists.
The array above would be used for translating the numbers into human-readable strings in the SEXP (and vice-versa) by the order.
Dynamic order rather than simple priority actually results in a simpler code sequence because you don't need new functions or more if() checks (or, Goob forbid, gotos).
So, what basis would this be on?
-
It would be nice to have one which works on all turrets (or all turrets of a certain type) on a ship and a more granular version which only affects a named turret if possible.
If you're only doing on go with the lowest level one. I could use when-argument or something to make all the turrets on a ship work.
-
(or, Goob forbid, gotos)
Hey, I like GOTO! :p I've even used it once or twice in the SCP.
-
turret-set-target-order and ship-turret-target-order should be in the next CVS build.
-
:nod: Nice. :yes:
-
Excellent :)
-
Oh, if you call those without any target order flags then the turret should keep firing at whatever the current target is until it's time to search for a new target.
-
I just took a look at this in the CVS build (01/07) and I think it needs a little more in terms of user-friendliness. The fact that the "order" list is done with strings concerns me. Are we supposed to put ship names, classes, what? It would do better if we had a drop-down menu so we know what our options are.
-
Erg, I forgot the FRED2 stuff, it should be in CVS now.
On that front, keep in mind that I wasn't able to figure out why I couldn't add on data to the target order flags (without extensive debugging). Hopefully it's just my inexperience with FRED here - the max values should be 5 for turret-set-target-order and 4 for ship-turret-target-order.
-
OK, it seems to be working now (at least in FRED). I do have a suggestion however. Is it possible to get even more specific in target priorities? What I mean is, could this or another sexp be created so that specific ships or ship classes could be included as options. For example, a Destroyer is engaged in a multi-cap-ship engagement. Its heaviest anti-cap beams would be targetted at the largest target, like a corvette, while the lighter ones would be targetting cruisers. If the corvette goes down, then the priority order would have the big weapons switch to targetting cruisers, or if the cruisers go down first, they lighter weapons would assist in targetting the corvette. I could see strings being used for specific ship names, if that's possible to code.