Weapon Manipulation Lua

Weapon Manipulation Lua

Requests for features in the spring code.

Moderator: Moderators

Post Reply
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Weapon Manipulation Lua

Post by Argh »

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.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Weapon Manipulation Lua

Post by AF »

This would also eb useful if exposed to the AIs, perhaps someone could help hoijui?
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Weapon Manipulation Lua

Post by KDR_11k »

Er, you mean projectiles, right? Not weapons? Weapons are the things units have.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Weapon Manipulation Lua

Post by lurker »

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.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Weapon Manipulation Lua

Post by hoijui »

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.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Weapon Manipulation Lua

Post by AF »

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.
User avatar
Peet
Malcontent
Posts: 4384
Joined: 27 Feb 2006, 22:04

Re: Weapon Manipulation Lua

Post by Peet »

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
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Weapon Manipulation Lua

Post by Argh »

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.
User avatar
REVENGE
Posts: 2382
Joined: 24 Aug 2006, 06:13

Re: Weapon Manipulation Lua

Post by REVENGE »

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.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Weapon Manipulation Lua

Post by lurker »

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.
User avatar
Zpock
Posts: 1218
Joined: 16 Sep 2004, 23:20

Re: Weapon Manipulation Lua

Post by Zpock »

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.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: Weapon Manipulation Lua

Post by FLOZi »

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.
+1
User avatar
Pendrokar
Posts: 658
Joined: 30 May 2007, 10:45

Re: Weapon Manipulation Lua

Post by Pendrokar »

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.
[sarcasm]-1 Why the hell would I need that in Kustorion mod?[/sarcasm] :P
User avatar
REVENGE
Posts: 2382
Joined: 24 Aug 2006, 06:13

Re: Weapon Manipulation Lua

Post by REVENGE »

So this is doable, I'm assuming? Please make this happen, would be really really awesome for almost all mods.
Post Reply

Return to “Feature Requests”