Having trouble coding projectiles in LUA

The Sin Heartless

Voluntary Exile
So I started trying to implement the boomerang projectiles but had trouble with it. Probably need to switch out the current missile spawning function for something I can use to spawn the two projectiles with.

Spaghetti code:
addHook("MobjThinker", "A_Boomerang", [MT_BOOMERANGPROJ])
function A_Boomerang()
    if returntimer == nil then
        returntimer = 15
    end
    if MT_BOOMERANGPROJ.state == S_BOOMERANG and returntimer > 0 then
        returntimer = $ - 1
    end
    
    if MT_BOOMERANGPROJ.state == S_BOOMERANG and returntimer == 0 then
        P_InstaThrust(MT_BOOMERANGPROJ, -player.angle, 50*FRACUNIT)
    end
        
    if MT_BOOMERANGPROJ.x == player.mo.x and MT_BOOMERANGPROJ.y == player.mo.y then
    P_ExplodeMissile(MT_BOOMERANGPROJ)
    end
end
addHook ("ThinkFrame", function()
    for player in players.iterate do
        if player.mo.skin ~= "ann" then
            continue
    end
    
    if player.state == S_PLAY_MLEE then
        P_SPMAngle(player.mo, MT_BOOMERANGPROJ, player.mo.angle, [0, [MF2_INFLOAT]])
 

Who is viewing this thread (Total: 0, Members: 0, Guests: 0)

Back
Top