Page 1 of 1

Forcing a Weapon to Fire

Posted: 17 Aug 2008, 10:38
by REVENGE
Can I use either COB or LUA script, to force a particular weapon to fire as is (no aiming necessary, just fire)?

The effect I'm trying to get at here is basically have the unit drop a bomb from one of its pieces in place, or emit an explosion (not cosmetic).

I believe a workaround would be emit-sfx'ing the explosion, then doing the damage using lua, but if I can, say, force a projectile or bomb to spawn, that would be nicer.

EDIT: I also just thought of a possible workaround using a unit, can someone tell me how to spawn a unit using lua? (not nearly as nice, but could be used temporarily)

Re: Forcing a Weapon to Fire

Posted: 17 Aug 2008, 11:15
by Evil4Zerggin
COB does what you want.

emit-sfx 2048 + weapon number (first weapon is 0) will fire the weapon from that piece using the piece's position and orientation. This should include projectile, etc.

emit-sfx 4096 + weapon number detonates a weapon at the piece.

For an example, spawn armthund2 in CA, or use the laser bombers modoption.

This is moot, but to create a unit using Lua, you'll need to use Spring.CreateUnit(
string "defName",
number x, number y, number z,
(number facing | string "facing"),
number teamID ) -> number unitID

This is taken from Lua SyncedCtrl.

Re: Forcing a Weapon to Fire

Posted: 17 Aug 2008, 21:24
by REVENGE
Thanks so much, this will make things very easy.

Weird, must have just not read SyncedCtrl carefully enough...totally missed createunit.

Re: Forcing a Weapon to Fire

Posted: 17 Aug 2008, 22:33
by REVENGE
Hmm, I just noticed, however, that if you emit-sfx 4096 an explosion, the explosion will not follow noselfdamage=1 rules. Hmm...

Re: Forcing a Weapon to Fire

Posted: 18 Aug 2008, 05:17
by Evil4Zerggin
noselfdamage is pretty broken anyways >_>. You could try gadgeting something like this. Not sure how to get it to work with an emit-sfx explosion though.

Re: Forcing a Weapon to Fire

Posted: 18 Aug 2008, 05:25
by REVENGE
Hmm, well noselfdamage doesnt work with 4096, but it works with 2048 fine. A little hax makes it all ok.