How to remove the Impulse from a unit

How to remove the Impulse from a unit

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
TheFatController
Balanced Annihilation Developer
Posts: 1177
Joined: 10 Dec 2006, 18:46

How to remove the Impulse from a unit

Post by TheFatController »

It seems UnitPreDamaged still applies the full impulse to a unit even if you return 0.

I need a hack to make the 0 damage units take no impulse at all but haven't found a solution yet, turning MoveCtrl on and off 5 frames later doesn't work and neither does SetUnitVelocity or applying negative values from GetUnitVelocity to AddUnitImpulse...

Can anyone advise please on the best way to remove a unit's impulse considering the above?
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: How to remove the Impulse from a unit

Post by Forboding Angel »

you mean weapon impulse?

impulseBoost = 0,
impulseFactor = 0,

works fine for me.
User avatar
Evil4Zerggin
Posts: 557
Joined: 16 May 2007, 06:34

Re: How to remove the Impulse from a unit

Post by Evil4Zerggin »

I believe he means via Lua, for example when adding special weapon behaviors using a gadget. Unfortunately, as far as I can tell, there is no way in Lua to read the value of unit->residualImpulse, so it appears you are stuck short of performing ridiculous calculations (e.g. simulating weapon impulse in Lua instead of using the engine).

BTW guess how impulse to ground units is removed:

Code: Select all

void CUnit::SlowUpdate()
{
[...]
  residualImpulse *= 0.6f;
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: How to remove the Impulse from a unit

Post by imbaczek »

movectrl?
User avatar
TheFatController
Balanced Annihilation Developer
Posts: 1177
Joined: 10 Dec 2006, 18:46

Re: How to remove the Impulse from a unit

Post by TheFatController »

It seems to retain its impulse somehow, in this case the unit is a commander and sometimes MoveCtrl even if you move it onto the ground it'll then perform a wierd slow motion flip on the spot then explode from falling damage.

Other idea from sleeping on it - silently destroy and swap the unit for an untainted one :?
Last edited by TheFatController on 02 Sep 2009, 13:24, edited 1 time in total.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: How to remove the Impulse from a unit

Post by KDR_11k »

Give it a HUEG mass?
Post Reply

Return to “Lua Scripts”