Weapon Manipulation Lua
Moderator: Moderators
Weapon Manipulation Lua
I'd like an unsynced Lua call-in, a synced call-in, and two synced call-outs: GetAllWeaponsInView(), GetAllWeaponsIn(), CreateWeapon(), and DestroyWeapon().
GetWeaponsInView() would return the weaponID, team, positions xyz, vector xyz. No biggie, but it would give us tools to make radically better special effects.
For more sophisticated stuff, you'd use GetAllWeapons in Gadget code. This should return: weaponID, team, positions xyz, vector xyz, and the age of the projectile, in frames.
CreateWeapon() would require a valid WeaponDef id, a position, a vector, and a target (if target is not supplied, then it will not guide, etc.). Pretty simple- weapon X becomes weapon Y after Z frames, etc., but it could radically change things.
DestroyWeapon() would just do like it says, and remove a weapon from the gameworld, either with or without an explosion, just like DestroyUnit does.
Other than GetAllWeaponsInView() the other stuff should be sync only, imo, but I can see an argument for an unsync version for GetAllWeapons for really classy, long-term graphical gee-whiz- stuff like staging rockets, etc.
At any rate, having the above simple building blocks ought to allow for a lot of really new behavior.
GetWeaponsInView() would return the weaponID, team, positions xyz, vector xyz. No biggie, but it would give us tools to make radically better special effects.
For more sophisticated stuff, you'd use GetAllWeapons in Gadget code. This should return: weaponID, team, positions xyz, vector xyz, and the age of the projectile, in frames.
CreateWeapon() would require a valid WeaponDef id, a position, a vector, and a target (if target is not supplied, then it will not guide, etc.). Pretty simple- weapon X becomes weapon Y after Z frames, etc., but it could radically change things.
DestroyWeapon() would just do like it says, and remove a weapon from the gameworld, either with or without an explosion, just like DestroyUnit does.
Other than GetAllWeaponsInView() the other stuff should be sync only, imo, but I can see an argument for an unsync version for GetAllWeapons for really classy, long-term graphical gee-whiz- stuff like staging rockets, etc.
At any rate, having the above simple building blocks ought to allow for a lot of really new behavior.
Re: Weapon Manipulation Lua
This would also eb useful if exposed to the AIs, perhaps someone could help hoijui?
Re: Weapon Manipulation Lua
Er, you mean projectiles, right? Not weapons? Weapons are the things units have.
Re: Weapon Manipulation Lua
Those all look like call-outs to me...
Obviously the best way to do this is to have a lot of calls to get projectiles along the lines of the unit calls, but that might be a lot of work. Still, I think there should be a bit more to the call than a list of all projectiles with detailed information about each, because of how slow that could be. The cleanest method to have minimal implementation effort is probably to give it parameters for location, team, and weapondef, all optional.
Obviously the best way to do this is to have a lot of calls to get projectiles along the lines of the unit calls, but that might be a lot of work. Still, I think there should be a bit more to the call than a list of all projectiles with detailed information about each, because of how slow that could be. The cleanest method to have minimal implementation effort is probably to give it parameters for location, team, and weapondef, all optional.
Re: Weapon Manipulation Lua
if i have to put it into the AI interface, i would need help, yes.
well.. AF, you think it could be of use to AIs if they could get a list of all weapons?
..i think i am t odull for this at the moment.
well.. AF, you think it could be of use to AIs if they could get a list of all weapons?
..i think i am t odull for this at the moment.
Re: Weapon Manipulation Lua
Projectiles entransit, for example, knowing if theirs a nuke in your LOS, and predicting where its headed then moving all your units within the predicted trajectory and reclaiming units guaranteed to die in the blast.
Re: Weapon Manipulation Lua
I am sure trepan left projectile interfacing out of spring's lua interface for a good reason, probably speed.
edit: nevermind, it looks like he simply didn't get to it
edit: nevermind, it looks like he simply didn't get to it
Re: Weapon Manipulation Lua
1. Yes, talking about projectiles, sorry for being unclear- I mainly think of a weapon in terms of what its projectile behavior is, I know they aren't the same thing at the engine level.
2. If speed's a major issue, we have the whole ScriptWatchWeapon thing- a short-list of weapons to actually track. That part's already there, the problem being what information I can request about the projectile- the answer being... currently none.
However, I don't think speed's the issue. There are often fewer weapons than Units, and they're nowhere near as large a CPU drain (except for the missiles, which shouldn't be correcting their path every frame like they do, imo- one in 4, or one in 8, is probably enough).
I mean... the C++ code has to get every weapon id and do a bunch of heavy math on it every frame... if this all worked out, we might end up removing all of that stuff in the longer term, and putting it into Lua, just letting Spring handle the aiming conditions and the basic mechanics of motion.
2. If speed's a major issue, we have the whole ScriptWatchWeapon thing- a short-list of weapons to actually track. That part's already there, the problem being what information I can request about the projectile- the answer being... currently none.
However, I don't think speed's the issue. There are often fewer weapons than Units, and they're nowhere near as large a CPU drain (except for the missiles, which shouldn't be correcting their path every frame like they do, imo- one in 4, or one in 8, is probably enough).
I mean... the C++ code has to get every weapon id and do a bunch of heavy math on it every frame... if this all worked out, we might end up removing all of that stuff in the longer term, and putting it into Lua, just letting Spring handle the aiming conditions and the basic mechanics of motion.
Re: Weapon Manipulation Lua
Holdon a second, are we talking about projectiles as in only stuff like missiles and plasma cannons, or all weapons including lasers and whatnot? I throw my support behind being able to spawn ANY kind of weapon and giving these weapons either a vector direction or a target. Also, there should be an option for say, collidetargetonly.
Re: Weapon Manipulation Lua
But doing the filtering in lua is going to be much slower, with a large overhead to dump the projectiles into a table. There is a reason the functions to get units just return ids. All it really needs to not cause slowdowns is some basic engine-side filtering. Then that search for a nuke will only run through and make a minimal table.
Re: Weapon Manipulation Lua
I want to be able to spawn whatever weapons wherever as well, it would be so useful in making customizable and other non-set-state units.
Re: Weapon Manipulation Lua
+1Zpock wrote:I want to be able to spawn whatever weapons wherever as well, it would be so useful in making customizable and other non-set-state units.
Re: Weapon Manipulation Lua
[sarcasm]-1 Why the hell would I need that in Kustorion mod?[/sarcasm]Zpock wrote:I want to be able to spawn whatever weapons wherever as well, it would be so useful in making customizable and other non-set-state units.

Re: Weapon Manipulation Lua
So this is doable, I'm assuming? Please make this happen, would be really really awesome for almost all mods.