Jump to content

Scripting Tutorial 8 - Ion Cannon and Nuke (from C&C '95)


Ransom

Recommended Posts

NOTICE: THIS TUTORIAL MAY BE OUTDATED! PLEASE READ: https://forum.multitheftauto.com/viewtopic.php?f=91&t=22270

Please post your comments about tutorial 8 scripts below. Thanks. 8)

The two seperate scripts for the ion cannon and nuke are posted below respectively. All of these two script's creation/commenting/video recording was done by me. So if you have any questions I'll be more than happy to answer them for you. ENJOY!

Edited by Guest
Link to comment
  • Replies 59
  • Created
  • Last Reply

Top Posters In This Topic

NOTICE: THIS SCRIPT IS OUTDATED FROM THE CURRENT SCRIPTING SYSTEM.

https://community.multitheftauto.com/index.php?p= ... ails&id=71

Tutorial 8a: Ion Cannon

:!: :!: :!: :!: :!: :!: :!: :!: :!: :!: :!: :!: :!: :!: :!: :!: :!: :!: :!: :!:

Start defining varibles, including a players array

root = getRootElement () 
players = {} 
  
outputChatBox ( "Ion cannon by Ransom" ) 
ion_rotx = 0 
ion_loops = 0 
ion_explosionTimer = 0 
ion_cannonActivated = false 
ion_cancelActivation = false 
ion_beamSize = 5 
ion_beamFlareSize = 5 
players = getElementsByType ( "player" ) 

Give all players on the server access to the weapons

addEventHandler ( "onResourceStart", root, "ResourceStartIonCannon" ) 
function ResourceStartIonCannon ( name, root ) 
if name ~= getThisResource() then return end 
    for k,v in players do 
    -- for all players in the "players" array 
    bindKey ( v, "f", "down", "placeIonCannonBeacon" ) 
    -- bind the key f for triggering the ion cannon 
    end 
end 
  
addEventHandler ( "onPlayerJoin", root, "ionPlayerJoin" ) 
function ionPlayerJoin () 
    bindKey ( source, "f", "down", "placeIonCannonBeacon" ) 
    --if a player joins after the resource loaded, bind their f key to trigger the ion cannon also 
end 

When the ion cannon key (f) is pressed, show the mouse cursor that will allow the triggering of the onPlayerClick function

function placeIonCannonBeacon ( player, key, state ) 
    if ( ion_cannonActivated == false ) and ( ion_cancelActivation == false ) and ( nuke_cancelActivation == false ) 
    and ( nuke_cannonActivated == false ) then 
    --These conditions prevent triggering the same weapon twice or triggering the other weapon at the same time. 
    --Both weapons cannot be triggered because explosions are stretched to the limit, explosions would be random 
    defineLaunchType = key 
    --This is used later on the onPlayerClick function to tell it what weapon to launch 
    showCursor ( player, true ) 
    ion_cancelActivation = true 
    else 
        if ion_cancelActivation == true then 
        showCursor ( player, false ) 
        end 
        --Prevents cursor from getting messed up if cursor is show for f or g and the opposite key is hit 
    ion_cancelActivation = false 
    --ion_cancelactivation is true when the cursor is showing. This is necessary along with asking if the actual 
    --weapon is active to prevent problems with the cursor and weapon activation between both weapons and themselves 
            if ion_cannonActivated == true then 
            outputChatBox ( "Ion cannon has already been activated", activator ) 
            else 
            outputChatBox ( "Cannot activate ion cannon and nuke at the same time", activator ) 
            end 
            --This statement says that if the ion cannon is already in use, display a meassage about it being in 
            --use on f press. Else, if the above conditions were not satisifed and the nuke is not active, it meant 
            --the ion cannon was active. Therefore, display the other message that both weapons cannot be used at 
            --the same time. 
    end 
end 

When the player clicks the mouse cursor, decide if the ion cannon is supposed to be launched and if so, set up the launch

addEventHandler ( "onPlayerClick", root, "playerClick" ) 
function playerClick ( button, state, clickedElement, x, y, z ) 
    if defineLaunchType == "f" then 
    --If the player clicked, we check if the key is equal to f or g. This will dictate which onPlayerClick function 
    --commences between the ion cannon and nuke scripts 
    ion_cancelActivation = false 
    --Since the weapon is now in use, you have no chance to abort by pressing the key again, therefore this is false 
    defineLaunchType = nil 
    --This must be reset to nil so it will not fire the ion cannon next time on click if g was pressed instead of f 
    --(which triggers nuke) 
    ion_beaconx = x 
    ion_beacony = y 
    ion_beaconz = z 
    --Set the ion cannon beacon (detonation spot) coordinates to the spot the mouse cursor clicked on the game map 
    local playerz, playerz, playerz = getElementPosition ( source ) 
    --For the above line, getElementPosition outputs 3 varibles, but I only want z so I overwrote 1 varible called 
    --playerz as the function went through and assigned the XYZ values to varible x, varible y, and varible z 
    --respectively. 
            if ( button == "left" ) and ( state == "down" ) and ( ion_cannonActivated == false ) then 
            --When the left mouse button is pressed down (not when released), if ion cannon is not active then 
            ion_cannonActivated = true 
            --Set this varible to true, which will be used to avoid double launches & double weapon usage 
            showCursor ( source, false ) 
            --Weapon beacon was chosen and the launch is initiating to that point. Hide cursor. 
            ionBeam = createMarker ( ion_beaconx, ion_beacony, ion_beaconz, "checkpoint", 5, 255, 255, 255, 255 ) 
            ionBeam2 = createMarker ( ion_beaconx, ion_beacony, ion_beaconz, "checkpoint", 5, 255, 255, 255, 255 ) 
            ionBeam3 = createMarker ( ion_beaconx, ion_beacony, ion_beaconz, "checkpoint", 5, 255, 255, 255, 255 ) 
            ionSecondaryBeam = createMarker ( ion_beaconx, ion_beacony, ion_beaconz, "checkpoint", 5, 255, 255, 
            255, 255 ) 
            ionSecondaryBeam2 = createMarker ( ion_beaconx, ion_beacony, ion_beaconz, "checkpoint", 5, 255, 255, 
            255, 255 ) 
            ionSecondaryBeam3 = createMarker ( ion_beaconx, ion_beacony, ion_beaconz, "checkpoint", 5, 255, 255, 
            255, 255 ) 
            ionBeamFlare = createMarker ( ion_beaconx, ion_beacony, ion_beaconz, "corona", 5, 255, 255, 255, 255 ) 
            --create six markers at the beacon point. The marker checkpoint will extend into the sky, but will end 
            --at the given z. 6 markers are used to ensure the beam looks full as I rapidly delete and recreate the 
            --markers in the next functions. 
            setTimer ( "ionExplosion", 50, 1 )   
            setTimer ( "ionShot", 100, 20 ) 
            setTimer ( "ionShot2", 150, 20 )  
            --Trigger the functions that will create the ion cannon shot and explosion imitation. 50ms 1 time, 100ms 
            --20 times, and 150ms 20 times respectively. 
            else 
            ion_activator = getPlayerFromNick ( source ) 
            showCursor ( source, false ) 
            --Makes sure the cursor will not show again for detonation unless the ion cannon is not active. 
            --Activator is used to display output messages in the other functions that activations/launches 
            --arent possible. 
            end 
    end 
end 

Create the illusion of a beam coming from space and gradually increasing in size (beam strike power)

function ionShot () 
    ion_beamSize = ion_beamSize + 1  
    setMarkerSize ( ionBeam, ion_beamSize )  
    setMarkerSize ( ionBeam2, ion_beamSize ) 
    setMarkerSize ( ionBeam3, ion_beamSize ) 
    if ( ion_beamSize == 6 ) then   
    setTimer ( "ionShotFlare", 3, 150 ) 
    end 
    --The first 3 markers making the ion beam are gradually increased at +10 in 1 second. When the function has 
    --looped 6 times (6/10 of a second), the flare (again, its a corona marker but I call it a flare) grow 
    --function is triggered. 
end 
  
function ionShot2 () 
    setMarkerSize ( ionSecondaryBeam, ion_beamSize ) 
    setMarkerSize ( ionSecondaryBeam2, ion_beamSize ) 
    setMarkerSize ( ionSecondaryBeam3, ion_beamSize ) 
    --These beams increase at a different rate, since beamSize is changing more rapidly in the ionShot function. 
    --They stay a little smaller than the main 3 markers and assist the "grow" look while keeping the beam visible 
    --while the markers change size. 
end 
  
function ionShotFlare () 
    ion_beamFlareSize = ion_beamFlareSize + 1 
    setMarkerSize ( ionBeamFlare, ion_beamFlareSize ) 
    --Every 3ms for 150 loops, the flare size increases. This makes a large glow that appears to be caused by the 
    --beam's light 
end 
  
function ionExplosion () 
    if ion_explosionTimer == 0 then 
    --We set this value when the script started. I do so I can keep looping through this function without 
    --resetting it. 
    setTimer ( "ionExplosion", 170, 18 ) 
    --Trigger this function to initiate 18 times in 170ms intervals. 
    ion_explosionTimer = 1 
    --Set the explosion timer flag to 1 so it is not done again with the looping (could have been true/false) 
    else 
    r = ion_beamSize --min/max blast radius: 1.5-28 
    --r will serve as our explosion radius. For the ion cannon, the explosions coming from the ion cannon 
    --will gradually increase distance from the center point in a circular motion, since I defined r as 
    --ion_beamSize, which is gradully increasing in size in the ionShot function at the same time. 
    angleup = randInt(0, 35999)/100 
    --Choose a random angle. A value between 0 and 35999 is divided by 100 because we want 
    --to have 2 random decimal places for as well, rather than just a whole integer. 
    explosionxcoord = r*math.cos(angleup) + ion_beaconx 
    explosionycoord = r*math.sin(angleup) + ion_beacony 
    --The x and y coordinates of the explosion will occur at a max radius of r away from the nuke beacon, 
    --in a circular shape. This is a fundamental, simple circle geometry formula. 
    createExplosion ( explosionxcoord, explosionycoord, ion_beaconz, 7 ) 
    --An explosion of type 7 is created, which is the tied as the largest with some others it is 
    --an aircraft explosion. 
    ion_loops = ion_loops + 1 
            if ion_loops == 16 then 
            --on the 16th loop of this function 
            ion_beamFlareSize = 200 
            --This triggers the flare to grow +50 immediately right as the beam is ending to create a little 
            --larger flash, just for effect as the beam is done 
            setTimer ( "ionFlareFade", 5, 200 ) 
            --The flarefade function is set to occur 200 times at 5ms to set the flare size to 0 quickly, as 
            --the beam has disappeared 
            elseif ion_loops == 18 then 
            --on the 18th loop of this function 
            ion_explosionTimer = 0 
            --Set the explosion timer to 0 for the next ion cannon launch, since this is the last loop 
            ion_loops = 0 
            --Set to 0 to trigger these events directly above on next ion cannon launch as well 
            ion_beamSize = 5 
            --Set to 0 to trigger the functions properly on the next ion cannon launch 
            destroyElement ( ionBeam ) 
            destroyElement ( ionSecondaryBeam )  
            destroyElement ( ionBeam2 ) 
            destroyElement ( ionSecondaryBeam2 ) 
            destroyElement ( ionBeam3 ) 
            destroyElement ( ionSecondaryBeam3 ) 
            --Destroy all the created checkpoint marker elements that made the beam 
            end 
    end 
end 
  
function ionFlareFade ()    
        setMarkerSize ( ionBeamFlare, ion_beamFlareSize ) 
        ion_beamFlareSize = ion_beamFlareSize - 1 
            if ion_beamFlareSize == 0 then 
            destroyElement ( ionBeamFlare ) 
            ion_cannonActivated = false 
            ion_beamFlareSize = 5 
            end 
--Each time the function loops, the flare gets -1 smaller. When it has a size of 0 and becomes invisible, it needs 
--to be deleted for the next ion cannon launch. No elements should stay created as they will pile up and eventually 
--crash you or the server. Finally, ion_cannonActivated is false, meaning the ion cannon is inactive and another 
--weapon use can be performed. 
end 

Link to comment

Tutorial 8b: Nuke

:!: :!: :!: :!: :!: :!: :!: :!: :!: :!: :!: :!: :!: :!: :!: :!: :!: :!: :!: :!:

Start defining varibles, including a players array

root = getRootElement () 
players = {} 
  
outputChatBox ( "Nulear Bomb by Ransom" ) 
--nuke_rotX = 0 
nuke_loops = 0 
nuke_explosionTimer = 0 
nuke_cloudRotationAngle = 0 
nuke_explosionLimiter = false 
nuke_cannonActivated = false 
nuke_cancelActivation = false 
players = getElementsByType ( "player" ) 

Give all players on the server access to the weapons

addEventHandler ( "onResourceStart", root, "ResourceStartNuke" ) 
function ResourceStartNuke ( name, root ) 
if name ~= getThisResource() then return end 
    for k,v in players do 
    -- for all players in the "players" array 
    bindKey ( v, "g", "down", "placeNukeBeacon" ) 
    -- bind the key g for triggering the nuke 
    end 
end 
  
addEventHandler ( "onPlayerJoin", root, "nukePlayerJoin" ) 
function nukePlayerJoin () 
    bindKey ( source, "g", "down", "placeNukeBeacon" ) 
    --if a player joins after the resource loaded, bind their g key to trigger the nuke also 
end 

When the nuke key (g) is pressed, show the mouse cursor that will allow the triggering of the onPlayerClick function

function placeNukeBeacon ( player, key, state ) 
    if ( nuke_cannonActivated == false ) and ( nuke_cancelActivation == false ) and 
    ( ion_cancelActivation == false ) and ( ion_cannonActivated == false ) then 
    --These conditions prevent triggering the same weapon twice or triggering the other weapon at the same time. 
    --Both weapons cannot be triggered because explosions are stretched to the limit, explosions would be random. 
    defineLaunchType = key 
    --This is used later on the onPlayerClick function to tell it what weapon to launch 
    showCursor ( player, true ) 
    nuke_cancelActivation = true 
    else 
        if nuke_cancelActivation == true then 
        showCursor ( player, false ) 
        end 
        --Prevents cursor from getting messed up if cursor is show for f or g and the opposite key is hit 
    nuke_cancelActivation = false 
    --nuke_cancelactivation is true when the cursor is showing. This is necessary along with asking if the actual 
    --weapon is active to prevent problems with the cursor and weapon activation between both weapons and themselves 
            if nuke_cannonActivated == true then 
            outputChatBox ( "Nuke has already been activated", activator ) 
            else 
            outputChatBox ( "Cannot activate ion cannon and nuke at the same time", activator ) 
            end 
            --This statement says that if the nuke is already in use, display a meassage about it being in use on g 
        --press else, if the above conditions were not satisifed and the nuke is not active, it meant the 
        --ioncannon was active. Therefore, display the other message that both weapons cannot be used at the 
        --same time. 
    end 
end 

When the player clicks the mouse cursor, decide if the nuke is supposed to be launched and if so, set up the launch

addEventHandler ( "onPlayerClick", root, "playerClickNuke" ) 
function playerClickNuke ( button, state, clickedElement, x, y, z ) 
    if defineLaunchType == "g" then 
    --If the player clicked, we check if the key is equal to f or g. This will dictate which onPlayerClick function 
    --commences between the ion cannon and nuke scripts 
    nuke_cancelActivation = false 
    --Since the weapon is now in use, you have no chance to abort by pressing the key again, therefore this is false 
    defineLaunchType = nil 
    --This must be reset to nil so it will not fire the nuke next time on click if f was pressed instead of g 
    --(which triggers ion) 
    nuke_beaconx = x 
    nuke_beacony = y 
    nuke_beaconz = z 
    --Set the nuke beacon (detonation spot) coordinates to the spot the mouse cursor clicked on the game map 
    local playerz, playerz, playerz = getElementPosition ( source ) 
    --I put a z height limit on the nuke, because the visual image of the bomb dropping can be broken if it is set 
    --to start an explosion/visually show object deletion in a mid-air point. To prevent this, I have assigned a max 
    --nuke height that is a little bit more than the z height of the player who activated it. There is a function to 
    --grab the actual z height at an X,Y position that I will implement later. For the above line, 
    --getElementPosition outputs 3 varibles, but I only want z so I overwrote 1 varible called playerz as the 
    --function went through and assigned the XYZ values to varible x, varible y, and varible z respectively. 
    nuke_maxBeamHeight = playerz + 2 
            if nuke_beaconz > nuke_maxBeamHeight then 
            nuke_beaconz = playerz + 3 
            end 
            --resets the nuke beacon z height if it is more than +3 above player z height 
                if ( button == "left" ) and ( state == "down" ) and ( nuke_cannonActivated == false ) then 
                --When the left mouse button is pressed down (not when released), if nuke is not active then 
                nuke_cannonActivated = true 
                --Set this varible to true, which will be used to avoid double launches & double weapon usage 
                showCursor ( source, false ) 
                --Weapon beacon was chosen and the launch is initiating to that point. Hide cursor. 
                setTimer ( "nukeExplosion", 2700, 1 ) 
                setTimer ( "nukeShot", 500, 1 ) 
                --Trigger these two functions that will drop and explode the nuke. Nuke drop triggers in 500ms, 
                --1 time only. The explosion is triggered at 2700ms which is when the nuke should be hitting 
                --the ground on the game map, it is also triggered 1 time. 
                else 
                activator = getPlayerFromNick ( source ) 
                showCursor ( source, false ) 
                --Makes sure the cursor will not show again for detonation unless the nuke is not active. Activator 
                --is used to display output messages in the other functions that activations/launches arent possible 
                end 
    end 
end 

Move 3 objects according to the beacon/detonation point to give the appearance of a falling nuclear bomb to the desired point

function nukeShot () 
    nuke1 = createObject ( 16340, nuke_beaconx, nuke_beacony, nuke_beaconz + 200 ) 
    nuke2 = createObject ( 3865, nuke_beaconx + 0.072265, nuke_beacony + 0.013731, nuke_beaconz + 196.153122 ) 
    nuke3 = createObject ( 1243, nuke_beaconx + 0.060547, nuke_beacony - 0.017578, nuke_beaconz + 189.075554 ) 
    --The 3 objects that make the nucelar bomb are called nuke1, nuke2, and nuke3. Math is done to piece the 
    --bomb together correctly at any given XYZ detonation coordinates. 
    setObjectRotation ( nuke1, math.deg(0.245437), math.deg(0), math.deg(3.150001) ) 
    setObjectRotation ( nuke2, math.deg(1.938950), math.deg(0), math.deg(-1.575) ) 
    setObjectRotation ( nuke3, math.deg(-1.767145), math.deg(0), math.deg(0) ) 
    --The objects must also be rotated after they are placed in the correct XYZ positions to get the bomb shape 
    --I created in the map editor at any given XYZ beacon/detonation point. 
    shotpath = nuke_beaconz - 200 
    moveObject ( nuke1, 5000, nuke_beaconx, nuke_beacony, shotpath, 259.9 ) --, 259 
    moveObject ( nuke2, 5000, nuke_beaconx + 0.072265, nuke_beacony + 0.013731, shotpath - 3.846878, 259.9 ) 
    moveObject ( nuke3, 5000, nuke_beaconx + 0.060547, nuke_beacony - 0.017578, shotpath - 10.924446, 259.9 ) 
    --To make all 3 pieces of the bomb stay together in the exact same shape, they must descend directly down. 
    --nuke2 and nuke3 drop paths are altered slightly to be directly below their created positions in the air. 
end 

Create the imitation of a nuclear explosion

function nukeExplosion () 
    if nuke_explosionTimer == 0 then 
    --We set this value when the script started. I do so I can keep looping through this function without 
    --resetting it. 
    setTimer ( "nukeExplosion", 170, 35 ) 
    --Trigger this function to initiate 35 times in 170ms intervals. 
    nuke_explosionTimer = 1 
    --Set the explosion timer flag to 1 so it is not done again with the looping (could have been true/false) 
    else 
    nuke_loops = nuke_loops + 1 
    --tells us how many times this function as been run through, which will be 35 in total. 
    r = randInt(1.5, 4.5) 
    --r will serve as our explosion radius. It can be a random value between 1.5 and 4.5 from the center of 
    --the circle. The math for this is below. 
    angleup = randInt(0, 35999)/100 
    --Choose a random angle. A value between 0 and 35999 is divided by 100 because we want 
    --to have 2 random decimal places for as well, rather than just a whole integer. 
    Explosionxcoord = r*math.cos(angleup) + nuke_beaconx 
    Explosionycoord = r*math.sin(angleup) + nuke_beacony 
    --The x and y coordinates of the explosion will occur at a max radius of 4.5 away from the nuke beacon, 
    --in a circular shape. This is a fundamental, simple circle geometry formula. 
        if nuke_loops == 1 then 
        nuke_nukeCloud = nuke_beaconz 
        createExplosion ( Explosionxcoord, Explosionycoord, nuke_nukeCloud, 7 ) 
        elseif nuke_loops == 2 then 
        nuke_nukeCloud = nuke_beaconz + 4 
        createExplosion ( Explosionxcoord, Explosionycoord, nuke_nukeCloud, 7 ) 
        --Up until 20 loops, a pillar of explosions is created with the above. 7 is the explosion type, 
        --which is tied with a couple others as the largest. 7 is a aircraft explosion. 
        elseif nuke_loops > 20 then 
        nuke_cloudRotationAngle = nuke_cloudRotationAngle + 22.5 
            if nuke_explosionLimiter == false then 
            nuke_cloudRadius = 7 
            Explosionxcoord = nuke_cloudRadius*math.cos(nuke_cloudRotationAngle) + nuke_beaconx 
            Explosionycoord = nuke_cloudRadius*math.sin(nuke_cloudRotationAngle) + nuke_beacony 
            createExplosion ( Explosionxcoord, Explosionycoord, nuke_nukeCloud, 7 ) 
            nuke_explosionLimiter = true 
            elseif nuke_explosionLimiter == true then 
            nuke_explosionLimiter = false 
            end 
        nuke_cloudRadius2 = 16 
        Explosionxcoord2 = nuke_cloudRadius2*math.cos(nuke_cloudRotationAngle) + nuke_beaconx 
        Explosionycoord2 = nuke_cloudRadius2*math.sin(nuke_cloudRotationAngle) + nuke_beacony 
        createExplosion ( Explosionxcoord2, Explosionycoord2, nuke_nukeCloud, 7 ) 
        else 
        nuke_nukeCloud = nuke_nukeCloud + 4 
        createExplosion ( Explosionxcoord, Explosionycoord, nuke_nukeCloud, 7 ) 
        end 
        --Since explosions are pushed to the limit, I have to make sure I can use the maximum amount without 
        --having explosions not appear. This required me to have the above explosions run every other time 
        --to create a mushroom cloud inner part (a circular area defined above), while at the same time creating 
        --an outter circle that also gave the look of a "full" mushroom cloud that won't have obvious visual holes. 
            if nuke_loops == 1 then 
            --On the first loop, the bright flare (as I call it, actually a corona marker), is created and 
            --increases in size. 
            nukeExplosionFlare = createMarker ( nuke_beaconx, nuke_beacony, nuke_beaconz, "corona", 0, 255, 255, 
            255, 255 ) 
            --The flare has an inital size of 0, and the R, G, B colors are 255, making it white. 
            nuke_flareSize = 0 
            setTimer ( "nukeFlareGrow", 1, 200 ) 
            --On the first loop, set the nuke_flareSize varible to 0, which will dictate the flare (corona) size 
            --in the nukeFlareGrow function below as it is looped. The timer initiates the function 200 times, 
            --every 1ms (so it takes 1/5 of a second to loop 200 times, thus making the bright flare). 
            elseif nuke_loops == 35 then 
            nuke_explosionTimer = 0 
            setTimer ( "nukeFlareFade", 1, 200 ) 
            nuke_loops = 0 
            end 
                --When this function has looped 35 times, the nuke has finished exploding and the flare must begin 
                --fading to look like it disappears naturally. Nuke loops is reset for the next nuke launch. 
    end 
end 
  
function nukeFlareGrow () 
        setMarkerSize ( nukeExplosionFlare, nuke_flareSize ) 
        nuke_flareSize = nuke_flareSize + 1 
            if nuke_flareSize == 200 then 
            destroyElement ( nuke1 ) 
            destroyElement ( nuke2 ) 
            destroyElement ( nuke3 ) 
            end 
            --The flare becomes +1 larger on each loop, and the nuke is destroyed when the flare reaches maximum 
            --size. It is triggered here as this is the point where it is safest to assume the objects are out 
            --of site. 
end 
  
function nukeFlareFade () 
    nuke_flareSize = nuke_flareSize - 1 
    setMarkerSize ( nukeExplosionFlare, nuke_flareSize ) 
    if nuke_flareSize == 0 then 
    destroyElement ( nukeExplosionFlare ) 
    nuke_cannonActivated = false 
    end 
    --Each time the function loops, the flare gets -1 smaller. When it has a size of 0 and becomes invisible, 
    --it needs to be deleted for the next nuke launch. No elements should stay created as they will pile up and 
    --eventually crash you or the server. Finally, nuke_cannonActivated is false, meaning the nuke is inactive 
    --and another weapon use can be performed. 
end 

Link to comment
Woot. First to reply. Finally! Anyways, would this be possible to do without click. Say, you goto Area 52 and click on a spot on map or something. if you get what I mean.

Well theres many different ways you can trigger something to occur with Lua. For a future version, yes I was hoping to be able to click on a map, get player details, and confirm a launch to their location. Could maybe cycle through a players list, type players name... thousands of possibilites. Its sometimes hard to have a concrete answer though. It depends on your ability to manipulate the functions MTA has provided to get what you desire. Such things like Aeron makes (A.I. sam site rockets, hay climb tower) seem impossible at first, but it can be done.

Although the MTA team has provided the functions and events, they are amazed themselves sometimes by how we coordinate them with scripting and come up with impressive results such as the imitation of WMDs in this video. eai was particularly pleased with this one as well since he is also a big C&C fan. I hope to perhaps make a mode to use these weapons in a team game or something for the future. We'll see depending on my time. I'd probably produce it this summer if anything.

Link to comment
Very cool! Best tutorial subject so far :D I have 1 question can you make a explosion like this shape?

nukebc3.jpg

Yes, that was the shape I was going for. If you read the code you'll see I did it in this way because I'm strecthing explosions to the GTA limit pretty much. You could make it more expansive but the completion time would be slower since you can only do so many explosions at once. I'll try to make a splash pool of explosions on the ground radius before I start the cloud but it may look too slow or glitchy. If I do, it should resemble your picture pretty well. The width of the middle part could be imitated more if you expand the radius of explosions as the nuke goes upward. Even if I can't make a better explosion cloud, when the flash goes off for the nuke explosion, I'll be defining an instant kill radius anyhow. Its not completed yet, but the visuals are pretty accurate already.

Also note for this same reason that the two weapons can NOT be launched at the same time. Many explosions would occur sporadically between them and ruin the visuals. The exact explosion limit you ask? From my testing and timing of these weapons as I recall the max stretch was 60 explosions at once (from the explosion to the time the smoke animation clears which takes considerably longer).

Link to comment
Can you make a Scud Storm to? like in C&C Generals

like this:

Generals-GLA-ScudStorm.jpg

Yep. Matter of fact it would just be a matter of adding more missile objects and more timings (for seperate missiles/explosions to create seperate heights). It would require you to define certain explosion locations so the impact of each appears to explode. Plus, if you wouldn't want them to keep the same shape you'd use random varibles between two numbers much like I did for the explosion cloud for my nuke. It would be considerably harder to script because it would be long unless you were advanced enough to use looping really well to overwrite varibles and such.

I have made "ion cannon" in sa-mp, but it's far not that realistic. Thanks for this tutorial.

Before this?! :shock:

Link to comment

I just thought of an idea. It must be possible to make some kind of DBZ game-mode with this :lol:. That in combination with Low Grav could work. Just make the ION blast smaller and come out of the player's hand. Maybe I should learn scripting and put all these tutorials to good use :P

Link to comment
I have made "ion cannon" in sa-mp, but it's far not that realistic. Thanks for this tutorial.

Before this?! :shock:

Yeah. I has made advanced mode, which mixes CS, UT and some other teamplay games. I have made lots of maps, voting for the next map, cs_, de_, dd_, es_, as_, tdm_ and ctf_ modes and a HUGE shop with all the weapons and some extra items. And ion cannon was one of them. :roll:

Link to comment
I have made "ion cannon" in sa-mp, but it's far not that realistic. Thanks for this tutorial.

Before this?! :shock:

Yeah. I has made advanced mode, which mixes CS, UT and some other teamplay games. I have made lots of maps, voting for the next map, cs_, de_, dd_, es_, as_, tdm_ and ctf_ modes and a HUGE shop with all the weapons and some extra items. And ion cannon was one of them. :roll:

The proof is in the pudding, but since BrophY ate all the pudding, a screenshot will suffice.

Link to comment
I just thought of an idea. It must be possible to make some kind of DBZ game-mode with this :lol:. That in combination with Low Grav could work. Just make the ION blast smaller and come out of the player's hand. Maybe I should learn scripting and put all these tutorials to good use :P

I actually made a script a while back where you could jump real high, glide on air, teleport around and shoot fireballs using key combinations (think hadooken).

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...