• 19 Juillet 2019, 18:52:14


Auteur Sujet: Tutorial 8b: Nuke  (Lu 6988 fois)

0 Membres et 1 Invité sur ce sujet

Hors ligne spykerc8

  • *
  • 'The GTAOnline.fr GodFather'
  • Messages: 3821
    • Voir le profil
    • http://www.gtaonline.fr
Tutorial 8b: Nuke
« le: 30 Mars 2007, 19:26:00 »
[yt=425,350]xD4pHYISHRM[/yt]

Lien du script : http://mtasa.com/scripts/script8b.nuke.lua
Vidéo HD :

Préparation du script : définition des variables, des array...

Code: Lua
  1. root = getRootElement ()
  2. players = {}
  3.  
  4. outputChatBox ( "Nulear Bomb by Ransom" )
  5. --nuke_rotX = 0
  6. nuke_loops = 0
  7. nuke_explosionTimer = 0
  8. nuke_cloudRotationAngle = 0
  9. nuke_explosionLimiter = false
  10. nuke_cannonActivated = false
  11. nuke_cancelActivation = false
  12. players = getElementsByType ( "player" )


Donne à tous les joueurs accès à la commande

Code: Lua
  1. addEventHandler ( "onResourceStart", root, "ResourceStartNuke" )
  2. function ResourceStartNuke ( name, root )
  3. if name ~= getThisResource() then return end
  4.         for k,v in players do
  5.         -- for all players in the "players" array
  6.         bindKey ( v, "g", "down", "placeNukeBeacon" )
  7.         -- bind the key g for triggering the nuke
  8.         end
  9. end
  10.  
  11. addEventHandler ( "onPlayerJoin", root, "nukePlayerJoin" )
  12. function nukePlayerJoin ()
  13.         bindKey ( source, "g", "down", "placeNukeBeacon" )
  14.         --if a player joins after the resource loaded, bind their g key to trigger the nuke also
  15. end


Quand la touche 'g' est utilisée, le curseur de la sourie s'active.

Code: Lua
  1. function placeNukeBeacon ( player, key, state )
  2.         if ( nuke_cannonActivated == false ) and ( nuke_cancelActivation == false ) and
  3.         ( ion_cancelActivation == false ) and ( ion_cannonActivated == false ) then
  4.         --These conditions prevent triggering the same weapon twice or triggering the other weapon at the same time.
  5.         --Both weapons cannot be triggered because explosions are stretched to the limit, explosions would be random.
  6.         defineLaunchType = key
  7.         --This is used later on the onPlayerClick function to tell it what weapon to launch
  8.         showCursor ( player, true )
  9.         nuke_cancelActivation = true
  10.         else
  11.         if nuke_cancelActivation == true then
  12.                 showCursor ( player, false )
  13.                 end
  14.                 --Prevents cursor from getting messed up if cursor is show for f or g and the opposite key is hit
  15.     nuke_cancelActivation = false
  16.         --nuke_cancelactivation is true when the cursor is showing. This is necessary along with asking if the actual
  17.         --weapon is active to prevent problems with the cursor and weapon activation between both weapons and themselves
  18.             if nuke_cannonActivated == true then
  19.             outputChatBox ( "Nuke has already been activated", activator )
  20.             else
  21.             outputChatBox ( "Cannot activate ion cannon and nuke at the same time", activator )
  22.             end
  23.             --This statement says that if the nuke is already in use, display a meassage about it being in use on g
  24.                 --press else, if the above conditions were not satisifed and the nuke is not active, it meant the
  25.                 --ioncannon was active. Therefore, display the other message that both weapons cannot be used at the
  26.                 --same time.
  27.         end
  28. end

Quand le joueur utilise les boutons de sa souris

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

Bouge les objets selon le points d'arrivée de la détonation et crée l'illusion de l'explosion

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

Créer l'illusion d'une explosion nucléaire

Code: Lua
  1. function nukeExplosion ()
  2.         if nuke_explosionTimer == 0 then
  3.         --We set this value when the script started. I do so I can keep looping through this function without
  4.         --resetting it.
  5.         setTimer ( "nukeExplosion", 170, 35 )
  6.         --Trigger this function to initiate 35 times in 170ms intervals.
  7.         nuke_explosionTimer = 1
  8.         --Set the explosion timer flag to 1 so it is not done again with the looping (could have been true/false)
  9.         else
  10.         nuke_loops = nuke_loops + 1
  11.         --tells us how many times this function as been run through, which will be 35 in total.
  12.         r = randInt(1.5, 4.5)
  13.         --r will serve as our explosion radius. It can be a random value between 1.5 and 4.5 from the center of
  14.         --the circle. The math for this is below.
  15.         angleup = randInt(0, 35999)/100
  16.         --Choose a random angle. A value between 0 and 35999 is divided by 100 because we want
  17.         --to have 2 random decimal places for as well, rather than just a whole integer.
  18.         Explosionxcoord = r*math.cos(angleup) + nuke_beaconx
  19.         Explosionycoord = r*math.sin(angleup) + nuke_beacony
  20.         --The x and y coordinates of the explosion will occur at a max radius of 4.5 away from the nuke beacon,
  21.         --in a circular shape. This is a fundamental, simple circle geometry formula.
  22.                 if nuke_loops == 1 then
  23.                 nuke_nukeCloud = nuke_beaconz
  24.                 createExplosion ( Explosionxcoord, Explosionycoord, nuke_nukeCloud, 7 )
  25.                 elseif nuke_loops == 2 then
  26.                 nuke_nukeCloud = nuke_beaconz + 4
  27.                 createExplosion ( Explosionxcoord, Explosionycoord, nuke_nukeCloud, 7 )
  28.                 --Up until 20 loops, a pillar of explosions is created with the above. 7 is the explosion type,
  29.                 --which is tied with a couple others as the largest. 7 is a aircraft explosion.
  30.                 elseif nuke_loops > 20 then
  31.                 nuke_cloudRotationAngle = nuke_cloudRotationAngle + 22.5
  32.                         if nuke_explosionLimiter == false then
  33.                         nuke_cloudRadius = 7
  34.                         Explosionxcoord = nuke_cloudRadius*math.cos(nuke_cloudRotationAngle) + nuke_beaconx
  35.                         Explosionycoord = nuke_cloudRadius*math.sin(nuke_cloudRotationAngle) + nuke_beacony
  36.                         createExplosion ( Explosionxcoord, Explosionycoord, nuke_nukeCloud, 7 )
  37.                         nuke_explosionLimiter = true
  38.                         elseif nuke_explosionLimiter == true then
  39.                         nuke_explosionLimiter = false
  40.                         end
  41.                 nuke_cloudRadius2 = 16
  42.                 Explosionxcoord2 = nuke_cloudRadius2*math.cos(nuke_cloudRotationAngle) + nuke_beaconx
  43.                 Explosionycoord2 = nuke_cloudRadius2*math.sin(nuke_cloudRotationAngle) + nuke_beacony
  44.                 createExplosion ( Explosionxcoord2, Explosionycoord2, nuke_nukeCloud, 7 )
  45.                 else
  46.             nuke_nukeCloud = nuke_nukeCloud + 4
  47.             createExplosion ( Explosionxcoord, Explosionycoord, nuke_nukeCloud, 7 )
  48.             end
  49.                 --Since explosions are pushed to the limit, I have to make sure I can use the maximum amount without
  50.                 --having explosions not appear. This required me to have the above explosions run every other time
  51.                 --to create a mushroom cloud inner part (a circular area defined above), while at the same time creating
  52.                 --an outter circle that also gave the look of a "full" mushroom cloud that won't have obvious visual holes.
  53.                         if nuke_loops == 1 then
  54.                         --On the first loop, the bright flare (as I call it, actually a corona marker), is created and
  55.                         --increases in size.
  56.                   nukeExplosionFlare = createMarker ( nuke_beaconx, nuke_beacony, nuke_beaconz, "corona", 0, 255, 255,
  57.                         255, 255 )
  58.                         --The flare has an inital size of 0, and the R, G, B colors are 255, making it white.
  59.                         nuke_flareSize = 0
  60.                         setTimer ( "nukeFlareGrow", 1, 200 )
  61.                         --On the first loop, set the nuke_flareSize varible to 0, which will dictate the flare (corona) size
  62.                         --in the nukeFlareGrow function below as it is looped. The timer initiates the function 200 times,
  63.                         --every 1ms (so it takes 1/5 of a second to loop 200 times, thus making the bright flare).
  64.                         elseif nuke_loops == 35 then
  65.                         nuke_explosionTimer = 0
  66.                         setTimer ( "nukeFlareFade", 1, 200 )
  67.                         nuke_loops = 0
  68.                         end
  69.                                 --When this function has looped 35 times, the nuke has finished exploding and the flare must begin
  70.                                 --fading to look like it disappears naturally. Nuke loops is reset for the next nuke launch.
  71.         end
  72. end
  73.  
  74. function nukeFlareGrow ()
  75.             setMarkerSize ( nukeExplosionFlare, nuke_flareSize )
  76.         nuke_flareSize = nuke_flareSize + 1
  77.                 if nuke_flareSize == 200 then
  78.                 destroyElement ( nuke1 )
  79.                         destroyElement ( nuke2 )
  80.                         destroyElement ( nuke3 )
  81.                 end
  82.                 --The flare becomes +1 larger on each loop, and the nuke is destroyed when the flare reaches maximum
  83.                 --size. It is triggered here as this is the point where it is safest to assume the objects are out
  84.                         --of site.
  85. end
  86.  
  87. function nukeFlareFade ()
  88.         nuke_flareSize = nuke_flareSize - 1
  89.         setMarkerSize ( nukeExplosionFlare, nuke_flareSize )
  90.         if nuke_flareSize == 0 then
  91.         destroyElement ( nukeExplosionFlare )
  92.         nuke_cannonActivated = false
  93.         end
  94.         --Each time the function loops, the flare gets -1 smaller. When it has a size of 0 and becomes invisible,
  95.         --it needs to be deleted for the next nuke launch. No elements should stay created as they will pile up and
  96.         --eventually crash you or the server. Finally, nuke_cannonActivated is false, meaning the nuke is inactive
  97.         --and another weapon use can be performed.
  98. end

CODE COMPLET :

Code: Lua
  1. --==============================================================================================================
  2. --Start defining varibles, including a players array
  3. --==============================================================================================================
  4. root = getRootElement ()
  5. players = {}
  6.  
  7. outputChatBox ( "Nulear Bomb by Ransom" )
  8. --nuke_rotX = 0
  9. nuke_loops = 0
  10. nuke_explosionTimer = 0
  11. nuke_cloudRotationAngle = 0    
  12. nuke_explosionLimiter = false
  13. nuke_cannonActivated = false
  14. nuke_cancelActivation = false
  15. players = getElementsByType ( "player" )
  16.  
  17. --==============================================================================================================
  18. --Give all players on the server access to the weapons
  19. --==============================================================================================================       
  20. addEventHandler ( "onResourceStart", root, "ResourceStartNuke" )
  21. function ResourceStartNuke ( name, root )
  22. if name ~= getThisResource() then return end
  23.         for k,v in players do
  24.         -- for all players in the "players" array
  25.         bindKey ( v, "g", "down", "placeNukeBeacon" )
  26.         -- bind the key g for triggering the nuke
  27.         end
  28. end
  29.  
  30. addEventHandler ( "onPlayerJoin", root, "nukePlayerJoin" )
  31. function nukePlayerJoin ()
  32.         bindKey ( source, "g", "down", "placeNukeBeacon" )
  33.         --if a player joins after the resource loaded, bind their g key to trigger the nuke also
  34. end
  35.  
  36. --====================================================================================================================
  37. --When the nuke key (g) is pressed, show the mouse cursor that will allow the triggering of the onPlayerClick function
  38. --====================================================================================================================
  39. function placeNukeBeacon ( player, key, state )                                                                      
  40.         if ( nuke_cannonActivated == false ) and ( nuke_cancelActivation == false ) and ( ion_cancelActivation == false ) and ( ion_cannonActivated == false ) then
  41.         --These conditions prevent triggering the same weapon twice or triggering the other weapon at the same time.
  42.         --Both weapons cannot be triggered because explosions are stretched to the limit, explosions would be random.
  43.         defineLaunchType = key
  44.         --This is used later on the onPlayerClick function to tell it what weapon to launch
  45.         showCursor ( player, true )
  46.         nuke_cancelActivation = true
  47.         else
  48.         if nuke_cancelActivation == true then
  49.                 showCursor ( player, false )
  50.                 end
  51.                 --Prevents cursor from getting messed up if cursor is show for f or g and the opposite key is hit
  52.     nuke_cancelActivation = false
  53.         --nuke_cancelactivation is true when the cursor is showing. This is necessary along with asking if the actual
  54.         --weapon is active to prevent problems with the cursor and weapon activation between both weapons and themselves.  
  55.                 if nuke_cannonActivated == true then
  56.                 outputChatBox ( "Nuke has already been activated", activator )
  57.                 else
  58.                 outputChatBox ( "Cannot activate ion cannon and nuke at the same time", activator )
  59.                 end
  60.                 --This statement says that if the nuke is already in use, display a meassage about it being in use on g press.
  61.                 --else, if the above conditions were not satisifed and the nuke is not active, it meant the ioncannon was
  62.                 --active. Therefore, display the other message that both weapons cannot be used at the same time.
  63.         end
  64. end
  65.  
  66. --====================================================================================================================
  67. --When the player clicks the mouse cursor, decide if the nuke is supposed to be launched and if so, set up the launch
  68. --====================================================================================================================
  69. addEventHandler ( "onPlayerClick", root, "playerClickNuke" )
  70. function playerClickNuke ( button, state, clickedElement, x, y, z )
  71.         if defineLaunchType == "g" then
  72.         --If the player clicked, we check if the key is equal to f or g. This will dictate which onPlayerClick function
  73.         --commences between the ion cannon and nuke scripts
  74.         nuke_cancelActivation = false
  75.         --Since the weapon is now in use, you have no chance to abort by pressing the key again, therefore this is false
  76.         defineLaunchType = nil
  77.     --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)
  78.         nuke_beaconx = x
  79.         nuke_beacony = y
  80.         nuke_beaconz = z
  81.         --Set the nuke beacon (detonation spot) coordinates to the spot the mouse cursor clicked on the game map
  82.         local playerz, playerz, playerz = getElementPosition ( source )
  83.         --I put a z height limit on the nuke, because the visual image of the bomb dropping can be broken if it is set
  84.         --to start an explosion/visually show object deletion in a mid-air point. To prevent this, I have assigned a max
  85.         --nuke height that is a little bit more than the z height of the player who activated it. There is a function to
  86.         --grab the actual z height at an X,Y position that I will implement later. For the above line, getElementPosition
  87.         --outputs 3 varibles, but I only want z so I overwrote 1 varible called playerz as the function went through and
  88.         --assigned the XYZ values to varible x, varible y, and varible z respectively.
  89.         nuke_maxBeamHeight = playerz + 2
  90.                         if nuke_beaconz > nuke_maxBeamHeight then
  91.                         nuke_beaconz = playerz + 3
  92.                         end
  93.                         --resets the nuke beacon z height if it is more than +3 above player z height
  94.                                 if ( button == "left" ) and ( state == "down" ) and ( nuke_cannonActivated == false ) then
  95.                                 --When the left mouse button is pressed down (not when released), if nuke is not active then
  96.                                 nuke_cannonActivated = true
  97.                                 --Set this varible to true, which will be used to avoid double launches & double weapon usage
  98.                                 showCursor ( source, false )
  99.                                 --Weapon beacon was chosen and the launch is initiating to that point. Hide cursor.
  100.                                 setTimer ( "nukeExplosion", 2700, 1 )
  101.                                 setTimer ( "nukeShot", 500, 1 )
  102.                                 --Trigger these two functions that will drop and explode the nuke. Nuke drop triggers in 500ms,
  103.                                 --1 time only. The explosion is triggered at 2700ms which is when the nuke should be hitting
  104.                                 --the ground on the game map, it is also triggered 1 time.
  105.                                 else
  106.                                 activator = getPlayerFromNick ( source )
  107.                                 showCursor ( source, false )
  108.                                 --Makes sure the cursor will not show again for detonation unless the nuke is not active. Activator
  109.                                 --is used to display output messages in the other functions that activations/launches arent possible.
  110.                                 end
  111.         end
  112. end
  113.  
  114. --=============================================================================================================================
  115. --Move 3 objects according to the beacon/detonation point to give the appearance of a falling nuclear bomb to the desired point
  116. --=============================================================================================================================
  117. function nukeShot ()
  118.         nuke1 = createObject ( 16340, nuke_beaconx, nuke_beacony, nuke_beaconz + 200 )
  119.         nuke2 = createObject ( 3865, nuke_beaconx + 0.072265, nuke_beacony + 0.013731, nuke_beaconz + 196.153122 )
  120.         nuke3 = createObject ( 1243, nuke_beaconx + 0.060547, nuke_beacony - 0.017578, nuke_beaconz + 189.075554 )
  121.         --The 3 objects that make the nucelar bomb are called nuke1, nuke2, and nuke3. Math is done to piece the
  122.         --bomb together correctly at any given XYZ detonation coordinates.
  123.         setObjectRotation ( nuke1, math.deg(0.245437), math.deg(0), math.deg(3.150001) )
  124.         setObjectRotation ( nuke2, math.deg(1.938950), math.deg(0), math.deg(-1.575) )
  125.         setObjectRotation ( nuke3, math.deg(-1.767145), math.deg(0), math.deg(0) )
  126.         --The objects must also be rotated after they are placed in the correct XYZ positions to get the bomb shape
  127.         --I created in the map editor at any given XYZ beacon/detonation point.
  128.         shotpath = nuke_beaconz - 200
  129.         moveObject ( nuke1, 5000, nuke_beaconx, nuke_beacony, shotpath, 259.9 ) --, 259
  130.         moveObject ( nuke2, 5000, nuke_beaconx + 0.072265, nuke_beacony + 0.013731, shotpath - 3.846878, 259.9 )
  131.         moveObject ( nuke3, 5000, nuke_beaconx + 0.060547, nuke_beacony - 0.017578, shotpath - 10.924446, 259.9 )
  132.         --To make all 3 pieces of the bomb stay together in the exact same shape, they must descend directly down.
  133.         --nuke2 and nuke3 drop paths are altered slightly to be directly below their created positions in the air.
  134. end
  135.  
  136. --==============================================================================================================
  137. --Create the imitation of a nuclear explosion
  138. --==============================================================================================================      
  139. function nukeExplosion ()
  140.         if nuke_explosionTimer == 0 then
  141.         --We set this value when the script started. I do so I can keep looping through this function without
  142.         --resetting it.
  143.         setTimer ( "nukeExplosion", 170, 35 )
  144.         --Trigger this function to initiate 35 times in 170ms intervals.
  145.         nuke_explosionTimer = 1
  146.         --Set the explosion timer flag to 1 so it is not done again with the looping (could have been true/false)
  147.         else
  148.         nuke_loops = nuke_loops + 1
  149.         --tells us how many times this function as been run through, which will be 35 in total.
  150.         r = randInt(1.5, 4.5)
  151.         --r will serve as our explosion radius. It can be a random value between 1.5 and 4.5 from the center of
  152.         --the circle. The math for this is below.
  153.         angleup = randInt(0, 35999)/100
  154.         --Choose a random angle. A value between 0 and 35999 is divided by 100 because we want
  155.         --to have 2 random decimal places for as well, rather than just a whole integer.
  156.         Explosionxcoord = r*math.cos(angleup) + nuke_beaconx
  157.         Explosionycoord = r*math.sin(angleup) + nuke_beacony
  158.         --The x and y coordinates of the explosion will occur at a max radius of 4.5 away from the nuke beacon,
  159.         --in a circular shape. This is a fundamental, simple circle geometry formula.
  160.                 if nuke_loops == 1 then
  161.                 nuke_nukeCloud = nuke_beaconz
  162.                 createExplosion ( Explosionxcoord, Explosionycoord, nuke_nukeCloud, 7 )
  163.                 elseif nuke_loops == 2 then
  164.                 nuke_nukeCloud = nuke_beaconz + 4
  165.                 createExplosion ( Explosionxcoord, Explosionycoord, nuke_nukeCloud, 7 )
  166.                 --Up until 20 loops, a pillar of explosions is created with the above. 7 is the explosion type,
  167.                 --which is tied with a couple others as the largest. 7 is a aircraft explosion.
  168.                 elseif nuke_loops > 20 then
  169.                 nuke_cloudRotationAngle = nuke_cloudRotationAngle + 22.5  
  170.                         if nuke_explosionLimiter == false then
  171.                         nuke_cloudRadius = 7
  172.                         Explosionxcoord = nuke_cloudRadius*math.cos(nuke_cloudRotationAngle) + nuke_beaconx --recalculate
  173.                         Explosionycoord = nuke_cloudRadius*math.sin(nuke_cloudRotationAngle) + nuke_beacony --recalculate              
  174.                         createExplosion ( Explosionxcoord, Explosionycoord, nuke_nukeCloud, 7 )
  175.                         nuke_explosionLimiter = true
  176.                         elseif nuke_explosionLimiter == true then
  177.                         nuke_explosionLimiter = false
  178.                         end            
  179.                 nuke_cloudRadius2 = 16  
  180.                 Explosionxcoord2 = nuke_cloudRadius2*math.cos(nuke_cloudRotationAngle) + nuke_beaconx
  181.                 Explosionycoord2 = nuke_cloudRadius2*math.sin(nuke_cloudRotationAngle) + nuke_beacony                  
  182.                 createExplosion ( Explosionxcoord2, Explosionycoord2, nuke_nukeCloud, 7 )
  183.                 else
  184.             nuke_nukeCloud = nuke_nukeCloud + 4
  185.             createExplosion ( Explosionxcoord, Explosionycoord, nuke_nukeCloud, 7 )
  186.             end
  187.                 --Since explosions are pushed to the limit, I have to make sure I can use the maximum amount without
  188.                 --having explosions not appear. This required me to have the above explosions run every other time
  189.                 --to create a mushroom cloud inner part (a circular area defined above), while at the same time creating
  190.                 --an outter circle that also gave the look of a "full" mushroom cloud that won't have obvious visual holes.
  191.                         if nuke_loops == 1 then
  192.                         --On the first loop, the bright flare (as I call it, actually a corona marker), is created and increases in size.  
  193.                         nukeExplosionFlare = createMarker ( nuke_beaconx, nuke_beacony, nuke_beaconz, "corona", 0, 255, 255, 255, 255 )
  194.                         --The flare has an inital size of 0, and the R, G, B colors are 255, making it white.          
  195.                         nuke_flareSize = 0
  196.                         setTimer ( "nukeFlareGrow", 1, 200 )
  197.                         --On the first loop, set the nuke_flareSize varible to 0, which will dictate the flare (corona) size
  198.                         --in the nukeFlareGrow function below as it is looped. The timer initiates the function 200 times,
  199.                         --every 1ms (so it takes 1/5 of a second to loop 200 times, thus making the bright flare).
  200.                         elseif nuke_loops == 35 then
  201.                         nuke_explosionTimer = 0
  202.                         setTimer ( "nukeFlareFade", 1, 200 )
  203.                         nuke_loops = 0                         
  204.                         end
  205.                                 --When this function has looped 35 times, the nuke has finished exploding and the flare must begin
  206.                                 --fading to look like it disappears naturally. Nuke loops is reset for the next nuke launch.
  207.         end
  208. end
  209.  
  210. function nukeFlareGrow ()
  211.             setMarkerSize ( nukeExplosionFlare, nuke_flareSize )
  212.         nuke_flareSize = nuke_flareSize + 1
  213.                 if nuke_flareSize == 200 then
  214.                 destroyElement ( nuke1 )
  215.                         destroyElement ( nuke2 )
  216.                         destroyElement ( nuke3 )
  217.                 end
  218.                 --The flare becomes +1 larger on each loop, and the nuke is destroyed when the flare reaches maximum
  219.                 --size. It is triggered here as this is the point where it is safest to assume the objects are out of site.
  220. end
  221.  
  222. function nukeFlareFade ()
  223.         nuke_flareSize = nuke_flareSize - 1
  224.         setMarkerSize ( nukeExplosionFlare, nuke_flareSize )
  225.         if nuke_flareSize == 0 then
  226.         destroyElement ( nukeExplosionFlare )
  227.         nuke_cannonActivated = false
  228.         end
  229.         --Each time the function loops, the flare gets -1 smaller. When it has a size of 0 and becomes invisible, it needs
  230.         --to be deleted for the next nuke launch. No elements should stay created as they will pile up and eventually
  231.         --crash you or the server. Finally, nuke_cannonActivated is false, meaning the nuke is inactive and another weapon
  232.         --use can be performed.
  233. end
« Modifié: 30 Mars 2007, 19:28:52 par spykerc8 »


~ Leader honoraire de la FsK Team ~ -
~ Membre honoraire de la PCP Team ~

Co-fondateur de GTAO - Retraité de la communauté

"Nous ne sommes rien, soyons tout !"


Hors ligne FuriousKing

  • Best-Driver
  • *
  • The King Of Furious
  • Messages: 546
    • Voir le profil
Re : Tutorial 8b: Nuke
« Réponse #1 le: 31 Mars 2007, 14:07:04 »
Mouai un truc qui sert a rien dans un GTA lol .
Si on a acheter GTA c'est pour son ambiance pas du star-wars lol .

Hors ligne [DoK]Diablo

  • *
  • Criminel
  • Messages: 34
    • Voir le profil
    • www.dailymotion.com/DiabloQM
Re : Tutorial 8b: Nuke
« Réponse #2 le: 17 Mai 2007, 16:10:15 »
C'est pas du star wars  :D , c'est les super armes de C&C Générals,c'est sympatoche ce qu'il arrive a faire MTA, mais bon,faudrais qu'il en fasse profité les joueurs !!!
Mais d'un autre côté voir 50 0000 bombes éclaté c'est pas se qui pourait étre le mieu en mutli...