Nuke Blast on Unit's death

maxaug999

Chieftain
Joined
Apr 21, 2021
Messages
53
So I got a space ship unit that uses uranium. I was wondering if some one know how to cause a nuclear explosion (with LUA I imagine) when it dies ?

Max

Moderator Action: Moved to main C&C forum as that is where questions belong. leif
 
Last edited by a moderator:
As far as I'm aware, you couldn't cause the explosion directly, but there should be workarounds that are close enough to meet your needs. What I would try is something like this:

Code:
local iFireNuke = GameInfoTypes["MISSION_NUKE"]
local iNuke = GameInfoTypes["UNIT_ATOMIC_BOMB"]
local iSpaceShip = GameInfoTypes[""] -- insert the tag of your unit here

function SpaceShipExplodes(playerID, unitID, unitType, iX, iY, bDelay, killerID)
    if not bDelay then return end
    if unitType == iSpaceShip then
        local pPlayer = Players[playerID]
        local pBomb = pPlayer:InitUnit(iNuke, iX, iY)
        pBomb:PushMission(iFireNuke)
    end
end
GameEvents.UnitPrekill.Add(SpaceShipExplodes)

Which would spawn (and then immediately detonate) a nuke at the site where your unit is killed.
 
Top Bottom