Advertisement
eldiegotee

Untitled

Nov 16th, 2022
697
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '/////////////////////////////Motor Grafico en DirectX 8///////////////////////////////
  2. '////////////////////////Extraccion de varios motores por ShaFTeR//////////////////////
  3. '///////////////////ORE - VBGORE - GSZAO - KKAO y algunos ejemplos de webs/////////////
  4. '**************************************************************************************
  5. Option Explicit
  6.  
  7. Public SangreTexture(1 To 4) As Direct3DTexture8
  8.  
  9. 'Texture for particle effects - this is handled differently then the rest of the graphics
  10.  
  11. Public WeatherEffectIndex As Integer
  12. Public OnRampage As Long
  13. Public OnRampageImg As Long
  14. Public OnRampageImgGrh As Integer
  15. Public LastEffect As Integer
  16.  
  17. Private Type effect
  18.     SizeP As Single
  19.     Ray As Byte
  20.     X As Single        'Location of effect
  21.    Y As Single
  22.     GoToX As Single        'Location to move to
  23.    GoToY As Single
  24.     KillWhenAtTarget As Boolean        'If the effect is at its target (GoToX/Y), then Progression is set to 0
  25.    KillWhenTargetLost As Boolean        'Kill the effect if the target is lost (sets progression = 0)
  26.    Gfx As Byte        'Particle texture used
  27.    Used As Boolean        'If the effect is in use
  28.    EffectNum As Byte        'What number of effect that is used
  29.    Modifier As Integer        'Misc variable (depends on the effect)
  30.    FloatSize As Long        'The size of the particles
  31.    Direction As Integer        'Misc variable (depends on the effect)
  32.    Particles() As Particle        'Information on each particle
  33.    Progression As Single        'Progression state, best to design where 0 = effect ends
  34.    Looping As Boolean
  35.     PartVertex() As TYPE_VERTEX        'Used to point render particles
  36.    PreviousFrame As Long        'Tick time of the last frame
  37.    ParticleCount As Integer        'Number of particles total
  38.    ParticlesLeft As Integer        'Number of particles left - only for non-repetitive effects
  39.    BindToChar As Integer        'Setting this value will bind the effect to move towards the character
  40.    BindSpeed As Single        'How fast the effect moves towards the character
  41.    BoundToMap As Byte        'If the effect is bound to the map or not (used only by the map editor)
  42.    TargetAA As Single
  43.     R As Single
  44.     g As Single
  45.     b As Single
  46.     a As Single
  47.     EcuationCount As Byte
  48.     Sng As Single        'Misc variable
  49.    size As Byte
  50. End Type
  51.  
  52. Public NumEffects As Byte        'Maximum number of effects at once
  53. Public effect() As effect        'List of all the active effects
  54.  
  55. 'Constants With The Order Number For Each Effect
  56.  
  57. Public Const EffectNum_Fire As Byte = 1        'Burn baby, burn! Flame from a central point that blows in a specified direction
  58. Public Const EffectNum_Snow As Byte = 2        'Snow that covers the screen - weather effect
  59. Public Const EffectNum_Heal As Byte = 3        'Healing effect that can bind to a character, ankhs float up and fade
  60. Public Const EffectNum_Bless As Byte = 4        'Following three effects are same: create a circle around the central point
  61. Public Const EffectNum_Protection As Byte = 5        ' (often the character) and makes the given particle on the perimeter
  62. Public Const EffectNum_Strengthen As Byte = 6        ' which float up and fade out
  63. Public Const EffectNum_Rain As Byte = 7        'Exact same as snow, but moves much faster and more alpha value - weather effect
  64. Public Const EffectNum_EquationTemplate As Byte = 8        'Template for creating particle effects through equations - a page with some equations can be found here: http://www.vbgore.com/modules.php?name=Forums&file=viewtopic&t=221
  65. Public Const EffectNum_Waterfall As Byte = 9        'Waterfall effect
  66. Public Const EffectNum_Summon As Byte = 10        'Summon effect
  67. Public Const EffectNum_Meditate As Byte = 11        'Medit effect
  68. Public Const EffectNum_Portal As Byte = 12        'Portal effect
  69. Public Const EffectNum_Atomic As Byte = 13        'Atomic Effect
  70. Public Const EffectNum_Circle As Byte = 14        'Outlined Circle Effect
  71. Public Const EffectNum_Raro As Byte = 15
  72. Public Const EffectNum_Lissajous As Byte = 16
  73. Public Const EffectNum_Apocalipsis As Byte = 17
  74. Public Const EffectNum_Humo As Byte = 18
  75. Public Const EffectNum_CherryBlossom As Byte = 19
  76. Public Const EffectNum_BloodSpray As Byte = 20
  77. Public Const EffectNum_BloodSplatter As Byte = 21
  78. Public Const EffectNum_LevelUP As Byte = 22        'Level Up Effect
  79. Public Const EffectNum_AnimatedSign As Byte = 23
  80. Public Const EffectNum_Galaxy As Byte = 24
  81. Public Const EffectNum_FancyThickCircle As Byte = 25
  82. Public Const EffectNum_Flower As Byte = 26
  83. Public Const EffectNum_Wormhole As Byte = 27
  84. Public Const EffectNum_HouseTeleport As Byte = 28        'Teleport To House Effect
  85. Public Const EffectNum_GuildTeleport As Byte = 29        'Teleport To Guild Meeting
  86. Public Const EffectNum_Rayo As Byte = 30        'Tormenta de Fuego
  87. Public Const EffectNum_LissajousMedit As Byte = 31
  88. Public Const EffectNum_Inmovilizar As Byte = 32
  89. Public Const EffectNum_ChangeClass As Byte = 33
  90. Public Const EffectNum_Armada As Byte = 34        'Particula armada ultimo rango
  91. Public Const EffectNum_ButterflyCurve As Byte = 35
  92. Public Const EffectNum_Torment As Byte = 36
  93. Public Const EffectNum_Green As Byte = 37        'Green Explosion
  94. Public Const EffectNum_Curse As Byte = 38
  95. Public Const EffectNum_Ray As Byte = 39        'Ray
  96. Public Const EffectNum_Ice As Byte = 40        'Ice
  97. Public Const EffectNum_Torch As Byte = 41        'Torch
  98. Public Const EffectNum_RedFountain As Byte = 42
  99. Public Const EffectNum_Implode As Byte = 43
  100. Public Const EffectNum_Misile As Byte = 44
  101. Public Const EffectNum_Holy As Byte = 45
  102. Public Const EffectNum_SmallTorch As Byte = 46
  103. Public Const EffectNum_PortalGroso As Byte = 47
  104. Public Const EffectNum_Nova As Byte = 48
  105. Public Const EffectNum_Explode As Byte = 49        'Explosion
  106. Public Const EffectNum_Atom As Byte = 50
  107. Public Const EffectNum_Teleport As Byte = 51
  108. Public Const EffectNum_Spell As Byte = 52
  109. Public Const EffectNum_Necro As Byte = 53        'Green Ray
  110. Public Const EffectNum_LissajousTrip As Byte = 54
  111. '*************
  112.  
  113. Sub Engine_Init_ParticleEngine(Optional ByVal SkipToTextures As Boolean = False)
  114.     '*****************************************************************
  115.    'Loads all particles into memory - unlike normal textures, these stay in memory. This isn't
  116.    'done for any reason in particular, they just use so little memory since they are so small
  117.    'More info: http://www.vbgore.com/GameClient.TileEn ... icleEngine" class="postlink" rel="nofollow" onClick="window.open(this.href);return false;
  118.    '*****************************************************************
  119.    Dim i As Byte
  120.  
  121.     If Not SkipToTextures Then
  122.  
  123.         'Set the particles texture
  124.        NumEffects = 54
  125.         ReDim effect(1 To NumEffects)
  126.  
  127.     End If
  128.  
  129.     For i = 1 To UBound(ParticleTexture())
  130.         If ParticleTexture(i) Is Nothing Then Set ParticleTexture(i) = Nothing
  131.         Set ParticleTexture(i) = DirectD3D8.CreateTextureFromFileEx(DirectDevice, App.path & "\Graficos\Grh\" & "p" & i & ".png", D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_FILTER_POINT, D3DX_FILTER_POINT, &HFF000000, ByVal 0, ByVal 0)
  132.     Next i
  133.  
  134.     For i = 1 To 4
  135.         If Not SangreTexture(i) Is Nothing Then Set SangreTexture(i) = Nothing
  136.         Set SangreTexture(i) = DirectD3D8.CreateTextureFromFileEx(DirectDevice, App.path & "\Graficos\Grh\" & "2500" & i & ".png", D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_FILTER_NONE, D3DX_FILTER_NONE, &HFF000000, ByVal 0, ByVal 0)
  137.     Next i
  138.  
  139. End Sub
  140.  
  141. Function Effect_EquationTemplate_Begin(ByVal X As Single, _
  142.                                        ByVal Y As Single, _
  143.                                        ByVal Gfx As Integer, _
  144.                                        ByVal Particles As Integer, _
  145.                                        Optional ByVal Progression As Single = 1) As Integer
  146.  
  147.     '*****************************************************************
  148.    'Particle effect template for effects as described on the
  149.    'wiki page: http://www.vbgore.com/Particle_effect_equations
  150.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Begin
  151.    '*****************************************************************
  152.  
  153.     Dim EffectIndex As Integer
  154.     Dim LoopC As Long
  155.  
  156.     'Get the next open effect slot
  157.    EffectIndex = Effect_NextOpenSlot
  158.  
  159.     If EffectIndex = -1 Then Exit Function
  160.     'Return the index of the used slot
  161.    Effect_EquationTemplate_Begin = EffectIndex
  162.     'Set The Effect's Variables
  163.    effect(EffectIndex).EffectNum = EffectNum_EquationTemplate        'Set the effect number
  164.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  165.    effect(EffectIndex).Used = True        'Enable the effect
  166.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  167.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  168.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  169.    effect(EffectIndex).Progression = Progression        'If we loop the effect
  170.    'Set the number of particles left to the total avaliable
  171.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  172.     'Set the float variables
  173.    effect(EffectIndex).FloatSize = Effect_FToDW(8)        'Size of the particles
  174.    'Redim the number of particles
  175.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  176.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  177.  
  178.     'Create the particles
  179.  
  180.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  181.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  182.         effect(EffectIndex).Particles(LoopC).Used = True
  183.         Effect_EquationTemplate_Reset EffectIndex, LoopC
  184.  
  185.     Next LoopC
  186.  
  187.     'Set The Initial Time
  188.    effect(EffectIndex).PreviousFrame = GetTickCount
  189. End Function
  190.  
  191. Private Sub Effect_EquationTemplate_Reset(ByVal EffectIndex As Integer, _
  192.                                           ByVal Index As Long)
  193.  
  194.     '*****************************************************************
  195.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Reset
  196.    '*****************************************************************
  197.  
  198.     Dim X As Single
  199.     Dim Y As Single
  200.     Dim R As Single
  201.  
  202.     effect(EffectIndex).Progression = effect(EffectIndex).Progression + 0.1
  203.     R = (Index / 20) * Exp(Index / effect(EffectIndex).Progression Mod 3)
  204.     X = R * Cos(Index)
  205.     Y = R * Sin(Index)
  206.     'Reset the particle
  207.    effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + X, effect(EffectIndex).Y + Y, 0, 0, 0, 0
  208.     effect(EffectIndex).Particles(Index).ResetColor 1, 1, 1, 1, 0.2 + (Rnd * 0.2)
  209. End Sub
  210.  
  211. Private Sub Effect_EquationTemplate_Update(ByVal EffectIndex As Integer)
  212.  
  213.     '*****************************************************************
  214.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Update
  215.    '*****************************************************************
  216.  
  217.     Dim ElapsedTime As Single
  218.     Dim LoopC As Long
  219.  
  220.     'Calculate The Time Difference
  221.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  222.     effect(EffectIndex).PreviousFrame = GetTickCount
  223.  
  224.     'Go Through The Particle Loop
  225.  
  226.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  227.  
  228.         'Check If Particle Is In Use
  229.  
  230.         If effect(EffectIndex).Particles(LoopC).Used Then
  231.             'Update The Particle
  232.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  233.  
  234.             'Check if the particle is ready to die
  235.  
  236.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  237.  
  238.                 'Check if the effect is ending
  239.  
  240.                 If effect(EffectIndex).Progression > 0 Then
  241.                     'Reset the particle
  242.                    Effect_EquationTemplate_Reset EffectIndex, LoopC
  243.                 Else
  244.                     'Disable the particle
  245.                    effect(EffectIndex).Particles(LoopC).Used = False
  246.                     'Subtract from the total particle count
  247.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  248.  
  249.                     'Check if the effect is out of particles
  250.  
  251.                     If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  252.                     'Clear the color (dont leave behind any artifacts)
  253.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  254.                 End If
  255.  
  256.             Else
  257.                 'Set the particle information on the particle vertex
  258.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  259.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  260.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  261.             End If
  262.         End If
  263.  
  264.     Next LoopC
  265.  
  266. End Sub
  267.  
  268. Function Effect_Bless_Begin(ByVal X As Single, _
  269.                             ByVal Y As Single, _
  270.                             ByVal Gfx As Integer, _
  271.                             ByVal Particles As Integer, _
  272.                             Optional ByVal size As Byte = 30, _
  273.                             Optional ByVal Time As Single = 10) As Integer
  274.  
  275.     '*****************************************************************
  276.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Bless_Begin
  277.    '*****************************************************************
  278.  
  279.     Dim EffectIndex As Integer
  280.     Dim LoopC As Long
  281.  
  282.     'Get the next open effect slot
  283.    EffectIndex = Effect_NextOpenSlot
  284.  
  285.     If EffectIndex = -1 Then Exit Function
  286.     'Return the index of the used slot
  287.    Effect_Bless_Begin = EffectIndex
  288.     'Set The Effect's Variables
  289.    effect(EffectIndex).EffectNum = EffectNum_Bless        'Set the effect number
  290.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  291.    effect(EffectIndex).Used = True        'Enabled the effect
  292.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  293.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  294.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  295.    effect(EffectIndex).Modifier = size        'How large the circle is
  296.    effect(EffectIndex).Progression = Time        'How long the effect will last
  297.    'Set the number of particles left to the total avaliable
  298.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  299.     'Set the float variables
  300.    effect(EffectIndex).FloatSize = Effect_FToDW(20)        'Size of the particles
  301.    'Redim the number of particles
  302.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  303.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  304.  
  305.     'Create the particles
  306.  
  307.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  308.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  309.         effect(EffectIndex).Particles(LoopC).Used = True
  310.        
  311.         Effect_Bless_Reset EffectIndex, LoopC
  312.  
  313.     Next LoopC
  314.  
  315.     'Set The Initial Time
  316.    effect(EffectIndex).PreviousFrame = GetTickCount
  317. End Function
  318.  
  319. Private Sub Effect_Bless_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  320.  
  321.     '*****************************************************************
  322.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Bless_Reset
  323.    '*****************************************************************
  324.  
  325.     Dim a As Single
  326.     Dim X As Single
  327.     Dim Y As Single
  328.  
  329.     'Get the positions
  330.    a = Rnd * 360 * DegreeToRadian
  331.     X = effect(EffectIndex).X - (Sin(a) * effect(EffectIndex).Modifier)
  332.     Y = effect(EffectIndex).Y + (Cos(a) * effect(EffectIndex).Modifier)
  333.     'Reset the particle
  334.    effect(EffectIndex).Particles(Index).ResetIt X, Y, 0, Rnd * -1, 0, -2
  335.     effect(EffectIndex).Particles(Index).ResetColor 1, 1, 0.2, 0.6 + (Rnd * 0.4), 0.06 + (Rnd * 0.2)
  336. End Sub
  337.  
  338. Private Sub Effect_Bless_Update(ByVal EffectIndex As Integer)
  339.  
  340.     '*****************************************************************
  341.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Bless_Update
  342.    '*****************************************************************
  343.  
  344.     Dim ElapsedTime As Single
  345.     Dim LoopC As Long
  346.  
  347.     'Calculate The Time Difference
  348.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  349.     effect(EffectIndex).PreviousFrame = GetTickCount
  350.  
  351.     'Update the life span
  352.  
  353.     If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  354.  
  355.     'Go Through The Particle Loop
  356.  
  357.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  358.  
  359.         'Check If Particle Is In Use
  360.  
  361.         If effect(EffectIndex).Particles(LoopC).Used Then
  362.             'Update The Particle
  363.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  364.  
  365.             'Check if the particle is ready to die
  366.  
  367.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  368.  
  369.                 'Check if the effect is ending
  370.  
  371.                 If effect(EffectIndex).Progression > 0 Then
  372.                     'Reset the particle
  373.                    Effect_Bless_Reset EffectIndex, LoopC
  374.                 Else
  375.                     'Disable the particle
  376.                    effect(EffectIndex).Particles(LoopC).Used = False
  377.                     'Subtract from the total particle count
  378.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  379.  
  380.                     'Check if the effect is out of particles
  381.  
  382.                     If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  383.                     'Clear the color (dont leave behind any artifacts)
  384.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  385.                 End If
  386.  
  387.             Else
  388.                 'Set the particle information on the particle vertex
  389.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  390.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  391.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  392.             End If
  393.         End If
  394.  
  395.     Next LoopC
  396.  
  397. End Sub
  398.  
  399. Function Effect_Fire_Begin(ByVal X As Single, _
  400.                            ByVal Y As Single, _
  401.                            ByVal Gfx As Integer, _
  402.                            ByVal Particles As Integer, _
  403.                            Optional ByVal Direction As Integer = 180, _
  404.                            Optional ByVal Progression As Single = 1) As Integer
  405.  
  406.     '*****************************************************************
  407.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Begin
  408.    '*****************************************************************
  409.  
  410.     Dim EffectIndex As Integer
  411.     Dim LoopC As Long
  412.  
  413.     'Get the next open effect slot
  414.    EffectIndex = Effect_NextOpenSlot
  415.  
  416.     If EffectIndex = -1 Then Exit Function
  417.     'Return the index of the used slot
  418.    Effect_Fire_Begin = EffectIndex
  419.     'Set The Effect's Variables
  420.    effect(EffectIndex).EffectNum = EffectNum_Fire        'Set the effect number
  421.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  422.    effect(EffectIndex).Used = True        'Enabled the effect
  423.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  424.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  425.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  426.    effect(EffectIndex).Direction = Direction        'The direction the effect is animat
  427.    effect(EffectIndex).Progression = Progression        'Loop the effect
  428.    'Set the number of particles left to the total avaliable
  429.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  430.     'Set the float variables
  431.    effect(EffectIndex).FloatSize = Effect_FToDW(15)        'Size of the particles
  432.    'Redim the number of particles
  433.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  434.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  435.  
  436.     'Create the particles
  437.  
  438.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  439.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  440.         effect(EffectIndex).Particles(LoopC).Used = True
  441.        
  442.         Effect_Fire_Reset EffectIndex, LoopC
  443.  
  444.     Next LoopC
  445.  
  446.     'Set The Initial Time
  447.    effect(EffectIndex).PreviousFrame = GetTickCount
  448. End Function
  449.  
  450. Private Sub Effect_Fire_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  451.     '*****************************************************************
  452.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Reset
  453.    '*****************************************************************
  454.    'Reset the particle
  455.    effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X - 10 + Rnd * 20, effect(EffectIndex).Y - 10 + Rnd * 20, -Sin((effect(EffectIndex).Direction + (Rnd * 70) - 35) * DegreeToRadian) * 8, Cos((effect(EffectIndex).Direction + (Rnd * 70) - 35) * DegreeToRadian) * 8, 0, 0
  456.     effect(EffectIndex).Particles(Index).ResetColor 1, 0.2, 0.2, 0.4 + (Rnd * 0.2), 0.03 + (Rnd * 0.07)
  457. End Sub
  458.  
  459. Private Sub Effect_Fire_Update(ByVal EffectIndex As Integer)
  460.  
  461.     '*****************************************************************
  462.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Update
  463.    '*****************************************************************
  464.  
  465.     Dim ElapsedTime As Single
  466.     Dim LoopC As Long
  467.  
  468.     'Calculate The Time Difference
  469.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  470.     effect(EffectIndex).PreviousFrame = GetTickCount
  471.  
  472.     'Update the life span
  473.  
  474.     If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  475.  
  476.     'Go Through The Particle Loop
  477.  
  478.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  479.  
  480.         'Check If Particle Is In Use
  481.  
  482.         If effect(EffectIndex).Particles(LoopC).Used Then
  483.             'Update The Particle
  484.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  485.  
  486.             'Check if the particle is ready to die
  487.  
  488.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  489.  
  490.                 'Check if the effect is ending
  491.  
  492.                 If effect(EffectIndex).Progression > 0 Then
  493.                     'Reset the particle
  494.                    Effect_Fire_Reset EffectIndex, LoopC
  495.                 Else
  496.                     'Disable the particle
  497.                    effect(EffectIndex).Particles(LoopC).Used = False
  498.                     'Subtract from the total particle count
  499.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  500.  
  501.                     'Check if the effect is out of particles
  502.  
  503.                     If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  504.                     'Clear the color (dont leave behind any artifacts)
  505.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  506.                 End If
  507.  
  508.             Else
  509.                 'Set the particle information on the particle vertex
  510.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  511.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  512.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  513.             End If
  514.         End If
  515.  
  516.     Next LoopC
  517.  
  518. End Sub
  519.  
  520. Private Function Effect_FToDW(ByVal F As Single) As Long
  521.  
  522.     '*****************************************************************
  523.    'Converts a float to a D-Word, or in Visual Basic terms, a Single to a Long
  524.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_FToDW
  525.    '*****************************************************************
  526.  
  527.     Dim buf As D3DXBuffer
  528.  
  529.     'Converts a single into a long (Float to DWORD)
  530.    Set buf = DirectD3D8.CreateBuffer(4)
  531.     DirectD3D8.BufferSetData buf, 0, 4, 1, F
  532.     DirectD3D8.BufferGetData buf, 0, 4, 1, Effect_FToDW
  533. End Function
  534.  
  535. Function Effect_Heal_Begin(ByVal X As Single, _
  536.                            ByVal Y As Single, _
  537.                            ByVal Gfx As Integer, _
  538.                            ByVal Particles As Integer, _
  539.                            Optional ByVal Progression As Single = 1) As Integer
  540.  
  541.     '*****************************************************************
  542.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Heal_Begin
  543.    '*****************************************************************
  544.  
  545.     Dim EffectIndex As Integer
  546.     Dim LoopC As Long
  547.  
  548.     'Get the next open effect slot
  549.    EffectIndex = Effect_NextOpenSlot
  550.  
  551.     If EffectIndex = -1 Then Exit Function
  552.     'Return the index of the used slot
  553.    Effect_Heal_Begin = EffectIndex
  554.     'Set The Effect's Variables
  555.    effect(EffectIndex).EffectNum = EffectNum_Heal        'Set the effect number
  556.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  557.    effect(EffectIndex).Used = True        'Enabled the effect
  558.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  559.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  560.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  561.    effect(EffectIndex).Progression = Progression        'Loop the effect
  562.    effect(EffectIndex).KillWhenAtTarget = True        'End the effect when it reaches the target (progression = 0)
  563.    effect(EffectIndex).KillWhenTargetLost = True        'End the effect if the target is lost (progression = 0)
  564.    'Set the number of particles left to the total avaliable
  565.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  566.     'Set the float variables
  567.    effect(EffectIndex).FloatSize = Effect_FToDW(16)        'Size of the particles
  568.    'Redim the number of particles
  569.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  570.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  571.  
  572.     'Create the particles
  573.  
  574.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  575.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  576.         effect(EffectIndex).Particles(LoopC).Used = True
  577.        
  578.         Effect_Heal_Reset EffectIndex, LoopC
  579.  
  580.     Next LoopC
  581.  
  582.     'Set The Initial Time
  583.    effect(EffectIndex).PreviousFrame = GetTickCount
  584. End Function
  585.  
  586. Private Sub Effect_Heal_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  587.     '*****************************************************************
  588.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Heal_Reset
  589.    '*****************************************************************
  590.    'Reset the particle
  591.    effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X - 10 + Rnd * 20, effect(EffectIndex).Y - 10 + Rnd * 20, -Sin((180 + (Rnd * 90) - 45) * 0.0174533) * 8 + (Rnd * 3), Cos((180 + (Rnd * 90) - 45) * 0.0174533) * 8 + (Rnd * 3), 0, 0
  592.     effect(EffectIndex).Particles(Index).ResetColor 0.8, 0.2, 0.2, 0.6 + (Rnd * 0.2), 0.01 + (Rnd * 0.5)
  593. End Sub
  594.  
  595. Private Sub Effect_Heal_Update(ByVal EffectIndex As Integer)
  596.  
  597.     '*****************************************************************
  598.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Heal_Update
  599.    '*****************************************************************
  600.  
  601.     Dim ElapsedTime As Single
  602.     Dim LoopC As Long
  603.  
  604.     'Calculate the time difference
  605.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  606.     effect(EffectIndex).PreviousFrame = GetTickCount
  607.  
  608.     'Go through the particle loop
  609.  
  610.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  611.  
  612.         'Check If Particle Is In Use
  613.  
  614.         If effect(EffectIndex).Particles(LoopC).Used Then
  615.             'Update The Particle
  616.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  617.  
  618.             'Check if the particle is ready to die
  619.  
  620.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  621.  
  622.                 'Check if the effect is ending
  623.  
  624.                 If effect(EffectIndex).Progression <> 0 Then
  625.                     'Reset the particle
  626.                    Effect_Heal_Reset EffectIndex, LoopC
  627.                 Else
  628.                     'Disable the particle
  629.                    effect(EffectIndex).Particles(LoopC).Used = False
  630.                     'Subtract from the total particle count
  631.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  632.  
  633.                     'Check if the effect is out of particles
  634.  
  635.                     If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  636.                     'Clear the color (dont leave behind any artifacts)
  637.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  638.                 End If
  639.  
  640.             Else
  641.                 'Set the particle information on the particle vertex
  642.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  643.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  644.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  645.             End If
  646.         End If
  647.  
  648.     Next LoopC
  649.  
  650. End Sub
  651.  
  652. Sub Effect_Kill(Optional ByVal EffectIndex As Integer = 1, _
  653.                 Optional ByVal KillAll As Boolean = False)
  654.  
  655.     '*****************************************************************
  656.    'Kills (stops) a single effect or all effects
  657.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Kill
  658.    '*****************************************************************
  659.  
  660.     Dim LoopC As Long
  661.  
  662.     'Check If To Kill All Effects
  663.  
  664.     If KillAll Then
  665.  
  666.         'Loop Through Every Effect
  667.  
  668.         For LoopC = 1 To NumEffects
  669.             'Stop The Effect
  670.            effect(LoopC).Used = False
  671.  
  672.         Next
  673.  
  674.     Else
  675.         'Stop The Selected Effect
  676.        effect(EffectIndex).Used = False
  677.     End If
  678.  
  679. End Sub
  680.  
  681. Private Function Effect_NextOpenSlot() As Integer
  682.  
  683.     '*****************************************************************
  684.    'Finds the next open effects index
  685.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_NextOpenSlot
  686.    '*****************************************************************
  687.  
  688.     Dim EffectIndex As Integer
  689.  
  690.     'Find The Next Open Effect Slot
  691.  
  692.     Do
  693.         EffectIndex = EffectIndex + 1        'Check The Next Slot
  694.  
  695.         If EffectIndex > NumEffects Then        'Dont Go Over Maximum Amount
  696.            Effect_NextOpenSlot = -1
  697.  
  698.             Exit Function
  699.  
  700.         End If
  701.  
  702.     Loop While effect(EffectIndex).Used = True        'Check Next If Effect Is In Use
  703.  
  704.     'Return the next open slot
  705.    Effect_NextOpenSlot = EffectIndex
  706.     'Clear the old information from the effect
  707.  
  708.     Erase effect(EffectIndex).Particles()
  709.     Erase effect(EffectIndex).PartVertex()
  710.  
  711.     ZeroMemory effect(EffectIndex), LenB(effect(EffectIndex))
  712.     effect(EffectIndex).GoToX = -30000
  713.     effect(EffectIndex).GoToY = -30000
  714.  
  715. End Function
  716.  
  717. Function Effect_Protection_Begin(ByVal X As Single, _
  718.                                  ByVal Y As Single, _
  719.                                  ByVal Gfx As Integer, _
  720.                                  ByVal Particles As Integer, _
  721.                                  Optional ByVal size As Byte = 30, _
  722.                                  Optional ByVal Time As Single = 10) As Integer
  723.  
  724.     '*****************************************************************
  725.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Protection_Begin
  726.    '*****************************************************************
  727.  
  728.     Dim EffectIndex As Integer
  729.     Dim LoopC As Long
  730.  
  731.     'Get the next open effect slot
  732.    EffectIndex = Effect_NextOpenSlot
  733.  
  734.     If EffectIndex = -1 Then Exit Function
  735.     'Return the index of the used slot
  736.    Effect_Protection_Begin = EffectIndex
  737.     'Set The Effect's Variables
  738.    effect(EffectIndex).EffectNum = EffectNum_Protection        'Set the effect number
  739.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  740.    effect(EffectIndex).Used = True        'Enabled the effect
  741.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  742.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  743.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  744.    effect(EffectIndex).Modifier = size        'How large the circle is
  745.    effect(EffectIndex).Progression = Time        'How long the effect will last
  746.    'Set the number of particles left to the total avaliable
  747.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  748.     'Set the float variables
  749.    effect(EffectIndex).FloatSize = Effect_FToDW(20)        'Size of the particles
  750.    'Redim the number of particles
  751.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  752.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  753.  
  754.     'Create the particles
  755.  
  756.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  757.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  758.         effect(EffectIndex).Particles(LoopC).Used = True
  759.        
  760.         Effect_Protection_Reset EffectIndex, LoopC
  761.  
  762.     Next LoopC
  763.  
  764.     'Set The Initial Time
  765.    effect(EffectIndex).PreviousFrame = GetTickCount
  766. End Function
  767.  
  768. Private Sub Effect_Protection_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  769.  
  770.     '*****************************************************************
  771.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Protection_Reset
  772.    '*****************************************************************
  773.  
  774.     Dim a As Single
  775.     Dim X As Single
  776.     Dim Y As Single
  777.  
  778.     'Get the positions
  779.    a = Rnd * 360 * DegreeToRadian
  780.     X = effect(EffectIndex).X - (Sin(a) * effect(EffectIndex).Modifier)
  781.     Y = effect(EffectIndex).Y + (Cos(a) * effect(EffectIndex).Modifier)
  782.     'Reset the particle
  783.    effect(EffectIndex).Particles(Index).ResetIt X, Y, 0, Rnd * -1, 0, -2
  784.     effect(EffectIndex).Particles(Index).ResetColor 0.1, 0.1, 0.9, 0.6 + (Rnd * 0.4), 0.06 + (Rnd * 0.2)
  785. End Sub
  786.  
  787. Private Sub Effect_UpdateOffset(ByVal EffectIndex As Integer)
  788.     '***************************************************
  789.    'Update an effect's position if the screen has moved
  790.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_UpdateOffset
  791.    '***************************************************
  792.  
  793.     If UserCharIndex <> 0 Then
  794.         If EffectIndex <> Charlist(UserCharIndex).ParticleIndex Then
  795.             effect(EffectIndex).X = effect(EffectIndex).X + (LastOffsetX - ParticleOffsetX)
  796.             effect(EffectIndex).Y = effect(EffectIndex).Y + (LastOffsetY - ParticleOffsetY)
  797.         End If
  798.     End If
  799.  
  800. End Sub
  801.  
  802. Private Sub Effect_UpdateBinding(ByVal EffectIndex As Integer)
  803.  
  804.     '***************************************************
  805.    'Updates the binding of a particle effect to a target, if
  806.    'the effect is bound to a character
  807.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_UpdateBinding
  808.    '***************************************************
  809.  
  810.     Dim TargetI As Integer
  811.     Dim TargetA As Single
  812.     Dim RetNum As Integer        'fao
  813.  
  814.     'Update position through character binding
  815.  
  816.     If effect(EffectIndex).BindToChar > 0 Then
  817.         'Store the character index
  818.        TargetI = effect(EffectIndex).BindToChar
  819.  
  820.         'Check for a valid binding index
  821.  
  822.         If TargetI > LastChar Then
  823.             effect(EffectIndex).BindToChar = 0
  824.  
  825.             If effect(EffectIndex).KillWhenTargetLost Then
  826.                 effect(EffectIndex).Progression = 0
  827.  
  828.                 Exit Sub
  829.  
  830.             End If
  831.  
  832.         ElseIf Charlist(TargetI).Active = 0 Then
  833.             effect(EffectIndex).BindToChar = 0
  834.  
  835.             If effect(EffectIndex).KillWhenTargetLost Then
  836.                 effect(EffectIndex).Progression = 0
  837.  
  838.                 Exit Sub
  839.  
  840.             End If
  841.  
  842.         Else
  843.             'Calculate the X and Y positions
  844.            effect(EffectIndex).GoToX = Engine_TPtoSPX(Charlist(effect(EffectIndex).BindToChar).Pos.X) + 10
  845.             effect(EffectIndex).GoToY = Engine_TPtoSPY(Charlist(effect(EffectIndex).BindToChar).Pos.Y)
  846.         End If
  847.     End If
  848.  
  849.     'Move to the new position if needed
  850.  
  851.     If effect(EffectIndex).GoToX > -30000 Or effect(EffectIndex).GoToY > -30000 Then
  852.         If effect(EffectIndex).GoToX <> effect(EffectIndex).X Or effect(EffectIndex).GoToY <> effect(EffectIndex).Y Then
  853.             'Calculate the angle
  854.            TargetA = Engine_GetAngle(effect(EffectIndex).X, effect(EffectIndex).Y, effect(EffectIndex).GoToX, effect(EffectIndex).GoToY) + 180
  855.             'Update the position of the effect
  856.            effect(EffectIndex).X = effect(EffectIndex).X - Sin(TargetA * DegreeToRadian) * effect(EffectIndex).BindSpeed        '* timerElapsedTime
  857.            effect(EffectIndex).Y = effect(EffectIndex).Y + Cos(TargetA * DegreeToRadian) * effect(EffectIndex).BindSpeed        '* timerElapsedTime
  858.  
  859.             'Check if the effect is close enough to the target to just stick it at the target
  860.  
  861.             If effect(EffectIndex).GoToX > -30000 Then
  862.                 If Abs(effect(EffectIndex).X - effect(EffectIndex).GoToX) < 6 Then effect(EffectIndex).X = effect(EffectIndex).GoToX
  863.             End If
  864.  
  865.             If effect(EffectIndex).GoToY > -30000 Then
  866.                 If Abs(effect(EffectIndex).Y - effect(EffectIndex).GoToY) < 6 Then effect(EffectIndex).Y = effect(EffectIndex).GoToY
  867.             End If
  868.  
  869.             'Check if the position of the effect is equal to that of the target
  870.  
  871.             If effect(EffectIndex).X = effect(EffectIndex).GoToX Then
  872.                 If effect(EffectIndex).Y = effect(EffectIndex).GoToY Then
  873.  
  874.                     'For some effects, if the position is reached, we want to end the effect
  875.                    If effect(EffectIndex).KillWhenAtTarget Then
  876.  
  877.                         'Explosion
  878.                        If effect(EffectIndex).Progression <> 0 Then
  879.  
  880.                             If effect(EffectIndex).EffectNum = EffectNum_Rayo Then
  881.                                 RetNum = Effect_Inmovilizar_Begin(effect(EffectIndex).X - 16, effect(EffectIndex).Y - 16, 17, 100, , 5)
  882.                             ElseIf effect(EffectIndex).EffectNum = EffectNum_Torch Then
  883.                                 RetNum = Effect_EquationTemplate_Begin(effect(EffectIndex).X, effect(EffectIndex).Y, 1, 200, 1)        'TORMENTA DE FUEGO
  884.                            ElseIf effect(EffectIndex).EffectNum = EffectNum_Ray Then
  885.                                 RetNum = Effect_Ice_Begin(effect(EffectIndex).X, effect(EffectIndex).Y, 2, 150, 40)        'RAYO DE HIELO / DESCARGA ELECTRICA
  886.                            ElseIf effect(EffectIndex).EffectNum = EffectNum_Necro Then
  887.                                 effect(EffectIndex).TargetAA = 0
  888.                                 RetNum = Effect_Green_Begin(effect(EffectIndex).X, effect(EffectIndex).Y, 2, 300, 40)        'APOCALIPSIS
  889.                            ElseIf effect(EffectIndex).EffectNum = EffectNum_Curse Then
  890.                                 effect(EffectIndex).TargetAA = 0
  891.                                 RetNum = Effect_Lissajous_Begin(effect(EffectIndex).X, effect(EffectIndex).Y, 1, 250, 1)        'INMOVILIZAR
  892.                            End If
  893.  
  894.                             If RetNum > 0 Then
  895.                                 effect(RetNum).BindToChar = effect(EffectIndex).BindToChar
  896.                                 effect(RetNum).BindSpeed = 10
  897.                             End If
  898.                         End If
  899.  
  900.                         effect(EffectIndex).BindToChar = 0
  901.                         effect(EffectIndex).Progression = 0
  902.                         effect(EffectIndex).GoToX = effect(EffectIndex).X
  903.                         effect(EffectIndex).GoToY = effect(EffectIndex).Y
  904.                     End If
  905.  
  906.                     Exit Sub        'The effect is at the right position, don't update
  907.  
  908.                 End If
  909.             End If
  910.         End If
  911.     End If
  912.  
  913. End Sub
  914.  
  915. Private Sub Effect_Protection_Update(ByVal EffectIndex As Integer)
  916.  
  917.     '*****************************************************************
  918.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Protection_Update
  919.    '*****************************************************************
  920.  
  921.     Dim ElapsedTime As Single
  922.     Dim LoopC As Long
  923.  
  924.     'Calculate The Time Difference
  925.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  926.     effect(EffectIndex).PreviousFrame = GetTickCount
  927.  
  928.     'Update the life span
  929.  
  930.     If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  931.  
  932.     'Go through the particle loop
  933.  
  934.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  935.  
  936.         'Check If Particle Is In Use
  937.  
  938.         If effect(EffectIndex).Particles(LoopC).Used Then
  939.             'Update The Particle
  940.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  941.  
  942.             'Check if the particle is ready to die
  943.  
  944.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  945.  
  946.                 'Check if the effect is ending
  947.  
  948.                 If effect(EffectIndex).Progression > 0 Then
  949.                     'Reset the particle
  950.                    Effect_Protection_Reset EffectIndex, LoopC
  951.                 Else
  952.                     'Disable the particle
  953.                    effect(EffectIndex).Particles(LoopC).Used = False
  954.                     'Subtract from the total particle count
  955.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  956.  
  957.                     'Check if the effect is out of particles
  958.  
  959.                     If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  960.                     'Clear the color (dont leave behind any artifacts)
  961.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  962.                 End If
  963.  
  964.             Else
  965.                 'Set the particle information on the particle vertex
  966.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  967.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  968.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  969.             End If
  970.         End If
  971.  
  972.     Next LoopC
  973.  
  974. End Sub
  975.  
  976. Public Sub Effect_Render(ByVal EffectIndex As Integer, _
  977.                          Optional ByVal SetRenderStates As Boolean = True)
  978.  
  979.     '*****************************************************************
  980.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Render
  981.    '*****************************************************************
  982.  
  983.     Dim Count As Long
  984.     Dim i As Long
  985.  
  986.     'Check if we have the device
  987.    If DirectDevice.TestCooperativeLevel <> D3D_OK Then Exit Sub
  988.  
  989.     'Set the render state for the size of the particle
  990.    DirectDevice.SetRenderState D3DRS_POINTSIZE, effect(EffectIndex).FloatSize
  991.  
  992.     'Set the render state to point blitting
  993.    If SetRenderStates Then DirectDevice.SetRenderState D3DRS_DESTBLEND, D3DBLEND_ONE
  994.  
  995.     'Set the last texture to a random number to force the engine to reload the texture
  996.    LastTexture = -65489
  997.  
  998.     'Check what type of rendering to do (blood or everything else)
  999.  
  1000.     If effect(EffectIndex).EffectNum = EffectNum_BloodSpray Or effect(EffectIndex).EffectNum = EffectNum_BloodSplatter Then
  1001.         Count = effect(EffectIndex).ParticleCount \ 4
  1002.         DirectDevice.SetTexture 0, SangreTexture(1)
  1003.         DirectDevice.DrawPrimitiveUP D3DPT_POINTLIST, Count, effect(EffectIndex).PartVertex(0), LenB(effect(EffectIndex).PartVertex(0))
  1004.  
  1005.         For i = 0 To Count - 1
  1006.  
  1007.             With effect(EffectIndex).Particles(i)
  1008.  
  1009.                 If .sngZ < 1 Then effect(EffectIndex).PartVertex(i).Y = effect(EffectIndex).PartVertex(i).Y + .sngZ
  1010.                 effect(EffectIndex).PartVertex(i).Colour = D3DColorMake(.SngR, .SngG, .SngB, .SngA)
  1011.             End With
  1012.  
  1013.         Next i
  1014.  
  1015.         DirectDevice.DrawPrimitiveUP D3DPT_POINTLIST, Count, effect(EffectIndex).PartVertex(0), LenB(effect(EffectIndex).PartVertex(0))
  1016.         DirectDevice.SetTexture 0, SangreTexture(4)
  1017.         DirectDevice.DrawPrimitiveUP D3DPT_POINTLIST, Count, effect(EffectIndex).PartVertex(Count - 1), Len(effect(EffectIndex).PartVertex(0))
  1018.  
  1019.         For i = Count To Count - 1 + Count
  1020.  
  1021.             With effect(EffectIndex).Particles(i)
  1022.  
  1023.                 If .sngZ < 1 Then effect(EffectIndex).PartVertex(i).Y = effect(EffectIndex).PartVertex(i).Y + .sngZ
  1024.                 effect(EffectIndex).PartVertex(i).Colour = D3DColorMake(.SngR, .SngG, .SngB, .SngA)
  1025.             End With
  1026.  
  1027.         Next i
  1028.  
  1029.         DirectDevice.DrawPrimitiveUP D3DPT_POINTLIST, Count, effect(EffectIndex).PartVertex(Count - 1), LenB(effect(EffectIndex).PartVertex(0))
  1030.         DirectDevice.SetTexture 0, SangreTexture(2)
  1031.         DirectDevice.DrawPrimitiveUP D3DPT_POINTLIST, Count, effect(EffectIndex).PartVertex((Count * 2) - 1), LenB(effect(EffectIndex).PartVertex(0))
  1032.  
  1033.         For i = (Count * 2) To (Count * 2) - 1 + Count
  1034.  
  1035.             With effect(EffectIndex).Particles(i)
  1036.  
  1037.                 If .sngZ < 1 Then effect(EffectIndex).PartVertex(i).Y = effect(EffectIndex).PartVertex(i).Y + .sngZ
  1038.                 effect(EffectIndex).PartVertex(i).Colour = D3DColorMake(.SngR, .SngG, .SngB, .SngA)
  1039.             End With
  1040.  
  1041.         Next i
  1042.  
  1043.         DirectDevice.DrawPrimitiveUP D3DPT_POINTLIST, Count, effect(EffectIndex).PartVertex((Count * 2) - 1), LenB(effect(EffectIndex).PartVertex(0))
  1044.         DirectDevice.SetTexture 0, SangreTexture(3)
  1045.         DirectDevice.DrawPrimitiveUP D3DPT_POINTLIST, Count, effect(EffectIndex).PartVertex((Count * 3) - 1), LenB(effect(EffectIndex).PartVertex(0))
  1046.  
  1047.         For i = (Count * 3) To effect(EffectIndex).ParticleCount
  1048.  
  1049.             With effect(EffectIndex).Particles(i)
  1050.  
  1051.                 If .sngZ < 1 Then effect(EffectIndex).PartVertex(i).Y = effect(EffectIndex).PartVertex(i).Y + .sngZ
  1052.                 effect(EffectIndex).PartVertex(i).Colour = D3DColorMake(.SngR, .SngG, .SngB, .SngA)
  1053.             End With
  1054.  
  1055.         Next i
  1056.  
  1057.         DirectDevice.DrawPrimitiveUP D3DPT_POINTLIST, Count, effect(EffectIndex).PartVertex((Count * 3) - 1), LenB(effect(EffectIndex).PartVertex(0))
  1058.     Else
  1059.         'Set the texture
  1060.        DirectDevice.SetTexture 0, ParticleTexture(effect(EffectIndex).Gfx)
  1061.  
  1062.         'Draw all the particles at once
  1063.        DirectDevice.DrawPrimitiveUP D3DPT_POINTLIST, effect(EffectIndex).ParticleCount, effect(EffectIndex).PartVertex(0), LenB(effect(EffectIndex).PartVertex(0))
  1064.  
  1065.         'Reset the render state back to normal
  1066.        If SetRenderStates Then DirectDevice.SetRenderState D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA
  1067.  
  1068.     End If
  1069.  
  1070. End Sub
  1071.  
  1072. Function Effect_Snow_Begin(ByVal Gfx As Integer, ByVal Particles As Integer) As Integer
  1073.  
  1074.     '*****************************************************************
  1075.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Snow_Begin
  1076.    '*****************************************************************
  1077.  
  1078.     Dim EffectIndex As Integer
  1079.     Dim LoopC As Long
  1080.  
  1081.     'Get the next open effect slot
  1082.    EffectIndex = Effect_NextOpenSlot
  1083.  
  1084.     If EffectIndex = -1 Then Exit Function
  1085.     'Return the index of the used slot
  1086.    Effect_Snow_Begin = EffectIndex
  1087.     'Set The Effect's Variables
  1088.    effect(EffectIndex).EffectNum = EffectNum_Snow        'Set the effect number
  1089.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  1090.    effect(EffectIndex).Used = True        'Enabled the effect
  1091.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  1092.    'Set the number of particles left to the total avaliable
  1093.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  1094.     'Set the float variables
  1095.    effect(EffectIndex).FloatSize = Effect_FToDW(15)        'Size of the particles
  1096.    'Redim the number of particles
  1097.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  1098.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  1099.  
  1100.     'Create the particles
  1101.  
  1102.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  1103.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  1104.         effect(EffectIndex).Particles(LoopC).Used = True
  1105.        
  1106.         Effect_Snow_Reset EffectIndex, LoopC, 1
  1107.  
  1108.     Next LoopC
  1109.  
  1110.     'Set the initial time
  1111.    effect(EffectIndex).PreviousFrame = GetTickCount
  1112. End Function
  1113.  
  1114. Private Sub Effect_Snow_Reset(ByVal EffectIndex As Integer, _
  1115.                               ByVal Index As Long, _
  1116.                               Optional ByVal FirstReset As Byte = 0)
  1117.  
  1118.     '*****************************************************************
  1119.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Snow_Reset
  1120.    '*****************************************************************
  1121.  
  1122.     If FirstReset = 1 Then
  1123.         'The very first reset
  1124.        effect(EffectIndex).Particles(Index).ResetIt -200 + (Rnd * (frmMain.ScaleWidth + 400)), Rnd * (frmMain.ScaleHeight + 50), Rnd * 5, 5 + Rnd * 3, 0, 0
  1125.     Else
  1126.         'Any reset after first
  1127.        effect(EffectIndex).Particles(Index).ResetIt -200 + (Rnd * (frmMain.ScaleWidth + 400)), -15 - Rnd * 185, Rnd * 5, 5 + Rnd * 3, 0, 0
  1128.  
  1129.         If effect(EffectIndex).Particles(Index).sngX < -20 Then effect(EffectIndex).Particles(Index).sngY = Rnd * (frmMain.ScaleHeight + 50)
  1130.         If effect(EffectIndex).Particles(Index).sngX > frmMain.ScaleWidth Then effect(EffectIndex).Particles(Index).sngY = Rnd * (frmMain.ScaleHeight + 50)
  1131.         If effect(EffectIndex).Particles(Index).sngY > frmMain.ScaleHeight Then effect(EffectIndex).Particles(Index).sngX = Rnd * (frmMain.ScaleWidth + 50)
  1132.     End If
  1133.  
  1134.     'Set the color
  1135.    effect(EffectIndex).Particles(Index).ResetColor 1, 1, 1, 0.8, 0
  1136. End Sub
  1137.  
  1138. Private Sub Effect_Snow_Update(ByVal EffectIndex As Integer)
  1139.  
  1140.     '*****************************************************************
  1141.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Snow_Update
  1142.    '*****************************************************************
  1143.  
  1144.     Dim ElapsedTime As Single
  1145.     Dim LoopC As Long
  1146.  
  1147.     'Calculate the time difference
  1148.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  1149.     effect(EffectIndex).PreviousFrame = GetTickCount
  1150.  
  1151.     'Go through the particle loop
  1152.  
  1153.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  1154.  
  1155.         'Check if particle is in use
  1156.  
  1157.         If effect(EffectIndex).Particles(LoopC).Used Then
  1158.             'Update The Particle
  1159.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  1160.  
  1161.             'Check if to reset the particle
  1162.  
  1163.             If effect(EffectIndex).Particles(LoopC).sngX < -200 Then effect(EffectIndex).Particles(LoopC).SngA = 0
  1164.             If effect(EffectIndex).Particles(LoopC).sngX > (frmMain.ScaleWidth + 200) Then effect(EffectIndex).Particles(LoopC).SngA = 0
  1165.             If effect(EffectIndex).Particles(LoopC).sngY > (frmMain.ScaleHeight + 200) Then effect(EffectIndex).Particles(LoopC).SngA = 0
  1166.  
  1167.             'Time for a reset, baby!
  1168.  
  1169.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  1170.                 'Reset the particle
  1171.                Effect_Snow_Reset EffectIndex, LoopC
  1172.             Else
  1173.                 'Set the particle information on the particle vertex
  1174.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  1175.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  1176.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  1177.             End If
  1178.         End If
  1179.  
  1180.     Next LoopC
  1181.  
  1182. End Sub
  1183.  
  1184. Function Effect_Strengthen_Begin(ByVal X As Single, _
  1185.                                  ByVal Y As Single, _
  1186.                                  ByVal Gfx As Integer, _
  1187.                                  ByVal Particles As Integer, _
  1188.                                  Optional ByVal size As Byte = 30, _
  1189.                                  Optional ByVal Time As Single = 10) As Integer
  1190.  
  1191.     '*****************************************************************
  1192.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Strengthen_Begin
  1193.    '*****************************************************************
  1194.  
  1195.     Dim EffectIndex As Integer
  1196.     Dim LoopC As Long
  1197.  
  1198.     'Get the next open effect slot
  1199.    EffectIndex = Effect_NextOpenSlot
  1200.  
  1201.     If EffectIndex = -1 Then Exit Function
  1202.     'Return the index of the used slot
  1203.    Effect_Strengthen_Begin = EffectIndex
  1204.     'Set the effect's variables
  1205.    effect(EffectIndex).EffectNum = EffectNum_Strengthen        'Set the effect number
  1206.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  1207.    effect(EffectIndex).Used = True        'Enabled the effect
  1208.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  1209.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  1210.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  1211.    effect(EffectIndex).Modifier = size        'How large the circle is
  1212.    effect(EffectIndex).Progression = Time        'How long the effect will last
  1213.    'Set the number of particles left to the total avaliable
  1214.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  1215.     'Set the float variables
  1216.    effect(EffectIndex).FloatSize = Effect_FToDW(20)        'Size of the particles
  1217.    'Redim the number of particles
  1218.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  1219.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  1220.  
  1221.     'Create the particles
  1222.  
  1223.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  1224.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  1225.         effect(EffectIndex).Particles(LoopC).Used = True
  1226.        
  1227.         Effect_Strengthen_Reset EffectIndex, LoopC
  1228.  
  1229.     Next LoopC
  1230.  
  1231.     'Set The Initial Time
  1232.    effect(EffectIndex).PreviousFrame = GetTickCount
  1233. End Function
  1234.  
  1235. Private Sub Effect_Strengthen_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  1236.  
  1237.     '*****************************************************************
  1238.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Strengthen_Reset
  1239.    '*****************************************************************
  1240.  
  1241.     Dim a As Single
  1242.     Dim X As Single
  1243.     Dim Y As Single
  1244.  
  1245.     'Get the positions
  1246.    a = Rnd * 360 * DegreeToRadian
  1247.     X = effect(EffectIndex).X - (Sin(a) * effect(EffectIndex).Modifier)
  1248.     Y = effect(EffectIndex).Y + (Cos(a) * effect(EffectIndex).Modifier)
  1249.     'Reset the particle
  1250.    effect(EffectIndex).Particles(Index).ResetIt X, Y, 0, Rnd * -1, 0, -2
  1251.     effect(EffectIndex).Particles(Index).ResetColor 0.2, 1, 0.2, 0.6 + (Rnd * 0.4), 0.06 + (Rnd * 0.2)
  1252. End Sub
  1253.  
  1254. Private Sub Effect_Strengthen_Update(ByVal EffectIndex As Integer)
  1255.  
  1256.     '*****************************************************************
  1257.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Strengthen_Update
  1258.    '*****************************************************************
  1259.  
  1260.     Dim ElapsedTime As Single
  1261.     Dim LoopC As Long
  1262.  
  1263.     'Calculate the time difference
  1264.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  1265.     effect(EffectIndex).PreviousFrame = GetTickCount
  1266.  
  1267.     'Update the life span
  1268.  
  1269.     If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  1270.  
  1271.     'Go through the particle loop
  1272.  
  1273.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  1274.  
  1275.         'Check if particle is in use
  1276.  
  1277.         If effect(EffectIndex).Particles(LoopC).Used Then
  1278.             'Update the particle
  1279.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  1280.  
  1281.             'Check if the particle is ready to die
  1282.  
  1283.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  1284.  
  1285.                 'Check if the effect is ending
  1286.  
  1287.                 If effect(EffectIndex).Progression > 0 Then
  1288.                     'Reset the particle
  1289.                    Effect_Strengthen_Reset EffectIndex, LoopC
  1290.                 Else
  1291.                     'Disable the particle
  1292.                    effect(EffectIndex).Particles(LoopC).Used = False
  1293.                     'Subtract from the total particle count
  1294.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  1295.  
  1296.                     'Check if the effect is out of particles
  1297.  
  1298.                     If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  1299.                     'Clear the color (dont leave behind any artifacts)
  1300.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  1301.                 End If
  1302.  
  1303.             Else
  1304.                 'Set the particle information on the particle vertex
  1305.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  1306.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  1307.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  1308.             End If
  1309.         End If
  1310.  
  1311.     Next LoopC
  1312.  
  1313. End Sub
  1314.  
  1315. Sub Effect_UpdateAll()
  1316.  
  1317.     '*****************************************************************
  1318.    'Updates all of the effects and renders them
  1319.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_UpdateAll
  1320.    '*****************************************************************
  1321.  
  1322.     Dim LoopC As Long
  1323.  
  1324.     'Make sure we have effects
  1325.  
  1326.     If NumEffects = 0 Then Exit Sub
  1327.  
  1328.     'Set the render state for the particle effects
  1329.    DirectDevice.SetRenderState D3DRS_DESTBLEND, D3DBLEND_ONE
  1330.  
  1331.     'Update every effect in use
  1332.  
  1333.     For LoopC = 1 To NumEffects
  1334.  
  1335.         'Make sure the effect is in use
  1336.        If effect(LoopC).Used Then
  1337.             'Update the effect position if the screen has moved
  1338.            Effect_UpdateOffset LoopC
  1339.             'Update the effect position if it is binded
  1340.            Effect_UpdateBinding LoopC
  1341.  
  1342.             'Find out which effect is selected, then update it
  1343.            If effect(LoopC).EffectNum = EffectNum_Fire Then Effect_Fire_Update LoopC
  1344.             If effect(LoopC).EffectNum = EffectNum_Snow Then Effect_Snow_Update LoopC
  1345.             If effect(LoopC).EffectNum = EffectNum_Heal Then Effect_Heal_Update LoopC
  1346.             If effect(LoopC).EffectNum = EffectNum_Bless Then Effect_Bless_Update LoopC
  1347.             If effect(LoopC).EffectNum = EffectNum_Protection Then Effect_Protection_Update LoopC
  1348.             If effect(LoopC).EffectNum = EffectNum_Strengthen Then Effect_Strengthen_Update LoopC
  1349.             If effect(LoopC).EffectNum = EffectNum_Rain Then Effect_Rain_Update LoopC
  1350.             If effect(LoopC).EffectNum = EffectNum_EquationTemplate Then Effect_EquationTemplate_Update LoopC
  1351.             If effect(LoopC).EffectNum = EffectNum_Waterfall Then Effect_Waterfall_Update LoopC
  1352.             If effect(LoopC).EffectNum = EffectNum_Summon Then Effect_Summon_Update LoopC
  1353.             If effect(LoopC).EffectNum = EffectNum_Meditate Then Effect_Meditate_Update LoopC
  1354.             If effect(LoopC).EffectNum = EffectNum_Portal Then Effect_Portal_Update LoopC
  1355.             If effect(LoopC).EffectNum = EffectNum_Atomic Then Effect_Atomic_Update LoopC
  1356.             If effect(LoopC).EffectNum = EffectNum_Circle Then Effect_Circle_Update LoopC
  1357.             If effect(LoopC).EffectNum = EffectNum_Raro Then Effect_Raro_Update LoopC
  1358.             If effect(LoopC).EffectNum = EffectNum_Lissajous Then Effect_Lissajous_Update LoopC
  1359.             If effect(LoopC).EffectNum = EffectNum_Apocalipsis Then Effect_Apocalipsis_Update LoopC
  1360.             If effect(LoopC).EffectNum = EffectNum_Humo Then Effect_Humo_Update LoopC
  1361.             If effect(LoopC).EffectNum = EffectNum_CherryBlossom Then Effect_CherryBlossom_Update LoopC
  1362.             If effect(LoopC).EffectNum = EffectNum_BloodSpray Then Effect_BloodSpray_Update LoopC
  1363.             If effect(LoopC).EffectNum = EffectNum_BloodSplatter Then Effect_BloodSplatter_Update LoopC
  1364.             If effect(LoopC).EffectNum = EffectNum_LevelUP Then Effect_Spawn_Update EffectNum_LevelUP, LoopC
  1365.             If effect(LoopC).EffectNum = EffectNum_AnimatedSign Then Effect_Spawn_Update EffectNum_AnimatedSign, LoopC
  1366.             If effect(LoopC).EffectNum = EffectNum_Galaxy Then Effect_Spawn_Update EffectNum_Galaxy, LoopC
  1367.             If effect(LoopC).EffectNum = EffectNum_FancyThickCircle Then Effect_Spawn_Update EffectNum_FancyThickCircle, LoopC
  1368.             If effect(LoopC).EffectNum = EffectNum_Flower Then Effect_Spawn_Update EffectNum_Flower, LoopC
  1369.             If effect(LoopC).EffectNum = EffectNum_Wormhole Then Effect_Spawn_Update EffectNum_Wormhole, LoopC
  1370.             If effect(LoopC).EffectNum = EffectNum_HouseTeleport Then Effect_Spawn_Update EffectNum_HouseTeleport, LoopC
  1371.             If effect(LoopC).EffectNum = EffectNum_GuildTeleport Then Effect_Spawn_Update EffectNum_GuildTeleport, LoopC
  1372.             If effect(LoopC).EffectNum = EffectNum_Rayo Then Effect_Rayo_Update LoopC
  1373.             If effect(LoopC).EffectNum = EffectNum_LissajousMedit Then Effect_LissajousMedit_Update LoopC
  1374.             If effect(LoopC).EffectNum = EffectNum_Inmovilizar Then Effect_Inmovilizar_Update LoopC
  1375.             If effect(LoopC).EffectNum = EffectNum_ChangeClass Then Effect_ChangeClass_Update LoopC
  1376.             If effect(LoopC).EffectNum = EffectNum_Armada Then Effect_Armada_Update LoopC
  1377.             If effect(LoopC).EffectNum = EffectNum_ButterflyCurve Then Effect_Butterfly_Update LoopC
  1378.             If effect(LoopC).EffectNum = EffectNum_Torment Then Effect_Torment_Update LoopC
  1379.             If effect(LoopC).EffectNum = EffectNum_Green Then Effect_Green_Update LoopC
  1380.             If effect(LoopC).EffectNum = EffectNum_Curse Then Effect_Curse_Update LoopC
  1381.             If effect(LoopC).EffectNum = EffectNum_Ray Then Effect_Ray_Update LoopC
  1382.             If effect(LoopC).EffectNum = EffectNum_Ice Then Effect_Ice_Update LoopC
  1383.             If effect(LoopC).EffectNum = EffectNum_Torch Then Effect_Torch_Update LoopC
  1384.             If effect(LoopC).EffectNum = EffectNum_RedFountain Then Effect_RedFountain_Update LoopC
  1385.             If effect(LoopC).EffectNum = EffectNum_Implode Then Effect_Implode_Update LoopC
  1386.             If effect(LoopC).EffectNum = EffectNum_Misile Then Effect_Misile_Update LoopC
  1387.             If effect(LoopC).EffectNum = EffectNum_Holy Then Effect_Holy_Update LoopC
  1388.             If effect(LoopC).EffectNum = EffectNum_PortalGroso Then Effect_PortalGroso_Update LoopC
  1389.             If effect(LoopC).EffectNum = EffectNum_Nova Then Effect_Nova_Update LoopC
  1390.             If effect(LoopC).EffectNum = EffectNum_Explode Then Effect_Explode_Update LoopC
  1391.             If effect(LoopC).EffectNum = EffectNum_Teleport Then Effect_teleport_Update LoopC
  1392.             If effect(LoopC).EffectNum = EffectNum_Spell Then Effect_Spell_Update LoopC
  1393.             If effect(LoopC).EffectNum = EffectNum_Necro Then Effect_Necro_Update LoopC
  1394.             If effect(LoopC).EffectNum = EffectNum_LissajousTrip Then Effect_LissajousTrip_Update LoopC
  1395.             'Render the effect
  1396.            Effect_Render LoopC, False
  1397.         End If
  1398.  
  1399.     Next
  1400.  
  1401.     'Set the render state back for normal rendering
  1402.    DirectDevice.SetRenderState D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA
  1403. End Sub
  1404.  
  1405. Function Effect_Rain_Begin(ByVal Gfx As Integer, ByVal Particles As Integer) As Integer
  1406.  
  1407.     '*****************************************************************
  1408.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Rain_Begin
  1409.    '*****************************************************************
  1410.  
  1411.     Dim EffectIndex As Integer
  1412.     Dim LoopC As Long
  1413.  
  1414.     'Get the next open effect slot
  1415.    EffectIndex = Effect_NextOpenSlot
  1416.  
  1417.     If EffectIndex = -1 Then Exit Function
  1418.     'Return the index of the used slot
  1419.    Effect_Rain_Begin = EffectIndex
  1420.     'Set the effect's variables
  1421.    effect(EffectIndex).EffectNum = EffectNum_Rain        'Set the effect number
  1422.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  1423.    effect(EffectIndex).Used = True        'Enabled the effect
  1424.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  1425.    'Set the number of particles left to the total avaliable
  1426.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  1427.     'Set the float variables
  1428.    effect(EffectIndex).FloatSize = Effect_FToDW(10)        'Size of the particles
  1429.    'Redim the number of particles
  1430.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  1431.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  1432.  
  1433.     'Create the particles
  1434.  
  1435.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  1436.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  1437.         effect(EffectIndex).Particles(LoopC).Used = True
  1438.        
  1439.         Effect_Rain_Reset EffectIndex, LoopC, 1
  1440.  
  1441.     Next LoopC
  1442.  
  1443.     'Set The Initial Time
  1444.    effect(EffectIndex).PreviousFrame = GetTickCount
  1445. End Function
  1446.  
  1447. Private Sub Effect_Rain_Reset(ByVal EffectIndex As Integer, _
  1448.                               ByVal Index As Long, _
  1449.                               Optional ByVal FirstReset As Byte = 0)
  1450.  
  1451.     '*****************************************************************
  1452.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Rain_Reset
  1453.    '*****************************************************************
  1454.  
  1455.     If FirstReset = 1 Then
  1456.         'The very first reset
  1457.        effect(EffectIndex).Particles(Index).ResetIt -200 + (Rnd * (frmMain.ScaleWidth + 400)), Rnd * (frmMain.ScaleHeight + 50), Rnd * 5, 25 + Rnd * 12, 0, 0
  1458.     Else
  1459.         'Any reset after first
  1460.        effect(EffectIndex).Particles(Index).ResetIt -200 + (Rnd * 1200), -15 - Rnd * 185, Rnd * 5, 25 + Rnd * 12, 0, 0
  1461.  
  1462.         If effect(EffectIndex).Particles(Index).sngX < -20 Then effect(EffectIndex).Particles(Index).sngY = Rnd * (frmMain.ScaleHeight + 50)
  1463.         If effect(EffectIndex).Particles(Index).sngX > frmMain.ScaleWidth Then effect(EffectIndex).Particles(Index).sngY = Rnd * (frmMain.ScaleHeight + 50)
  1464.         If effect(EffectIndex).Particles(Index).sngY > frmMain.ScaleHeight Then effect(EffectIndex).Particles(Index).sngX = Rnd * (frmMain.ScaleWidth + 50)
  1465.     End If
  1466.  
  1467.     'Set the color
  1468.    effect(EffectIndex).Particles(Index).ResetColor 1, 1, 1, 0.4, 0
  1469. End Sub
  1470.  
  1471. Private Sub Effect_Rain_Update(ByVal EffectIndex As Integer)
  1472.  
  1473.     '*****************************************************************
  1474.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Rain_Update
  1475.    '*****************************************************************
  1476.  
  1477.     Dim ElapsedTime As Single
  1478.     Dim LoopC As Long
  1479.  
  1480.     'Calculate the time difference
  1481.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  1482.     effect(EffectIndex).PreviousFrame = GetTickCount
  1483.  
  1484.     'Go through the particle loop
  1485.  
  1486.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  1487.  
  1488.         'Check if the particle is in use
  1489.  
  1490.         If effect(EffectIndex).Particles(LoopC).Used Then
  1491.             'Update the particle
  1492.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  1493.  
  1494.             'Check if to reset the particle
  1495.  
  1496.             If effect(EffectIndex).Particles(LoopC).sngX < -200 Then effect(EffectIndex).Particles(LoopC).SngA = 0
  1497.             If effect(EffectIndex).Particles(LoopC).sngX > (frmMain.ScaleWidth + 200) Then effect(EffectIndex).Particles(LoopC).SngA = 0
  1498.             If effect(EffectIndex).Particles(LoopC).sngY > (frmMain.ScaleHeight + 200) Then effect(EffectIndex).Particles(LoopC).SngA = 0
  1499.  
  1500.             'Time for a reset, baby!
  1501.  
  1502.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  1503.                 'Reset the particle
  1504.                Effect_Rain_Reset EffectIndex, LoopC
  1505.             Else
  1506.                 'Set the particle information on the particle vertex
  1507.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  1508.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  1509.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  1510.             End If
  1511.         End If
  1512.  
  1513.     Next LoopC
  1514.  
  1515. End Sub
  1516.  
  1517. Public Sub Effect_Begin(ByVal EffectIndex As Integer, _
  1518.                         ByVal X As Single, _
  1519.                         ByVal Y As Single, _
  1520.                         ByVal GfxIndex As Byte, _
  1521.                         ByVal Particles As Byte, _
  1522.                         Optional ByVal Direction As Single = 180, _
  1523.                         Optional ByVal BindToMap As Boolean = False)
  1524.  
  1525.     '*****************************************************************
  1526.    'A very simplistic form of initialization for particle effects
  1527.    'Should only be used for starting map-based effects
  1528.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Begin
  1529.    '*****************************************************************
  1530.  
  1531.     Dim RetNum As Byte
  1532.  
  1533.     Select Case EffectIndex
  1534.  
  1535.         Case 1
  1536.             RetNum = Effect_Fire_Begin(X, Y, GfxIndex, Particles, Direction, 1)
  1537.  
  1538.         Case 4
  1539.             RetNum = Effect_Waterfall_Begin(X, Y, GfxIndex, Particles)
  1540.  
  1541.         Case 7
  1542.             RetNum = Effect_Portal_Begin(X, Y, GfxIndex, Particles, 100)
  1543.     End Select
  1544.  
  1545.     'Bind the effect to the map if needed
  1546.  
  1547.     If BindToMap Then effect(RetNum).BoundToMap = 1
  1548. End Sub
  1549.  
  1550. Function Effect_Waterfall_Begin(ByVal X As Single, _
  1551.                                 ByVal Y As Single, _
  1552.                                 ByVal Gfx As Integer, _
  1553.                                 ByVal Particles As Integer) As Integer
  1554.  
  1555.     '*****************************************************************
  1556.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Waterfall_Begin
  1557.    '*****************************************************************
  1558.  
  1559.     Dim EffectIndex As Integer
  1560.     Dim LoopC As Long
  1561.  
  1562.     'Get the next open effect slot
  1563.    EffectIndex = Effect_NextOpenSlot
  1564.  
  1565.     If EffectIndex = -1 Then Exit Function
  1566.     'Return the index of the used slot
  1567.    Effect_Waterfall_Begin = EffectIndex
  1568.     'Set the effect's variables
  1569.    effect(EffectIndex).EffectNum = EffectNum_Waterfall        'Set the effect number
  1570.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  1571.    effect(EffectIndex).Used = True        'Enabled the effect
  1572.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  1573.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  1574.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  1575.    'Set the number of particles left to the total avaliable
  1576.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  1577.     'Set the float variables
  1578.    effect(EffectIndex).FloatSize = Effect_FToDW(20)        'Size of the particles
  1579.    'Redim the number of particles
  1580.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  1581.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  1582.  
  1583.     'Create the particles
  1584.  
  1585.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  1586.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  1587.         effect(EffectIndex).Particles(LoopC).Used = True
  1588.        
  1589.         Effect_Waterfall_Reset EffectIndex, LoopC
  1590.  
  1591.     Next LoopC
  1592.  
  1593.     'Set The Initial Time
  1594.    effect(EffectIndex).PreviousFrame = GetTickCount
  1595. End Function
  1596.  
  1597. Private Sub Effect_Waterfall_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  1598.  
  1599.     '*****************************************************************
  1600.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Waterfall_Reset
  1601.    '*****************************************************************
  1602.  
  1603.     If Int(Rnd * 10) = 1 Then
  1604.         effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + (Rnd * 60), effect(EffectIndex).Y + (Rnd * 130), 0, 8 + (Rnd * 6), 0, 0
  1605.     Else
  1606.         effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + (Rnd * 60), effect(EffectIndex).Y + (Rnd * 10), 0, 8 + (Rnd * 6), 0, 0
  1607.     End If
  1608.  
  1609.     effect(EffectIndex).Particles(Index).ResetColor 0.1, 0.1, 0.9, 0.6 + (Rnd * 0.4), 0
  1610. End Sub
  1611.  
  1612. Private Sub Effect_Waterfall_Update(ByVal EffectIndex As Integer)
  1613.  
  1614.     '*****************************************************************
  1615.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Waterfall_Update
  1616.    '*****************************************************************
  1617.  
  1618.     Dim ElapsedTime As Single
  1619.     Dim LoopC As Long
  1620.  
  1621.     'Calculate The Time Difference
  1622.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  1623.     effect(EffectIndex).PreviousFrame = GetTickCount
  1624.  
  1625.     'Update the life span
  1626.  
  1627.     If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  1628.  
  1629.     'Go through the particle loop
  1630.  
  1631.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  1632.  
  1633.         With effect(EffectIndex).Particles(LoopC)
  1634.  
  1635.             'Check if the particle is in use
  1636.  
  1637.             If .Used Then
  1638.                 'Update The Particle
  1639.                .UpdateParticle ElapsedTime
  1640.  
  1641.                 'Check if the particle is ready to die
  1642.  
  1643.                 If (.sngY > effect(EffectIndex).Y + 140) Or (.SngA = 0) Then
  1644.                     'Reset the particle
  1645.                    Effect_Waterfall_Reset EffectIndex, LoopC
  1646.                 Else
  1647.                     'Set the particle information on the particle vertex
  1648.                    effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(.SngR, .SngG, .SngB, .SngA)
  1649.                     effect(EffectIndex).PartVertex(LoopC).X = .sngX
  1650.                     effect(EffectIndex).PartVertex(LoopC).Y = .sngY
  1651.                 End If
  1652.             End If
  1653.  
  1654.         End With
  1655.  
  1656.     Next LoopC
  1657.  
  1658. End Sub
  1659.  
  1660. Function Effect_Summon_Begin(ByVal X As Single, _
  1661.                              ByVal Y As Single, _
  1662.                              ByVal Gfx As Integer, _
  1663.                              ByVal Particles As Integer, _
  1664.                              Optional ByVal Progression As Single = 0) As Integer
  1665.  
  1666.     '*****************************************************************
  1667.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Summon_Begin
  1668.    '*****************************************************************
  1669.  
  1670.     Dim EffectIndex As Integer
  1671.     Dim LoopC As Long
  1672.  
  1673.     'Get the next open effect slot
  1674.    EffectIndex = Effect_NextOpenSlot
  1675.  
  1676.     If EffectIndex = -1 Then Exit Function
  1677.     'Return the index of the used slot
  1678.    Effect_Summon_Begin = EffectIndex
  1679.     'Set The Effect's Variables
  1680.    effect(EffectIndex).EffectNum = EffectNum_Summon        'Set the effect number
  1681.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  1682.    effect(EffectIndex).Used = True        'Enable the effect
  1683.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  1684.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  1685.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  1686.    effect(EffectIndex).Progression = Progression        'If we loop the effect
  1687.    'Set the number of particles left to the total avaliable
  1688.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  1689.     'Set the float variables
  1690.    effect(EffectIndex).FloatSize = Effect_FToDW(8)        'Size of the particles
  1691.    'Redim the number of particles
  1692.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  1693.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  1694.  
  1695.     'Create the particles
  1696.  
  1697.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  1698.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  1699.         effect(EffectIndex).Particles(LoopC).Used = True
  1700.        
  1701.         Effect_Summon_Reset EffectIndex, LoopC
  1702.  
  1703.     Next LoopC
  1704.  
  1705.     'Set The Initial Time
  1706.    effect(EffectIndex).PreviousFrame = GetTickCount
  1707. End Function
  1708.  
  1709. Private Sub Effect_Summon_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  1710.  
  1711.     '*****************************************************************
  1712.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Summon_Reset
  1713.    '*****************************************************************
  1714.  
  1715.     Dim X As Single
  1716.     Dim Y As Single
  1717.     Dim R As Single
  1718.  
  1719.     If effect(EffectIndex).Progression > 1000 Then
  1720.         effect(EffectIndex).Progression = effect(EffectIndex).Progression + 1.4
  1721.     Else
  1722.         effect(EffectIndex).Progression = effect(EffectIndex).Progression + 0.5
  1723.     End If
  1724.  
  1725.     R = (Index / 30) * Exp(Index / effect(EffectIndex).Progression)
  1726.     X = R * Cos(Index)
  1727.     Y = R * Sin(Index)
  1728.     'Reset the particle
  1729.    effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + X, effect(EffectIndex).Y + Y, 0, 0, 0, 0
  1730.     effect(EffectIndex).Particles(Index).ResetColor 0, Rnd, 0, 0.9, 0.2 + (Rnd * 0.2)
  1731. End Sub
  1732.  
  1733. Private Sub Effect_Summon_Update(ByVal EffectIndex As Integer)
  1734.  
  1735.     '*****************************************************************
  1736.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Summon_Update
  1737.    '*****************************************************************
  1738.  
  1739.     Dim ElapsedTime As Single
  1740.     Dim LoopC As Long
  1741.  
  1742.     'Calculate The Time Difference
  1743.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  1744.     effect(EffectIndex).PreviousFrame = GetTickCount
  1745.  
  1746.     'Go Through The Particle Loop
  1747.  
  1748.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  1749.  
  1750.         'Check If Particle Is In Use
  1751.  
  1752.         If effect(EffectIndex).Particles(LoopC).Used Then
  1753.             'Update The Particle
  1754.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  1755.  
  1756.             'Check if the particle is ready to die
  1757.  
  1758.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  1759.  
  1760.                 'Check if the effect is ending
  1761.  
  1762.                 If effect(EffectIndex).Progression < 1800 Then
  1763.                     'Reset the particle
  1764.                    Effect_Summon_Reset EffectIndex, LoopC
  1765.                 Else
  1766.                     'Disable the particle
  1767.                    effect(EffectIndex).Particles(LoopC).Used = False
  1768.                     'Subtract from the total particle count
  1769.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  1770.  
  1771.                     'Check if the effect is out of particles
  1772.  
  1773.                     If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  1774.                     'Clear the color (dont leave behind any artifacts)
  1775.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  1776.                 End If
  1777.  
  1778.             Else
  1779.                 'Set the particle information on the particle vertex
  1780.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  1781.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  1782.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  1783.             End If
  1784.         End If
  1785.  
  1786.     Next LoopC
  1787.  
  1788. End Sub
  1789.  
  1790. Function Effect_Meditate_Begin(ByVal X As Single, _
  1791.                                ByVal Y As Single, _
  1792.                                ByVal Gfx As Integer, _
  1793.                                ByVal Particles As Integer, _
  1794.                                Optional ByVal size As Byte = 30, _
  1795.                                Optional ByVal Time As Single = 10) As Integer
  1796.  
  1797.     '*****************************************************************
  1798.    'More info: http://www.vbgore.com/CommonCode.Partic ... tate_Begin
  1799.    '*****************************************************************
  1800.  
  1801.     Dim EffectIndex As Integer
  1802.     Dim LoopC As Long
  1803.  
  1804.     'Get the next open effect slot
  1805.    EffectIndex = Effect_NextOpenSlot
  1806.  
  1807.     If EffectIndex = -1 Then Exit Function
  1808.     'Return the index of the used slot
  1809.    Effect_Meditate_Begin = EffectIndex
  1810.     'Set The Effect's Variables
  1811.    effect(EffectIndex).EffectNum = EffectNum_Meditate        'Set the effect number
  1812.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  1813.    effect(EffectIndex).Used = True        'Enabled the effect
  1814.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  1815.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  1816.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  1817.    effect(EffectIndex).Modifier = size        'How large the circle is
  1818.    effect(EffectIndex).Progression = Time        'How long the effect will last
  1819.    'Set the number of particles left to the total avaliable
  1820.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  1821.     'Set the float variables
  1822.    effect(EffectIndex).FloatSize = Effect_FToDW(20)        'Size of the particles
  1823.    'Redim the number of particles
  1824.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  1825.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  1826.  
  1827.     'Create the particles
  1828.  
  1829.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  1830.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  1831.         effect(EffectIndex).Particles(LoopC).Used = True
  1832.        
  1833.         Effect_Meditate_Reset EffectIndex, LoopC
  1834.  
  1835.     Next LoopC
  1836.  
  1837.     'Set The Initial Time
  1838.    effect(EffectIndex).PreviousFrame = GetTickCount
  1839. End Function
  1840.  
  1841. Private Sub Effect_Meditate_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  1842.  
  1843.     '*****************************************************************
  1844.    'More info: http://www.vbgore.com/CommonCode.Partic ... tate_Reset
  1845.    '*****************************************************************
  1846.  
  1847.     Dim a As Single
  1848.     Dim X As Single
  1849.     Dim Y As Single
  1850.     Dim rR As Single
  1851.     Dim rG As Single
  1852.     Dim rB As Single
  1853.  
  1854.     'Get the positions
  1855.    a = Rnd * 360 * DegreeToRadian
  1856.     X = effect(EffectIndex).X - (Sin(a) * effect(EffectIndex).Modifier)
  1857.     Y = effect(EffectIndex).Y + (Cos(a) * effect(EffectIndex).Modifier / 2.5)
  1858.     'Load Colours
  1859.    rR = (0.1 - 0.05) * Rnd + 0.03
  1860.     rG = 0.8
  1861.     rB = 0.5
  1862.     'Reset the particle
  1863.    effect(EffectIndex).Particles(Index).ResetIt X, Y, 0, Rnd * -1, 0, -2
  1864.     effect(EffectIndex).Particles(Index).ResetColor rR, rG, rB, 0.6 + (Rnd * 0.4), 0.06 + (Rnd * 0.2)
  1865. End Sub
  1866.  
  1867. Private Sub Effect_Meditate_Update(ByVal EffectIndex As Integer)
  1868.  
  1869.     '*****************************************************************
  1870.    'More info: http://www.vbgore.com/CommonCode.Partic ... ate_Update
  1871.    '*****************************************************************
  1872.  
  1873.     Dim ElapsedTime As Single
  1874.     Dim LoopC As Long
  1875.  
  1876.     'Calculate The Time Difference
  1877.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  1878.     effect(EffectIndex).PreviousFrame = GetTickCount
  1879.  
  1880.     'Update the life span
  1881.  
  1882.     If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  1883.  
  1884.     'Go Through The Particle Loop
  1885.  
  1886.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  1887.  
  1888.         'Check If Particle Is In Use
  1889.  
  1890.         If effect(EffectIndex).Particles(LoopC).Used Then
  1891.             'Update The Particle
  1892.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  1893.  
  1894.             'Check if the particle is ready to die
  1895.  
  1896.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  1897.  
  1898.                 'Check if the effect is ending
  1899.  
  1900.                 If effect(EffectIndex).Progression > 0 Then
  1901.                     'Reset the particle
  1902.                    Effect_Meditate_Reset EffectIndex, LoopC
  1903.                 Else
  1904.                     'Disable the particle
  1905.                    effect(EffectIndex).Particles(LoopC).Used = False
  1906.                     'Subtract from the total particle count
  1907.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  1908.  
  1909.                     'Check if the effect is out of particles
  1910.  
  1911.                     If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  1912.                     'Clear the color (dont leave behind any artifacts)
  1913.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  1914.                 End If
  1915.  
  1916.             Else
  1917.                 'Set the particle information on the particle vertex
  1918.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  1919.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  1920.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  1921.             End If
  1922.         End If
  1923.  
  1924.     Next LoopC
  1925.  
  1926. End Sub
  1927.  
  1928. Function Effect_Portal_Begin(ByVal X As Single, _
  1929.                              ByVal Y As Single, _
  1930.                              ByVal Gfx As Integer, _
  1931.                              ByVal Particles As Integer, _
  1932.                              Optional ByVal size As Byte = 30, _
  1933.                              Optional ByVal Time As Single = 10) As Long
  1934.  
  1935.     '*****************************************************************
  1936.    'More info: http://www.vbgore.com/CommonCode.Partic ... rtal_Begin
  1937.    '*****************************************************************
  1938.  
  1939.     Dim EffectIndex As Integer
  1940.     Dim LoopC As Long
  1941.  
  1942.     'Get the next open effect slot
  1943.    EffectIndex = Effect_NextOpenSlot
  1944.  
  1945.     If EffectIndex = -1 Then Exit Function
  1946.  
  1947.     'Return the index of the used slot
  1948.    Effect_Portal_Begin = EffectIndex
  1949.  
  1950.     'Set The Effect's Variables
  1951.    effect(EffectIndex).EffectNum = EffectNum_Portal        'Set the effect number
  1952.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  1953.    effect(EffectIndex).Used = True        'Enabled the effect
  1954.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  1955.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  1956.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  1957.    effect(EffectIndex).Modifier = size        'How large the circle is
  1958.    effect(EffectIndex).Progression = Time        'How long the effect will last
  1959.  
  1960.     'Set the number of particles left to the total avaliable
  1961.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  1962.  
  1963.     'Set the float variables
  1964.    effect(EffectIndex).FloatSize = Effect_FToDW(20)        'Size of the particles
  1965.  
  1966.     'Redim the number of particles
  1967.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  1968.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  1969.  
  1970.     'Create the particles
  1971.  
  1972.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  1973.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  1974.         effect(EffectIndex).Particles(LoopC).Used = True
  1975.        
  1976.         Effect_Portal_Reset EffectIndex, LoopC
  1977.  
  1978.     Next LoopC
  1979.  
  1980.     'Set The Initial Time
  1981.    effect(EffectIndex).PreviousFrame = GetTickCount
  1982. End Function
  1983.  
  1984. Private Sub Effect_Portal_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  1985.  
  1986.     '*****************************************************************
  1987.    'More info: http://www.vbgore.com/CommonCode.Partic ... rtal_Reset
  1988.    '*****************************************************************
  1989.  
  1990.     Dim a As Single
  1991.     Dim X As Single
  1992.     Dim Y As Single
  1993.     Dim rR As Single
  1994.     Dim rG As Single
  1995.     Dim rB As Single
  1996.  
  1997.     'Get the positions
  1998.    a = Rnd * 360 * DegreeToRadian
  1999.  
  2000.     effect(EffectIndex).Progression = effect(EffectIndex).Progression + 0.14
  2001.  
  2002.     If Rnd > Rnd Then
  2003.         X = effect(EffectIndex).X - (Sin(a) * effect(EffectIndex).Modifier / 1.8) * Rnd * 1.1
  2004.         Y = effect(EffectIndex).Y + (Cos(a) * effect(EffectIndex).Modifier * 1.1) * Rnd * 1.1
  2005.         rR = (0.1 - 0.05) * Rnd + 0.03
  2006.         rG = 0.2
  2007.         rB = 0.8
  2008.     Else
  2009.         X = effect(EffectIndex).X - (Sin(a) * effect(EffectIndex).Modifier / 3)
  2010.         Y = effect(EffectIndex).Y + (Cos(a) * effect(EffectIndex).Modifier / 1.5)
  2011.         rR = (0.2 - 0.06) * Rnd + 0.04
  2012.         rG = 0.3
  2013.         rB = 0.2
  2014.     End If
  2015.  
  2016.     'Reset the particle
  2017.    effect(EffectIndex).Particles(Index).ResetIt X, Y, 0, Rnd * -1, 0, 0        '-2
  2018.    effect(EffectIndex).Particles(Index).ResetColor rR, rG, rB, 0.6 + (Rnd * 0.4), 0.06 + (Rnd * 0.2)
  2019. End Sub
  2020.  
  2021. Private Sub Effect_Portal_Update(ByVal EffectIndex As Integer)
  2022.  
  2023.     '*****************************************************************
  2024.    'More info: http://www.vbgore.com/CommonCode.Partic ... tal_Update
  2025.    '*****************************************************************
  2026.  
  2027.     Dim ElapsedTime As Single
  2028.     Dim LoopC As Long
  2029.  
  2030.     'Calculate The Time Difference
  2031.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  2032.     effect(EffectIndex).PreviousFrame = GetTickCount
  2033.  
  2034.     'Update the life span
  2035.  
  2036.     'Go Through The Particle Loop
  2037.  
  2038.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  2039.  
  2040.         'Check If Particle Is In Use
  2041.  
  2042.         If effect(EffectIndex).Particles(LoopC).Used Then
  2043.             'Update The Particle
  2044.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  2045.  
  2046.             'Check if the particle is ready to die
  2047.  
  2048.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  2049.  
  2050.                 'Check if the effect is ending
  2051.  
  2052.                 If effect(EffectIndex).Progression > 0 Then
  2053.                     'Reset the particle
  2054.                    Effect_Portal_Reset EffectIndex, LoopC
  2055.                 Else
  2056.                     'Disable the particle
  2057.                    effect(EffectIndex).Particles(LoopC).Used = False
  2058.                     'Subtract from the total particle count
  2059.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  2060.  
  2061.                     'Check if the effect is out of particles
  2062.  
  2063.                     If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  2064.                     'Clear the color (dont leave behind any artifacts)
  2065.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  2066.                 End If
  2067.  
  2068.             Else
  2069.                 'Set the particle information on the particle vertex
  2070.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  2071.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  2072.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  2073.             End If
  2074.         End If
  2075.  
  2076.     Next LoopC
  2077.  
  2078. End Sub
  2079.  
  2080. Function Effect_Atomic_Begin(ByVal X As Single, _
  2081.                              ByVal Y As Single, _
  2082.                              ByVal Gfx As Integer, _
  2083.                              ByVal Particles As Integer, _
  2084.                              Optional ByVal size As Byte = 30, _
  2085.                              Optional ByVal Time As Single = 10) As Integer
  2086.  
  2087.     '*****************************************************************
  2088.    '*****************************************************************
  2089.  
  2090.     Dim EffectIndex As Integer
  2091.     Dim LoopC As Long
  2092.  
  2093.     'Get the next open effect slot
  2094.    EffectIndex = Effect_NextOpenSlot
  2095.  
  2096.     If EffectIndex = -1 Then Exit Function
  2097.     'Return the index of the used slot
  2098.    Effect_Atomic_Begin = EffectIndex
  2099.     'Set The Effect's Variables
  2100.    effect(EffectIndex).EffectNum = EffectNum_Atomic        'Set the effect number
  2101.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  2102.    effect(EffectIndex).Used = True        'Enabled the effect
  2103.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  2104.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  2105.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  2106.    effect(EffectIndex).Modifier = size        'How large the circle is
  2107.    effect(EffectIndex).Progression = Time        'How long the effect will last
  2108.    'Set the number of particles left to the total avaliable
  2109.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  2110.     'Set the float variables
  2111.    effect(EffectIndex).FloatSize = Effect_FToDW(8)        'Size of the particles
  2112.    'Redim the number of particles
  2113.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  2114.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  2115.  
  2116.     'Create the particles
  2117.  
  2118.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  2119.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  2120.         effect(EffectIndex).Particles(LoopC).Used = True
  2121.        
  2122.         Effect_Atomic_Reset EffectIndex, LoopC
  2123.  
  2124.     Next LoopC
  2125.  
  2126.     'Set The Initial Time
  2127.    effect(EffectIndex).PreviousFrame = GetTickCount
  2128. End Function
  2129.  
  2130. Private Sub Effect_Atomic_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  2131.  
  2132.     '*****************************************************************
  2133.    '*****************************************************************
  2134.  
  2135.     Dim R As Single
  2136.     Dim X As Single
  2137.     Dim Y As Single
  2138.  
  2139.     'Get the positions
  2140.    R = 10 + Sin(2 * (Index / 10)) * 50
  2141.     X = R * Cos(Index / 30)
  2142.     Y = R * Sin(Index / 30)
  2143.     'Reset the particle
  2144.    effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + X, effect(EffectIndex).Y + Y, 0, 0, 0, 0
  2145.     effect(EffectIndex).Particles(Index).ResetColor 200, 50, 1, 1, 0.9 + (Rnd * 0.2)
  2146. End Sub
  2147.  
  2148. Private Sub Effect_Atomic_Update(ByVal EffectIndex As Integer)
  2149.  
  2150.     '*****************************************************************
  2151.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Protection_Update
  2152.    '*****************************************************************
  2153.  
  2154.     Dim ElapsedTime As Single
  2155.     Dim LoopC As Long
  2156.  
  2157.     'Calculate The Time Difference
  2158.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  2159.     effect(EffectIndex).PreviousFrame = GetTickCount
  2160.  
  2161.     'Update the life span
  2162.  
  2163.     If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  2164.  
  2165.     'Go through the particle loop
  2166.  
  2167.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  2168.  
  2169.         'Check If Particle Is In Use
  2170.  
  2171.         If effect(EffectIndex).Particles(LoopC).Used Then
  2172.             'Update The Particle
  2173.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  2174.  
  2175.             'Check if the particle is ready to die
  2176.  
  2177.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  2178.  
  2179.                 'Check if the effect is ending
  2180.  
  2181.                 If effect(EffectIndex).Progression > 0 Then
  2182.                     'Reset the particle
  2183.                    Effect_Atomic_Reset EffectIndex, LoopC
  2184.                 Else
  2185.                     'Disable the particle
  2186.                    effect(EffectIndex).Particles(LoopC).Used = False
  2187.                     'Subtract from the total particle count
  2188.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  2189.  
  2190.                     'Check if the effect is out of particles
  2191.  
  2192.                     If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  2193.                     'Clear the color (dont leave behind any artifacts)
  2194.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  2195.                 End If
  2196.  
  2197.             Else
  2198.                 'Set the particle information on the particle vertex
  2199.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  2200.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  2201.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  2202.             End If
  2203.         End If
  2204.  
  2205.     Next LoopC
  2206.  
  2207. End Sub
  2208.  
  2209. Function Effect_Circle_Begin(ByVal X As Single, _
  2210.                              ByVal Y As Single, _
  2211.                              ByVal Gfx As Integer, _
  2212.                              ByVal Particles As Integer, _
  2213.                              Optional ByVal size As Byte = 30, _
  2214.                              Optional ByVal Time As Single = 10) As Integer
  2215.  
  2216.     '*****************************************************************
  2217.    '*****************************************************************
  2218.  
  2219.     Dim EffectIndex As Integer
  2220.     Dim LoopC As Long
  2221.  
  2222.     'Get the next open effect slot
  2223.    EffectIndex = Effect_NextOpenSlot
  2224.  
  2225.     If EffectIndex = -1 Then Exit Function
  2226.     'Return the index of the used slot
  2227.    Effect_Circle_Begin = EffectIndex
  2228.     'Set The Effect's Variables
  2229.    effect(EffectIndex).EffectNum = EffectNum_Circle        'Set the effect number
  2230.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  2231.    effect(EffectIndex).Used = True        'Enabled the effect
  2232.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  2233.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  2234.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  2235.    effect(EffectIndex).Modifier = size        'How large the circle is
  2236.    effect(EffectIndex).Progression = Time        'How long the effect will last
  2237.    'Set the number of particles left to the total avaliable
  2238.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  2239.     'Set the float variables
  2240.    effect(EffectIndex).FloatSize = Effect_FToDW(8)        'Size of the particles
  2241.    'Redim the number of particles
  2242.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  2243.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  2244.  
  2245.     'Create the particles
  2246.  
  2247.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  2248.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  2249.         effect(EffectIndex).Particles(LoopC).Used = True
  2250.        
  2251.         Effect_Circle_Reset EffectIndex, LoopC
  2252.  
  2253.     Next LoopC
  2254.  
  2255.     'Set The Initial Time
  2256.    effect(EffectIndex).PreviousFrame = GetTickCount
  2257. End Function
  2258.  
  2259. Private Sub Effect_Circle_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  2260.  
  2261.     '*****************************************************************
  2262.    '*****************************************************************
  2263.  
  2264.     Dim a As Single
  2265.     Dim X As Single
  2266.     Dim Y As Single
  2267.  
  2268.     'Get the positions
  2269.    a = Rnd * 360 * DegreeToRadian        'The point on the circumference to be used
  2270.    X = effect(EffectIndex).X - (Sin(a) * 40)        'The 40s state the radius of circle
  2271.    Y = effect(EffectIndex).Y + (Cos(a) * 40)
  2272.     'Reset the particle
  2273.    effect(EffectIndex).Particles(Index).ResetIt X, Y, 0, 0, 0, -2
  2274.     effect(EffectIndex).Particles(Index).ResetColor 1 * Rnd + 0.4, 0, 1, 1, 0.2 + (Rnd * 0.2)
  2275. End Sub
  2276.  
  2277. Private Sub Effect_Circle_Update(ByVal EffectIndex As Integer)
  2278.  
  2279.     '*****************************************************************
  2280.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Protection_Update
  2281.    '*****************************************************************
  2282.  
  2283.     Dim ElapsedTime As Single
  2284.     Dim LoopC As Long
  2285.  
  2286.     'Calculate The Time Difference
  2287.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  2288.     effect(EffectIndex).PreviousFrame = GetTickCount
  2289.  
  2290.     'Update the life span
  2291.  
  2292.     If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  2293.  
  2294.     'Go through the particle loop
  2295.  
  2296.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  2297.  
  2298.         'Check If Particle Is In Use
  2299.  
  2300.         If effect(EffectIndex).Particles(LoopC).Used Then
  2301.             'Update The Particle
  2302.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  2303.  
  2304.             'Check if the particle is ready to die
  2305.  
  2306.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  2307.  
  2308.                 'Check if the effect is ending
  2309.  
  2310.                 If effect(EffectIndex).Progression > 0 Then
  2311.                     'Reset the particle
  2312.                    Effect_Circle_Reset EffectIndex, LoopC
  2313.                 Else
  2314.                     'Disable the particle
  2315.                    effect(EffectIndex).Particles(LoopC).Used = False
  2316.                     'Subtract from the total particle count
  2317.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  2318.  
  2319.                     'Check if the effect is out of particles
  2320.  
  2321.                     If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  2322.                     'Clear the color (dont leave behind any artifacts)
  2323.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  2324.                 End If
  2325.  
  2326.             Else
  2327.                 'Set the particle information on the particle vertex
  2328.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  2329.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  2330.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  2331.             End If
  2332.         End If
  2333.  
  2334.     Next LoopC
  2335.  
  2336. End Sub
  2337.  
  2338. Function Effect_Raro_Begin(ByVal X As Single, _
  2339.                            ByVal Y As Single, _
  2340.                            ByVal Gfx As Integer, _
  2341.                            ByVal Particles As Integer, _
  2342.                            Optional ByVal size As Byte = 30, _
  2343.                            Optional ByVal Time As Single = 10) As Integer
  2344.  
  2345.     '*****************************************************************
  2346.    '*****************************************************************
  2347.  
  2348.     Dim EffectIndex As Integer
  2349.     Dim LoopC As Long
  2350.  
  2351.     'Get the next open effect slot
  2352.    EffectIndex = Effect_NextOpenSlot
  2353.  
  2354.     If EffectIndex = -1 Then Exit Function
  2355.     'Return the index of the used slot
  2356.    Effect_Raro_Begin = EffectIndex
  2357.     'Set The Effect's Variables
  2358.    effect(EffectIndex).EffectNum = EffectNum_Raro        'Set the effect number
  2359.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  2360.    effect(EffectIndex).Used = True        'Enabled the effect
  2361.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  2362.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  2363.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  2364.    effect(EffectIndex).Modifier = size        'How large the circle is
  2365.    effect(EffectIndex).Progression = Time        'How long the effect will last
  2366.    'Set the number of particles left to the total avaliable
  2367.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  2368.     'Set the float variables
  2369.    effect(EffectIndex).FloatSize = Effect_FToDW(8)        'Size of the particles
  2370.    'Redim the number of particles
  2371.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  2372.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  2373.  
  2374.     'Create the particles
  2375.  
  2376.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  2377.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  2378.         effect(EffectIndex).Particles(LoopC).Used = True
  2379.        
  2380.         Effect_Raro_Reset EffectIndex, LoopC
  2381.  
  2382.     Next LoopC
  2383.  
  2384.     'Set The Initial Time
  2385.    effect(EffectIndex).PreviousFrame = GetTickCount
  2386. End Function
  2387.  
  2388. Private Sub Effect_Raro_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  2389.  
  2390.     '*****************************************************************
  2391.    '*****************************************************************
  2392.  
  2393.     Dim X As Single
  2394.     Dim Y As Single
  2395.     Dim i As Single
  2396.  
  2397.     'Get the positions
  2398.    'a = Rnd * 360 * DegreeToRadian 'The point on the circumference to be used
  2399.  
  2400.     For i = 0 To 360 Step 30
  2401.         X = effect(EffectIndex).X - Cos(i)
  2402.         Y = effect(EffectIndex).Y + Sin(i) + Rnd
  2403.         'Reset the particle
  2404.        effect(EffectIndex).Particles(Index).ResetIt X, Y, 0, 0, 0, 0
  2405.         effect(EffectIndex).Particles(Index).ResetColor 1, 1, 1, 1, 0.2 + (Rnd * 0.2)
  2406.  
  2407.     Next i
  2408.  
  2409. End Sub
  2410.  
  2411. Private Sub Effect_Raro_Update(ByVal EffectIndex As Integer)
  2412.  
  2413.     '*****************************************************************
  2414.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Protection_Update
  2415.    '*****************************************************************
  2416.  
  2417.     Dim ElapsedTime As Single
  2418.     Dim LoopC As Long
  2419.  
  2420.     'Calculate The Time Difference
  2421.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  2422.     effect(EffectIndex).PreviousFrame = GetTickCount
  2423.  
  2424.     'Update the life span
  2425.  
  2426.     If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  2427.  
  2428.     'Go through the particle loop
  2429.  
  2430.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  2431.  
  2432.         'Check If Particle Is In Use
  2433.  
  2434.         If effect(EffectIndex).Particles(LoopC).Used Then
  2435.             'Update The Particle
  2436.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  2437.  
  2438.             'Check if the particle is ready to die
  2439.  
  2440.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  2441.  
  2442.                 'Check if the effect is ending
  2443.  
  2444.                 If effect(EffectIndex).Progression > 0 Then
  2445.                     'Reset the particle
  2446.                    Effect_Raro_Reset EffectIndex, LoopC
  2447.                 Else
  2448.                     'Disable the particle
  2449.                    effect(EffectIndex).Particles(LoopC).Used = False
  2450.                     'Subtract from the total particle count
  2451.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  2452.  
  2453.                     'Check if the effect is out of particles
  2454.  
  2455.                     If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  2456.                     'Clear the color (dont leave behind any artifacts)
  2457.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  2458.                 End If
  2459.  
  2460.             Else
  2461.                 'Set the particle information on the particle vertex
  2462.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  2463.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  2464.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  2465.             End If
  2466.         End If
  2467.  
  2468.     Next LoopC
  2469.  
  2470. End Sub
  2471.  
  2472. Function Effect_Lissajous_Begin(ByVal X As Single, _
  2473.                                 ByVal Y As Single, _
  2474.                                 ByVal Gfx As Integer, _
  2475.                                 ByVal Particles As Integer, _
  2476.                                 Optional ByVal Progression As Single = 0, _
  2477.                                 Optional size As Byte = 30, _
  2478.                                 Optional R As Single = 100, _
  2479.                                 Optional g As Single = 100, _
  2480.                                 Optional b As Single = 100) As Long
  2481.  
  2482.     '*****************************************************************
  2483.    'Particle effect Lissajous equation
  2484.    '*****************************************************************
  2485.  
  2486.     Dim EffectIndex As Integer
  2487.     Dim LoopC As Long
  2488.  
  2489.     'Get the next open effect slot
  2490.    EffectIndex = Effect_NextOpenSlot
  2491.  
  2492.     If EffectIndex = -1 Then Exit Function
  2493.     'Return the index of the used slot
  2494.    Effect_Lissajous_Begin = EffectIndex
  2495.     'Set The Effect's Variables
  2496.    effect(EffectIndex).EffectNum = EffectNum_Lissajous        'Set the effect number
  2497.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  2498.    effect(EffectIndex).Used = True        'Enable the effect
  2499.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  2500.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  2501.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  2502.    effect(EffectIndex).Modifier = size        'How large the circle is
  2503.    effect(EffectIndex).Progression = Progression
  2504.     effect(EffectIndex).R = R
  2505.     effect(EffectIndex).g = g
  2506.     effect(EffectIndex).b = b
  2507.     'Set the number of particles left to the total avaliable
  2508.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  2509.     'Set the float variables
  2510.    effect(EffectIndex).FloatSize = Effect_FToDW(8)        'Size of the particles
  2511.    'Redim the number of particles
  2512.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  2513.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  2514.  
  2515.     'Create the particles
  2516.  
  2517.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  2518.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  2519.         effect(EffectIndex).Particles(LoopC).Used = True
  2520.        
  2521.         Effect_Lissajous_Reset EffectIndex, LoopC
  2522.  
  2523.     Next LoopC
  2524.  
  2525.     'Set The Initial Time
  2526.    effect(EffectIndex).PreviousFrame = GetTickCount
  2527. End Function
  2528.  
  2529. Private Sub Effect_Lissajous_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  2530.  
  2531.     '*****************************************************************
  2532.    'More info: [url=http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Reset]http://www.vbgore.com/CommonCode.Partic ... late_Reset[/url]
  2533.    '*****************************************************************
  2534.  
  2535.     Dim X As Single
  2536.     Dim Y As Single
  2537.     Dim a As Single
  2538.  
  2539.     '2
  2540.    '1
  2541.    '1
  2542.    '2
  2543.    effect(EffectIndex).Progression = effect(EffectIndex).Progression + 0.01
  2544.     a = effect(EffectIndex).Progression
  2545.  
  2546.     If RandomNumber(1, 2) = 1 Then
  2547.         X = effect(EffectIndex).X - (Sin(2 * a) * effect(EffectIndex).Modifier) - 20
  2548.         Y = effect(EffectIndex).Y + (Sin(1 * a) * effect(EffectIndex).Modifier)
  2549.         'Reset the particle
  2550.        effect(EffectIndex).Particles(Index).ResetIt X, Y, 0, 0, 0, 0
  2551.         effect(EffectIndex).Particles(Index).ResetColor effect(EffectIndex).R * effect(EffectIndex).Progression, effect(EffectIndex).g * effect(EffectIndex).Progression, effect(EffectIndex).b, 0.2, 0.2 + (Rnd * 0.2)
  2552.     Else
  2553.         X = effect(EffectIndex).X - (Sin(1 + 5 * a) * effect(EffectIndex).Modifier) - 20
  2554.         Y = effect(EffectIndex).Y + (Sin(2 + 7 * a) * effect(EffectIndex).Modifier)
  2555.         'Reset the particle
  2556.        effect(EffectIndex).Particles(Index).ResetIt X, Y, 0, 0, 0, 0
  2557.         effect(EffectIndex).Particles(Index).ResetColor effect(EffectIndex).R * effect(EffectIndex).Progression, effect(EffectIndex).g * effect(EffectIndex).Progression, effect(EffectIndex).b, 0.2, 0.2 + (Rnd * 0.2)
  2558.     End If
  2559.  
  2560. End Sub
  2561.  
  2562. Private Sub Effect_Lissajous_Update(ByVal EffectIndex As Integer)
  2563.  
  2564.     '*****************************************************************
  2565.    'More info: [url=http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Update]http://www.vbgore.com/CommonCode.Partic ... ate_Update[/url]
  2566.    '*****************************************************************
  2567.  
  2568.     Dim ElapsedTime As Single
  2569.     Dim LoopC As Long
  2570.  
  2571.     'Calculate The Time Difference
  2572.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  2573.     effect(EffectIndex).PreviousFrame = GetTickCount
  2574.  
  2575.     'Go Through The Particle Loop
  2576.  
  2577.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  2578.  
  2579.         'Check If Particle Is In Use
  2580.  
  2581.         If effect(EffectIndex).Particles(LoopC).Used Then
  2582.             'Update The Particle
  2583.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  2584.  
  2585.             'Check if the particle is ready to die
  2586.  
  2587.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  2588.  
  2589.                 'Check if the effect is ending
  2590.  
  2591.                 If effect(EffectIndex).Progression > 0 Then
  2592.                     'Reset the particle
  2593.                    Effect_Lissajous_Reset EffectIndex, LoopC
  2594.                 Else
  2595.                     'Disable the particle
  2596.                    effect(EffectIndex).Particles(LoopC).Used = False
  2597.                     'Subtract from the total particle count
  2598.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  2599.  
  2600.                     'Check if the effect is out of particles
  2601.  
  2602.                     If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  2603.                     'Clear the color (dont leave behind any artifacts)
  2604.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  2605.                 End If
  2606.  
  2607.             Else
  2608.                 'Set the particle information on the particle vertex
  2609.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  2610.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  2611.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  2612.             End If
  2613.         End If
  2614.  
  2615.     Next LoopC
  2616.  
  2617. End Sub
  2618.  
  2619. Function Effect_Apocalipsis_Begin(ByVal X As Single, _
  2620.                                   ByVal Y As Single, _
  2621.                                   ByVal Gfx As Integer, _
  2622.                                   ByVal Particles As Integer, _
  2623.                                   Optional ByVal Progression As Single = 0) As Integer
  2624.  
  2625.     '*****************************************************************
  2626.    'Particle effect template for effects as described on the
  2627.    'wiki page: http://www.vbgore.com/Particle_effect_equations
  2628.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Begin
  2629.    '*****************************************************************
  2630.  
  2631.     Dim EffectIndex As Integer
  2632.     Dim LoopC As Long
  2633.  
  2634.     'Get the next open effect slot
  2635.    EffectIndex = Effect_NextOpenSlot
  2636.  
  2637.     If EffectIndex = -1 Then Exit Function
  2638.     'Return the index of the used slot
  2639.    Effect_Apocalipsis_Begin = EffectIndex
  2640.     'Set The Effect's Variables
  2641.    effect(EffectIndex).EffectNum = EffectNum_Apocalipsis        'Set the effect number
  2642.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  2643.    effect(EffectIndex).Used = True        'Enable the effect
  2644.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  2645.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  2646.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  2647.    effect(EffectIndex).Progression = Progression
  2648.     effect(EffectIndex).KillWhenAtTarget = True        'End the effect when it reaches the target (progression = 0)
  2649.    effect(EffectIndex).KillWhenTargetLost = True        'End the effect if the target is lost (progression = 0)
  2650.  
  2651.     'Set the number of particles left to the total avaliable
  2652.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  2653.     'Set the float variables
  2654.    effect(EffectIndex).FloatSize = Effect_FToDW(8)        'Size of the particles
  2655.    'Redim the number of particles
  2656.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  2657.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  2658.  
  2659.     'Create the particles
  2660.  
  2661.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  2662.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  2663.         effect(EffectIndex).Particles(LoopC).Used = True
  2664.        
  2665.         Effect_Apocalipsis_Reset EffectIndex, LoopC
  2666.  
  2667.     Next LoopC
  2668.  
  2669.     'Set The Initial Time
  2670.    effect(EffectIndex).PreviousFrame = GetTickCount
  2671. End Function
  2672.  
  2673. Private Sub Effect_Apocalipsis_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  2674.  
  2675.     '*****************************************************************
  2676.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Reset
  2677.    '*****************************************************************
  2678.  
  2679.     Dim X As Single
  2680.     Dim Y As Single
  2681.     Dim a As Single
  2682.  
  2683.     effect(EffectIndex).Progression = effect(EffectIndex).Progression + 0.01
  2684.     a = effect(EffectIndex).Progression
  2685.  
  2686.     If RandomNumber(1, 2) = 1 Then
  2687.         X = effect(EffectIndex).X - (Sin(a)) * 120
  2688.         Y = effect(EffectIndex).Y + Cos(5 * a) * 20        'The 40s state the radius of circle
  2689.        effect(EffectIndex).Particles(Index).ResetIt X, Y, 0, 0, 0, 0
  2690.         effect(EffectIndex).Particles(Index).ResetColor 5, 0, 3, 1, 0.2 + (Rnd * 0.2)
  2691.     Else
  2692.         X = effect(EffectIndex).X - (Sin(a)) * 120
  2693.         Y = effect(EffectIndex).Y - Cos(5 * a) * 20        'The 40s state the radius of circle
  2694.        '
  2695.        effect(EffectIndex).Particles(Index).ResetIt X, Y, 0, 0, 0, 0
  2696.         effect(EffectIndex).Particles(Index).ResetColor 0, 5, 2, 1, 0.2 + (Rnd * 0.2)
  2697.     End If
  2698.  
  2699. End Sub
  2700.  
  2701. Private Sub Effect_Apocalipsis_Update(ByVal EffectIndex As Integer)
  2702.  
  2703.     '*****************************************************************
  2704.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Update
  2705.    '*****************************************************************
  2706.  
  2707.     Dim ElapsedTime As Single
  2708.     Dim LoopC As Long
  2709.  
  2710.     'Calculate The Time Difference
  2711.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  2712.     effect(EffectIndex).PreviousFrame = GetTickCount
  2713.  
  2714.     'Go Through The Particle Loop
  2715.  
  2716.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  2717.  
  2718.         'Check If Particle Is In Use
  2719.  
  2720.         If effect(EffectIndex).Particles(LoopC).Used Then
  2721.             'Update The Particle
  2722.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  2723.  
  2724.             'Check if the particle is ready to die
  2725.  
  2726.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  2727.  
  2728.                 'Check if the effect is ending
  2729.  
  2730.                 If effect(EffectIndex).Progression > 0 Then
  2731.                     'Reset the particle
  2732.                    Effect_Apocalipsis_Reset EffectIndex, LoopC
  2733.                 Else
  2734.                     'Disable the particle
  2735.                    effect(EffectIndex).Particles(LoopC).Used = False
  2736.                     'Subtract from the total particle count
  2737.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  2738.  
  2739.                     'Check if the effect is out of particles
  2740.  
  2741.                     If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  2742.                     'Clear the color (dont leave behind any artifacts)
  2743.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  2744.                 End If
  2745.  
  2746.             Else
  2747.                 'Set the particle information on the particle vertex
  2748.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  2749.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  2750.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  2751.             End If
  2752.         End If
  2753.  
  2754.     Next LoopC
  2755.  
  2756. End Sub
  2757.  
  2758. Function Effect_Humo_Begin(ByVal X As Single, _
  2759.                            ByVal Y As Single, _
  2760.                            ByVal Gfx As Integer, _
  2761.                            ByVal Particles As Integer, _
  2762.                            Optional ByVal Direction As Integer = 180, _
  2763.                            Optional ByVal Progression As Single = 1) As Integer
  2764.  
  2765.     '*****************************************************************
  2766.    'More info: http://svn2.assembla.com/svn/vblore/trunk/Code/Common%20Code/Particles.bas
  2767.    '*****************************************************************
  2768.  
  2769.     Dim EffectIndex As Integer
  2770.     Dim LoopC As Long
  2771.  
  2772.     'Get the next open effect slot
  2773.    EffectIndex = Effect_NextOpenSlot
  2774.  
  2775.     If EffectIndex = -1 Then Exit Function
  2776.     'Return the index of the used slot
  2777.    Effect_Humo_Begin = EffectIndex
  2778.     'Set The Effect's Variables
  2779.    effect(EffectIndex).EffectNum = EffectNum_Humo        'Set the effect number
  2780.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  2781.    effect(EffectIndex).Used = True        'Enabled the effect
  2782.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  2783.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  2784.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  2785.    effect(EffectIndex).Direction = Direction        'The direction the effect is animat
  2786.    effect(EffectIndex).Progression = Progression        'Loop the effect
  2787.    'Set the number of particles left to the total avaliable
  2788.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  2789.     'Set the float variables
  2790.    effect(EffectIndex).FloatSize = Effect_FToDW(30)        'Size of the particles
  2791.    'Redim the number of particles
  2792.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  2793.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  2794.  
  2795.     'Create the particles
  2796.  
  2797.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  2798.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  2799.         effect(EffectIndex).Particles(LoopC).Used = True
  2800.        
  2801.         Effect_Humo_Reset EffectIndex, LoopC
  2802.  
  2803.     Next LoopC
  2804.  
  2805.     'Set The Initial Time
  2806.    effect(EffectIndex).PreviousFrame = GetTickCount
  2807. End Function
  2808.  
  2809. Private Sub Effect_Humo_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  2810.     '*****************************************************************
  2811.    'More info: http://svn2.assembla.com/svn/vblore/trunk/Code/Common%20Code/Particles.bas
  2812.    '*****************************************************************
  2813.    'Reset the particle
  2814.    'Effect(EffectIndex).Particles(index).ResetIt Effect(EffectIndex).X - 10 + Rnd * 20, Effect(EffectIndex).Y - 10 + Rnd * 20, -Sin((Effect(EffectIndex).Direction + (Rnd * 70) - 35) * DegreeToRadian) * 8, Cos((Effect(EffectIndex).Direction + (Rnd * 70) - 35) * DegreeToRadian) * 8, 0, 0
  2815.    'Effect(EffectIndex).Particles(Index).ResetColor 1, 0.2, 0.2, 0.4 + (Rnd * 0.2), 0.03 + (Rnd * 0.07)
  2816.    effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X - 10 + Rnd * 50, effect(EffectIndex).Y - 10 + Rnd * 50, -Sin((effect(EffectIndex).Direction + (Rnd * 70) - 35) * DegreeToRadian) * 5, Cos((effect(EffectIndex).Direction + (Rnd * 70) - 35) * DegreeToRadian) * 8, 0.5, 0
  2817.     effect(EffectIndex).Particles(Index).ResetColor 0.2, 0.2, 0.2, 0.2 + (Rnd * 0.2), 0.03 + (Rnd * 0.01)
  2818.     'Reset the particle
  2819.    'Effect(EffectIndex).Particles(Index).ResetIt Effect(EffectIndex).X - 10 + Rnd * 50, Effect(EffectIndex).Y - 10 + Rnd * 80, -Sin((Effect(EffectIndex).Direction + (Rnd * 70) - 35) * DegreeToRadian) * 8, Cos((Effect(EffectIndex).Direction + (Rnd * 70) - 35) * DegreeToRadian) * 8, 0, 0
  2820.    'Effect(EffectIndex).Particles(Index).ResetColor 0.1, 0.1, 0.1, 0.4 + (Rnd * 0.2), 0.03 + (Rnd * 0.07)
  2821.    'Effect(EffectIndex).Particles(index).ResetColor 0.1, 0.1, 0.1, 0.4 + (Rnd * 0.2), 0.03 + (Rnd * 0.07)
  2822. End Sub
  2823.  
  2824. Private Sub Effect_Humo_Update(ByVal EffectIndex As Integer)
  2825.  
  2826.     '*****************************************************************
  2827.    'More info: http://svn2.assembla.com/svn/vblore/trunk/Code/Common%20Code/Particles.bas
  2828.    '*****************************************************************
  2829.  
  2830.     Dim ElapsedTime As Single
  2831.     Dim LoopC As Long
  2832.  
  2833.     'Calculate The Time Difference
  2834.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  2835.     effect(EffectIndex).PreviousFrame = GetTickCount
  2836.  
  2837.     'Go Through The Particle Loop
  2838.  
  2839.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  2840.  
  2841.         'Check If Particle Is In Use
  2842.  
  2843.         If effect(EffectIndex).Particles(LoopC).Used Then
  2844.             'Update The Particle
  2845.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  2846.  
  2847.             'Check if the particle is ready to die
  2848.  
  2849.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  2850.  
  2851.                 'Check if the effect is ending
  2852.  
  2853.                 If effect(EffectIndex).Progression <> 0 Then
  2854.                     'Reset the particle
  2855.                    Effect_Humo_Reset EffectIndex, LoopC
  2856.                 Else
  2857.                     'Disable the particle
  2858.                    effect(EffectIndex).Particles(LoopC).Used = False
  2859.                     'Subtract from the total particle count
  2860.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  2861.  
  2862.                     'Check if the effect is out of particles
  2863.  
  2864.                     If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  2865.                     'Clear the color (dont leave behind any artifacts)
  2866.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  2867.                 End If
  2868.  
  2869.             Else
  2870.                 'Set the particle information on the particle vertex
  2871.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  2872.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  2873.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  2874.             End If
  2875.         End If
  2876.  
  2877.     Next LoopC
  2878.  
  2879. End Sub
  2880.  
  2881. Function Effect_CherryBlossom_Begin(ByVal X As Single, _
  2882.                                     ByVal Y As Single, _
  2883.                                     ByVal Gfx As Integer, _
  2884.                                     ByVal Particles As Integer) As Integer
  2885.  
  2886.     '*****************************************************************
  2887.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Waterfall_Begin
  2888.    '*****************************************************************
  2889.  
  2890.     Dim EffectIndex As Integer
  2891.     Dim LoopC As Long
  2892.  
  2893.     'Get the next open effect slot
  2894.    EffectIndex = Effect_NextOpenSlot
  2895.  
  2896.     If EffectIndex = -1 Then Exit Function
  2897.     'Return the index of the used slot
  2898.    Effect_CherryBlossom_Begin = EffectIndex
  2899.     'Set the effect's variables
  2900.    effect(EffectIndex).EffectNum = EffectNum_CherryBlossom        'Set the effect number
  2901.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  2902.    effect(EffectIndex).Used = True        'Enabled the effect
  2903.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  2904.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  2905.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  2906.    'Set the number of particles left to the total avaliable
  2907.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  2908.     'Set the float variables
  2909.    effect(EffectIndex).FloatSize = Effect_FToDW(20)        'Size of the particles
  2910.    'Redim the number of particles
  2911.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  2912.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  2913.  
  2914.     'Create the particles
  2915.  
  2916.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  2917.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  2918.         effect(EffectIndex).Particles(LoopC).Used = True
  2919.        
  2920.         Effect_CherryBlossom_Reset EffectIndex, LoopC
  2921.  
  2922.     Next LoopC
  2923.  
  2924.     'Set The Initial Time
  2925.    effect(EffectIndex).PreviousFrame = GetTickCount
  2926. End Function
  2927.  
  2928. Private Sub Effect_CherryBlossom_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  2929.  
  2930.     '*****************************************************************
  2931.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Waterfall_Reset
  2932.    '*****************************************************************
  2933.  
  2934.     If Int(Rnd * 10) = 1 Then
  2935.         effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + (Rnd * 60), effect(EffectIndex).Y + (Rnd * 130), 2 + (Rnd * 2), 2 + (Rnd * 2), 0, 0
  2936.     Else
  2937.         effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + (Rnd * 60), effect(EffectIndex).Y + (Rnd * 10), 2 + (Rnd * 2), 2 + (Rnd * 2), 0, 0
  2938.     End If
  2939.  
  2940.     effect(EffectIndex).Particles(Index).ResetColor 1#, 0.7, 0.75, 0.6 + (Rnd * 0.4), 0
  2941. End Sub
  2942.  
  2943. Private Sub Effect_CherryBlossom_Update(ByVal EffectIndex As Integer)
  2944.  
  2945.     '*****************************************************************
  2946.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Waterfall_Update
  2947.    '*****************************************************************
  2948.  
  2949.     Dim ElapsedTime As Single
  2950.     Dim LoopC As Long
  2951.  
  2952.     'Calculate The Time Difference
  2953.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  2954.     effect(EffectIndex).PreviousFrame = GetTickCount
  2955.  
  2956.     'Update the life span
  2957.  
  2958.     If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  2959.  
  2960.     'Go through the particle loop
  2961.  
  2962.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  2963.  
  2964.         With effect(EffectIndex).Particles(LoopC)
  2965.  
  2966.             'Check if the particle is in use
  2967.  
  2968.             If .Used Then
  2969.                 'Update The Particle
  2970.                .UpdateParticle ElapsedTime
  2971.  
  2972.                 'Check if the particle is ready to die
  2973.  
  2974.                 If (.sngY > effect(EffectIndex).Y + 140) Or (.SngA = 0) Then
  2975.                     'Reset the particle
  2976.                    Effect_CherryBlossom_Reset EffectIndex, LoopC
  2977.                 Else
  2978.                     'Set the particle information on the particle vertex
  2979.                    effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(.SngR, .SngG, .SngB, .SngA)
  2980.                     effect(EffectIndex).PartVertex(LoopC).X = .sngX
  2981.                     effect(EffectIndex).PartVertex(LoopC).Y = .sngY
  2982.                 End If
  2983.             End If
  2984.  
  2985.         End With
  2986.  
  2987.     Next LoopC
  2988.  
  2989. End Sub
  2990.  
  2991. Function Effect_Spawn_Begin(ByVal EffectNum As Byte, _
  2992.                             ByVal X As Single, _
  2993.                             ByVal Y As Single, _
  2994.                             ByVal Gfx As Integer, _
  2995.                             ByVal Particles As Integer, _
  2996.                             Optional ByVal size As Byte = 30, _
  2997.                             Optional ByVal Time As Single = 10, _
  2998.                             Optional ByVal Red As Single = -1, _
  2999.                             Optional ByVal Green As Single = -1, _
  3000.                             Optional ByVal Blue As Single = -1, _
  3001.                             Optional ByVal Alpha As Single = -1) As Integer
  3002.  
  3003.     Dim EffectIndex As Integer
  3004.     Dim LoopC As Long
  3005.  
  3006.     'Get the next open effect slot
  3007.    EffectIndex = Effect_NextOpenSlot
  3008.  
  3009.     If EffectIndex = -1 Then Exit Function
  3010.     'Return the index of the used slot
  3011.    Effect_Spawn_Begin = EffectIndex
  3012.     'Set The Effect's Variables
  3013.    effect(EffectIndex).EffectNum = EffectNum        'Set the effect number
  3014.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  3015.    effect(EffectIndex).Used = True        'Enabled the effect
  3016.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  3017.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  3018.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  3019.    effect(EffectIndex).Modifier = size        'How large the circle is
  3020.    effect(EffectIndex).Progression = Time        'How long the effect will last
  3021.    'Set the number of particles left to the total avaliable
  3022.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  3023.     'Set the float variables
  3024.    effect(EffectIndex).FloatSize = Effect_FToDW(20)        'Size of the particles
  3025.    'Redim the number of particles
  3026.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  3027.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  3028.  
  3029.     'Create the particles
  3030.  
  3031.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  3032.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  3033.         effect(EffectIndex).Particles(LoopC).Used = True
  3034.        
  3035.         Effect_Spawn_Reset EffectNum, EffectIndex, LoopC, Red, Green, Blue, Alpha
  3036.  
  3037.     Next LoopC
  3038.  
  3039.     'Set The Initial Time
  3040.    effect(EffectIndex).PreviousFrame = GetTickCount
  3041. End Function
  3042.  
  3043. Private Sub Effect_Spawn_Reset(ByVal EffectNum As Byte, _
  3044.                                ByVal EffectIndex As Integer, _
  3045.                                ByVal Index As Long, _
  3046.                                Optional ByVal Red As Single = -1, _
  3047.                                Optional ByVal Green As Single = -1, _
  3048.                                Optional ByVal Blue As Single = -1, _
  3049.                                Optional ByVal Alpha As Single = -1)
  3050.  
  3051.     Dim X As Single
  3052.     Dim Y As Single
  3053.     Dim R As Single
  3054.  
  3055.     'Determine if deafults are used
  3056.  
  3057.     If Red = -2 Then Red = Rnd
  3058.     If Green = -2 Then Green = Rnd
  3059.     If Blue = -2 Then Blue = Rnd
  3060.     If Alpha = -2 Then Alpha = Rnd
  3061.     'store
  3062.    effect(EffectIndex).Particles(Index).Red = Red
  3063.     effect(EffectIndex).Particles(Index).Green = Green
  3064.     effect(EffectIndex).Particles(Index).Blue = Blue
  3065.     effect(EffectIndex).Particles(Index).Alpha = Alpha
  3066.  
  3067.     Select Case EffectNum
  3068.  
  3069.         Case EffectNum_HouseTeleport
  3070.             R = Sin(20 / (Index + 1)) * 100
  3071.             X = R * Cos((Index))
  3072.             Y = R * Sin((Index))
  3073.             'Reset the particle
  3074.            effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + X, effect(EffectIndex).Y + Y, 0, 0, 0, 0
  3075.  
  3076.             'Determine if deafults are used
  3077.  
  3078.             If Red = -1 Then Red = Rnd
  3079.             If Green = -1 Then Green = Rnd
  3080.             If Blue = -1 Then Blue = 1
  3081.             If Alpha = -1 Then Alpha = Rnd
  3082.             effect(EffectIndex).Particles(Index).ResetColor Red, Green, Blue, Alpha, 0.2 + (Rnd * 0.5)
  3083.  
  3084.         Case EffectNum_GuildTeleport
  3085.             R = 150 + Cos(Index * Rnd) * Sin(Index * Rnd)
  3086.             X = R * Cos(Index) * Rnd
  3087.             Y = R * Sin(Index) * Rnd
  3088.  
  3089.             'Determine if deafults are used
  3090.  
  3091.             If Red = -1 Then Red = Rnd
  3092.             If Green = -1 Then Green = Rnd
  3093.             If Blue = -1 Then Blue = 0.5
  3094.             If Alpha = -1 Then Alpha = Rnd
  3095.             'Reset the particle
  3096.            effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + X, effect(EffectIndex).Y + Y, 0, 0, 0, 0
  3097.             effect(EffectIndex).Particles(Index).ResetColor Red, Green, Blue, Alpha, 0.2 + (Rnd * 0.2)
  3098.  
  3099.         Case EffectNum_LevelUP
  3100.             R = 10 + Sin(2 * (Index / 10)) * 50 + (30 * Rnd)
  3101.             X = R * Cos(Index / 30)
  3102.             Y = R * Sin(Index / 30)
  3103.  
  3104.             'Determine if deafults are used
  3105.  
  3106.             If Red = -1 Then Red = 1
  3107.             If Green = -1 Then Green = 0.3 + Rnd / 2
  3108.             If Blue = -1 Then Blue = Rnd / 3
  3109.             If Alpha = -1 Then Alpha = Rnd / 2
  3110.             'Reset the particle
  3111.            effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + X, effect(EffectIndex).Y + Y, 0, 0, 0, 0
  3112.             effect(EffectIndex).Particles(Index).ResetColor Red, Green, Blue, Alpha, 0.005 + (Rnd * 0.2)
  3113.  
  3114.         Case EffectNum_AnimatedSign
  3115.  
  3116.             If Index = 0 Then effect(EffectIndex).Modifier = effect(EffectIndex).Modifier + 1
  3117.             effect(EffectIndex).Progression = effect(EffectIndex).Progression + effect(EffectIndex).Direction
  3118.  
  3119.             If effect(EffectIndex).Progression > 100 Then effect(EffectIndex).Direction = -0.02
  3120.             If effect(EffectIndex).Progression < -100 Then effect(EffectIndex).Direction = 0.02
  3121.             R = effect(EffectIndex).Progression + 2 * Cos(2 * Index) * 40
  3122.             X = R * Cos(Index / (effect(EffectIndex).Modifier + 1) * 5)
  3123.             Y = R * Sin(Index / (effect(EffectIndex).Modifier + 1) * 5)
  3124.  
  3125.             'Determine if deafults are used
  3126.  
  3127.             If Red = -1 Then Red = 1
  3128.             If Green = -1 Then Green = 1
  3129.             If Blue = -1 Then Blue = 1
  3130.             If Alpha = -1 Then Alpha = 1
  3131.             'Reset the particle
  3132.            effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + X, effect(EffectIndex).Y + Y, 0, 0, 0, 0
  3133.             effect(EffectIndex).Particles(Index).ResetColor Red, Green, Blue, Alpha, 0.2 + (Rnd * 0.2)
  3134.  
  3135.         Case EffectNum_Galaxy
  3136.             R = Sin(20 / (Index + 1)) * 100
  3137.             X = R * Cos((Index))
  3138.             Y = R * Sin((Index))
  3139.  
  3140.             'Determine if deafults are used
  3141.  
  3142.             If Red = -1 Then Red = 1
  3143.             If Green = -1 Then Green = 1
  3144.             If Blue = -1 Then Blue = 1
  3145.             If Alpha = -1 Then Alpha = 1
  3146.             'Reset the particle
  3147.            effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + X, effect(EffectIndex).Y + Y, 0, 0, 0, 0
  3148.             effect(EffectIndex).Particles(Index).ResetColor Red, Green, Blue, Alpha, 0.2 + (Rnd * 0.2)
  3149.  
  3150.         Case EffectNum_FancyThickCircle
  3151.             R = 50 + Rnd * 15 * Cos(2 * Index)
  3152.             X = R * Cos(Index / 30)
  3153.             Y = R * Sin(Index / 30)
  3154.  
  3155.             'Determine if deafults are used
  3156.  
  3157.             If Red = -1 Then Red = 1
  3158.             If Green = -1 Then Green = 1
  3159.             If Blue = -1 Then Blue = 1
  3160.             If Alpha = -1 Then Alpha = 1
  3161.             'Reset the particle
  3162.            effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + X, effect(EffectIndex).Y + Y, 0, 0, 0, 0
  3163.             effect(EffectIndex).Particles(Index).ResetColor Red, Green, Blue, Alpha, 0.2 + (Rnd * 0.2)
  3164.  
  3165.         Case EffectNum_Flower
  3166.             R = Cos(2 * (Index / 10)) * 50
  3167.             X = R * Cos(Index / 10)
  3168.             Y = R * Sin(Index / 10)
  3169.  
  3170.             'Determine if deafults are used
  3171.  
  3172.             If Red = -1 Then Red = 1
  3173.             If Green = -1 Then Green = 1
  3174.             If Blue = -1 Then Blue = 1
  3175.             If Alpha = -1 Then Alpha = 1
  3176.             'Reset the particle
  3177.            effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + X, effect(EffectIndex).Y + Y, 0, 0, 0, 0
  3178.             effect(EffectIndex).Particles(Index).ResetColor Red, Green, Blue, Alpha, 0.2 + (Rnd * 0.2)
  3179.  
  3180.         Case EffectNum_Wormhole
  3181.             effect(EffectIndex).Progression = effect(EffectIndex).Progression + 0.1
  3182.             R = (Index / 20) * Exp(Index / effect(EffectIndex).Progression Mod 3)
  3183.             X = R * Cos(Index)
  3184.             Y = R * Sin(Index)
  3185.  
  3186.             'Determine if deafults are used
  3187.  
  3188.             If Red = -1 Then Red = 1
  3189.             If Green = -1 Then Green = 1
  3190.             If Blue = -1 Then Blue = 1
  3191.             If Alpha = -1 Then Alpha = 1
  3192.             'Reset the particle
  3193.            effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + X, effect(EffectIndex).Y + Y, 0, 0, 0, 0
  3194.             effect(EffectIndex).Particles(Index).ResetColor Red, Green, Blue, Alpha, 0.2 + (Rnd * 0.2)
  3195.     End Select
  3196.  
  3197. End Sub
  3198.  
  3199. Private Sub Effect_Spawn_Update(ByVal EffectNum As Byte, ByVal EffectIndex As Integer)
  3200.  
  3201.     Dim ElapsedTime As Single
  3202.     Dim LoopC As Long
  3203.  
  3204.     'Calculate The Time Difference
  3205.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  3206.     effect(EffectIndex).PreviousFrame = GetTickCount
  3207.  
  3208.     'Update the life span
  3209.  
  3210.     If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  3211.  
  3212.     'Go Through The Particle Loop
  3213.  
  3214.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  3215.  
  3216.         'Check If Particle Is In Use
  3217.  
  3218.         If effect(EffectIndex).Particles(LoopC).Used Then
  3219.             'Update The Particle
  3220.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  3221.  
  3222.             'Check if the particle is ready to die
  3223.  
  3224.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  3225.  
  3226.                 'Check if the effect is ending
  3227.  
  3228.                 If effect(EffectIndex).Progression > 0 Then
  3229.                     'Reset the particle
  3230.                    Effect_Spawn_Reset EffectNum, EffectIndex, LoopC, effect(EffectIndex).Particles(LoopC).Red, effect(EffectIndex).Particles(LoopC).Green, effect(EffectIndex).Particles(LoopC).Blue, effect(EffectIndex).Particles(LoopC).Alpha
  3231.                 Else
  3232.                     'Disable the particle
  3233.                    effect(EffectIndex).Particles(LoopC).Used = False
  3234.                     'Subtract from the total particle count
  3235.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  3236.  
  3237.                     'Check if the effect is out of particles
  3238.  
  3239.                     If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  3240.                     'Clear the color (dont leave behind any artifacts)
  3241.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  3242.                 End If
  3243.  
  3244.             Else
  3245.                 'Set the particle information on the particle vertex
  3246.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  3247.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  3248.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  3249.             End If
  3250.         End If
  3251.  
  3252.     Next LoopC
  3253.  
  3254. End Sub
  3255.  
  3256. Public Sub Effect_Create(ByVal QuienLanza As Byte, _
  3257.                          ByVal CharIndex As Integer, _
  3258.                          ByVal Effecto As Byte)
  3259.  
  3260.     With Charlist(CharIndex)
  3261.  
  3262.         Select Case Effecto
  3263.  
  3264.             Case 1
  3265.                 .ParticleIndex = Effect_BloodSplatter_Begin(Engine_TPtoSPX(Charlist(CharIndex).Pos.X), Engine_TPtoSPY(Charlist(CharIndex).Pos.Y), 20 + Rnd * 40)
  3266.  
  3267.             Case 2
  3268.                 .ParticleIndex = Effect_Rayo_Begin(Engine_TPtoSPX(Charlist(QuienLanza).Pos.X), Engine_TPtoSPY(Charlist(QuienLanza).Pos.Y), 13, 100)
  3269.                 effect(Effecto).BindToChar = CharIndex
  3270.                 effect(Effecto).BindSpeed = 3
  3271.         End Select
  3272.  
  3273.     End With
  3274.  
  3275. End Sub
  3276.  
  3277. Function Effect_Rayo_Begin(ByVal X As Single, _
  3278.                            ByVal Y As Single, _
  3279.                            ByVal Gfx As Integer, _
  3280.                            ByVal Particles As Integer, _
  3281.                            Optional ByVal Progression As Single = 1) As Integer
  3282.  
  3283.     '*****************************************************************
  3284.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Rayo_Begin
  3285.    '*****************************************************************
  3286.  
  3287.     Dim EffectIndex As Integer
  3288.     Dim LoopC As Long
  3289.  
  3290.     'Get the next open effect slot
  3291.    EffectIndex = Effect_NextOpenSlot
  3292.  
  3293.     If EffectIndex = -1 Then Exit Function
  3294.     'Return the index of the used slot
  3295.    Effect_Rayo_Begin = EffectIndex
  3296.     'Set The Effect's Variables
  3297.    effect(EffectIndex).EffectNum = EffectNum_Rayo        'Set the effect number
  3298.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  3299.    effect(EffectIndex).Used = True        'Enabled the effect
  3300.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  3301.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  3302.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  3303.    effect(EffectIndex).Progression = Progression        'Loop the effect
  3304.    effect(EffectIndex).KillWhenAtTarget = True        'End the effect when it reaches the target (progression = 0)
  3305.    effect(EffectIndex).KillWhenTargetLost = True        'End the effect if the target is lost (progression = 0)
  3306.    'Set the number of particles left to the total avaliable
  3307.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  3308.     'Set the float variables
  3309.    effect(EffectIndex).FloatSize = Effect_FToDW(16)        'Size of the particles
  3310.    'Redim the number of particles
  3311.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  3312.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  3313.  
  3314.     'Create the particles
  3315.  
  3316.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  3317.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  3318.         effect(EffectIndex).Particles(LoopC).Used = True
  3319.        
  3320.         Effect_Rayo_Reset EffectIndex, LoopC
  3321.  
  3322.     Next LoopC
  3323.  
  3324.     'Set The Initial Time
  3325.    effect(EffectIndex).PreviousFrame = GetTickCount
  3326. End Function
  3327.  
  3328. Private Sub Effect_Rayo_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  3329.     '*****************************************************************
  3330.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Rayo_Reset
  3331.    '*****************************************************************
  3332.    'Reset the particle
  3333.    effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X - 10 + Rnd * 20, effect(EffectIndex).Y - 10 + Rnd * 20, -Sin((180 + (Rnd * 90) - 45) * 0.0174533) * 8 + (Rnd * 3), Cos((180 + (Rnd * 90) - 45) * 0.0174533) * 8 + (Rnd * 3), 0, 0
  3334.     'Effect(EffectIndex).Particles(Index).ResetColor 0, 0.8, 0.8, 0.6 + (Rnd * 0.2), 0.001 + (Rnd * 0.5)
  3335.    effect(EffectIndex).Particles(Index).ResetColor (Rnd * 0.8), (Rnd * 0.8), (Rnd * 0.8), 0.6 + (Rnd * 0.2), 0.001 + (Rnd * 0.5)
  3336. End Sub
  3337.  
  3338. Private Sub Effect_Rayo_Update(ByVal EffectIndex As Integer)
  3339.  
  3340.     '*****************************************************************
  3341.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Rayo_Update
  3342.    '*****************************************************************
  3343.  
  3344.     Dim ElapsedTime As Single
  3345.     Dim LoopC As Long
  3346.  
  3347.     'Calculate the time difference
  3348.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  3349.     effect(EffectIndex).PreviousFrame = GetTickCount
  3350.  
  3351.     'Go through the particle loop
  3352.  
  3353.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  3354.  
  3355.         'Check If Particle Is In Use
  3356.  
  3357.         If effect(EffectIndex).Particles(LoopC).Used Then
  3358.             'Update The Particle
  3359.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  3360.  
  3361.             'Check if the particle is ready to die
  3362.  
  3363.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  3364.  
  3365.                 'Check if the effect is ending
  3366.  
  3367.                 If effect(EffectIndex).Progression <> 0 Then
  3368.                     'Reset the particle
  3369.                    Effect_Rayo_Reset EffectIndex, LoopC
  3370.                 Else
  3371.                     'Disable the particle
  3372.                    effect(EffectIndex).Particles(LoopC).Used = False
  3373.                     'Subtract from the total particle count
  3374.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  3375.  
  3376.                     'Check if the effect is out of particles
  3377.  
  3378.                     If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  3379.                     'Clear the color (dont leave behind any artifacts)
  3380.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  3381.                 End If
  3382.  
  3383.             Else
  3384.                 'Set the particle information on the particle vertex
  3385.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  3386.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  3387.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  3388.             End If
  3389.         End If
  3390.  
  3391.     Next LoopC
  3392.  
  3393. End Sub
  3394.  
  3395. Function Effect_LissajousMedit_Begin(ByVal X As Single, _
  3396.                                      ByVal Y As Single, _
  3397.                                      ByVal Gfx As Integer, _
  3398.                                      ByVal Particles As Integer, _
  3399.                                      Optional ByVal Progression As Single = 0, _
  3400.                                      Optional size As Byte = 30, _
  3401.                                      Optional R As Single = 100, _
  3402.                                      Optional g As Single = 100, _
  3403.                                      Optional b As Single = 100, _
  3404.                                      Optional ByVal EcuationCount As Byte = 1) As Long
  3405.  
  3406.     '*****************************************************************
  3407.    'Particle effect Lissajous equation
  3408.    '*****************************************************************
  3409.  
  3410.     Dim EffectIndex As Integer
  3411.     Dim LoopC As Long
  3412.  
  3413.     'Get the next open effect slot
  3414.    EffectIndex = Effect_NextOpenSlot
  3415.  
  3416.     If EffectIndex = -1 Then Exit Function
  3417.     'Return the index of the used slot
  3418.    Effect_LissajousMedit_Begin = EffectIndex
  3419.     'Set The Effect's Variables
  3420.    effect(EffectIndex).EffectNum = EffectNum_LissajousMedit        'Set the effect number
  3421.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  3422.    effect(EffectIndex).Used = True        'Enable the effect
  3423.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  3424.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  3425.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  3426.    effect(EffectIndex).Modifier = size        'How large the circle is
  3427.    effect(EffectIndex).Progression = Progression
  3428.     effect(EffectIndex).R = R
  3429.     effect(EffectIndex).g = g
  3430.     effect(EffectIndex).b = b
  3431.     effect(EffectIndex).EcuationCount = EcuationCount
  3432.     'Set the number of particles left to the total avaliable
  3433.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  3434.     'Set the float variables
  3435.    effect(EffectIndex).FloatSize = Effect_FToDW(8)        'Size of the particles
  3436.    'Redim the number of particles
  3437.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  3438.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  3439.  
  3440.     'Create the particles
  3441.  
  3442.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  3443.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  3444.         effect(EffectIndex).Particles(LoopC).Used = True
  3445.        
  3446.         Effect_LissajousMedit_Reset EffectIndex, LoopC
  3447.  
  3448.     Next LoopC
  3449.  
  3450.     'Set The Initial Time
  3451.    effect(EffectIndex).PreviousFrame = GetTickCount
  3452. End Function
  3453.  
  3454. Private Sub Effect_LissajousMedit_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  3455.  
  3456.     '*****************************************************************
  3457.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Reset
  3458.    '*****************************************************************
  3459.  
  3460.     Dim X As Single
  3461.     Dim Y As Single
  3462.     Dim a As Single
  3463.  
  3464.     '2
  3465.    '1
  3466.    '1
  3467.    '2
  3468.    effect(EffectIndex).Progression = effect(EffectIndex).Progression + 0.01
  3469.     a = effect(EffectIndex).Progression
  3470.  
  3471.     With effect(EffectIndex)
  3472.  
  3473.         If .EcuationCount = 1 Then
  3474.             X = effect(EffectIndex).X - (Sin(1 * a + 1) * effect(EffectIndex).Modifier) - 20
  3475.             Y = effect(EffectIndex).Y + (Sin(1 * a) * effect(EffectIndex).Modifier)
  3476.             'Reset the particle
  3477.            effect(EffectIndex).Particles(Index).ResetIt X, Y, 0, 0, 0, 0
  3478.             effect(EffectIndex).Particles(Index).ResetColor effect(EffectIndex).R * effect(EffectIndex).Progression, effect(EffectIndex).g * effect(EffectIndex).Progression, effect(EffectIndex).b, 0.2, 0.2 + (Rnd * 0.2)
  3479.         ElseIf .EcuationCount = 2 Then
  3480.  
  3481.             If RandomNumber(1, 2) = 1 Then
  3482.                 X = effect(EffectIndex).X - (Sin(1 * a + 1) * effect(EffectIndex).Modifier) - 20
  3483.                 Y = effect(EffectIndex).Y + (Sin(1 * a) * effect(EffectIndex).Modifier)
  3484.                 'Reset the particle
  3485.                effect(EffectIndex).Particles(Index).ResetIt X, Y, 0, 0, 0, 0
  3486.                 effect(EffectIndex).Particles(Index).ResetColor effect(EffectIndex).R * effect(EffectIndex).Progression, effect(EffectIndex).g * effect(EffectIndex).Progression, effect(EffectIndex).b, 0.2, 0.2 + (Rnd * 0.2)
  3487.             Else
  3488.                 X = .X - (Sin(1 * a) * .Modifier) - 20
  3489.                 Y = .Y + (Sin(1 * a) * .Modifier)
  3490.                 'Reset the particle
  3491.                .Particles(Index).ResetIt X, Y, 0, 0, 0, 0
  3492.                 .Particles(Index).ResetColor .R * .Progression, .g * .Progression, .b, 0.2, 0.2 + (Rnd * 0.2)
  3493.             End If
  3494.  
  3495.         ElseIf .EcuationCount = 3 Then
  3496.  
  3497.             If RandomNumber(1, 2) = 1 Then
  3498.                 X = .X - (Sin(2 * a) * .Modifier) - 20
  3499.                 Y = .Y + (Sin(1 * a) * .Modifier)
  3500.                 'Reset the particle
  3501.                .Particles(Index).ResetIt X, Y, 0, 0, 0, 0
  3502.                 .Particles(Index).ResetColor .R * .Progression, .g * .Progression, .b, 0.2, 0.2 + (Rnd * 0.2)
  3503.             Else
  3504.                 X = .X - (Sin(1 * a) * .Modifier) - 20
  3505.                 Y = .Y + (Sin(2 * a) * .Modifier)
  3506.                 'Reset the particle
  3507.                .Particles(Index).ResetIt X, Y, 0, 0, 0, 0
  3508.                 .Particles(Index).ResetColor .R * .Progression, .g * .Progression, .b, 0.2, 0.2 + (Rnd * 0.2)
  3509.             End If
  3510.  
  3511.         ElseIf .EcuationCount = 4 Then
  3512.  
  3513.             If RandomNumber(1, 2) = 1 Then
  3514.                 X = .X - (Sin(4 * a) * .Modifier) - 20
  3515.                 Y = .Y + (Sin(2 * a) * .Modifier)
  3516.                 'Reset the particle
  3517.                .Particles(Index).ResetIt X, Y, 0, 0, 0, 0
  3518.                 .Particles(Index).ResetColor .R * .Progression, .g * .Progression, .b, 0.2, 0.2 + (Rnd * 0.2)
  3519.             Else
  3520.                 X = .X - (Sin(2 * a) * .Modifier) - 20
  3521.                 Y = .Y + (Sin(4 * a) * .Modifier)
  3522.                 'Reset the particle
  3523.                .Particles(Index).ResetIt X, Y, 0, 0, 0, 0
  3524.                 .Particles(Index).ResetColor .R * .Progression, .g * .Progression, .b, 0.2, 0.2 + (Rnd * 0.2)
  3525.             End If
  3526.  
  3527.         ElseIf .EcuationCount = 5 Then
  3528.  
  3529.             If RandomNumber(1, 2) = 1 Then
  3530.                 X = .X - (Sin(2 * a) * .Modifier) - 20
  3531.                 Y = .Y + (Sin(1 * a) * .Modifier)
  3532.                 'Reset the particle
  3533.                .Particles(Index).ResetIt X, Y, 0, 0, 0, 0
  3534.                 .Particles(Index).ResetColor .R * .Progression, .g * .Progression, .b, 0.2, 0.2 + (Rnd * 0.2)
  3535.             Else
  3536.                 X = .X - (Sin(1 + 5 * a) * .Modifier) - 20
  3537.                 Y = .Y + (Sin(2 + 7 * a) * .Modifier)
  3538.                 'Reset the particle
  3539.                .Particles(Index).ResetIt X, Y, 0, 0, 0, 0
  3540.                 .Particles(Index).ResetColor .R * .Progression, .g * .Progression, .b, 0.2, 0.2 + (Rnd * 0.2)
  3541.             End If
  3542.         End If
  3543.  
  3544.     End With
  3545.  
  3546. End Sub
  3547.  
  3548. Private Sub Effect_LissajousMedit_Update(ByVal EffectIndex As Integer)
  3549.  
  3550.     '*****************************************************************
  3551.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Update
  3552.    '*****************************************************************
  3553.  
  3554.     Dim ElapsedTime As Single
  3555.     Dim LoopC As Long
  3556.  
  3557.     'Calculate The Time Difference
  3558.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  3559.     effect(EffectIndex).PreviousFrame = GetTickCount
  3560.  
  3561.     'Go Through The Particle Loop
  3562.  
  3563.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  3564.  
  3565.         'Check If Particle Is In Use
  3566.  
  3567.         If effect(EffectIndex).Particles(LoopC).Used Then
  3568.             'Update The Particle
  3569.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  3570.  
  3571.             'Check if the particle is ready to die
  3572.  
  3573.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  3574.  
  3575.                 'Check if the effect is ending
  3576.  
  3577.                 If effect(EffectIndex).Progression > 0 Then
  3578.                     'Reset the particle
  3579.                    Effect_LissajousMedit_Reset EffectIndex, LoopC
  3580.                 Else
  3581.                     'Disable the particle
  3582.                    effect(EffectIndex).Particles(LoopC).Used = False
  3583.                     'Subtract from the total particle count
  3584.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  3585.  
  3586.                     'Check if the effect is out of particles
  3587.  
  3588.                     If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  3589.                     'Clear the color (dont leave behind any artifacts)
  3590.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  3591.                 End If
  3592.  
  3593.             Else
  3594.                 'Set the particle information on the particle vertex
  3595.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  3596.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  3597.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  3598.             End If
  3599.         End If
  3600.  
  3601.     Next LoopC
  3602.  
  3603. End Sub
  3604.  
  3605. Function Effect_Inmovilizar_Begin(ByVal X As Single, _
  3606.                                   ByVal Y As Single, _
  3607.                                   ByVal Gfx As Integer, _
  3608.                                   ByVal Particles As Integer, _
  3609.                                   Optional ByVal size As Byte = 30, _
  3610.                                   Optional ByVal Time As Single = 10) As Long
  3611.  
  3612.     '*****************************************************************
  3613.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Strengthen_Begin
  3614.    '*****************************************************************
  3615.  
  3616.     Dim EffectIndex As Integer
  3617.     Dim LoopC As Long
  3618.  
  3619.     'Get the next open effect slot
  3620.    EffectIndex = Effect_NextOpenSlot
  3621.  
  3622.     If EffectIndex = -1 Then Exit Function
  3623.  
  3624.     'Return the index of the used slot
  3625.    Effect_Inmovilizar_Begin = EffectIndex
  3626.  
  3627.     'Set the effect's variables
  3628.    effect(EffectIndex).EffectNum = EffectNum_Inmovilizar        'Set the effect number
  3629.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  3630.    effect(EffectIndex).Used = True        'Enabled the effect
  3631.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  3632.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  3633.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  3634.    effect(EffectIndex).Modifier = size        'How large the circle is
  3635.    effect(EffectIndex).Progression = Time        'How long the effect will last
  3636.  
  3637.     'Set the number of particles left to the total avaliable
  3638.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  3639.  
  3640.     'Set the float variables
  3641.    effect(EffectIndex).FloatSize = Effect_FToDW(15)        'Size of the particles
  3642.  
  3643.     'Redim the number of particles
  3644.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  3645.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  3646.  
  3647.     'Create the particles
  3648.  
  3649.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  3650.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  3651.         effect(EffectIndex).Particles(LoopC).Used = True
  3652.        
  3653.         Effect_Inmovilizar_Reset EffectIndex, LoopC
  3654.  
  3655.     Next LoopC
  3656.  
  3657.     'Set The Initial Time
  3658.    effect(EffectIndex).PreviousFrame = GetTickCount
  3659. End Function
  3660.  
  3661. Private Sub Effect_Inmovilizar_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  3662.  
  3663.     '// Posiciones
  3664.  
  3665.     Dim X As Single
  3666.     Dim Y As Single
  3667.  
  3668.     'Get the positions
  3669.    X = effect(EffectIndex).X + (Rnd * 60)
  3670.     Y = effect(EffectIndex).Y + (Rnd * 60)
  3671.  
  3672.     '// Colores
  3673.    '// Reset the particle
  3674.    effect(EffectIndex).Particles(Index).ResetIt X, Y, Rnd * 1 - 0.5, Rnd * 1 - 0.5, Rnd - 0.5, Rnd * -0.9 + 0.45
  3675.     effect(EffectIndex).Particles(Index).ResetColor (Rnd * 0.8), (Rnd * 0.8), (Rnd * 0.8), 0.6 + (Rnd * 0.2), 0.07 + Rnd * 0.01
  3676. End Sub
  3677.  
  3678. Private Sub Effect_Inmovilizar_Update(ByVal EffectIndex As Integer)
  3679.  
  3680.     Dim ElapsedTime As Single
  3681.     Dim LoopC As Long
  3682.  
  3683.     'Calculate the time difference
  3684.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.1
  3685.     effect(EffectIndex).PreviousFrame = GetTickCount
  3686.  
  3687.     'Update the life span
  3688.  
  3689.     If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  3690.  
  3691.     'Go through the particle loop
  3692.  
  3693.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  3694.  
  3695.         'Check if particle is in use
  3696.  
  3697.         If effect(EffectIndex).Particles(LoopC).Used Then
  3698.             'Update the particle
  3699.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  3700.  
  3701.             'Check if the particle is ready to die
  3702.  
  3703.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  3704.  
  3705.                 'Check if the effect is ending
  3706.  
  3707.                 If effect(EffectIndex).Progression > 0 Then
  3708.                     'Reset the particle
  3709.                    Effect_Inmovilizar_Reset EffectIndex, LoopC
  3710.                 Else
  3711.                     'Disable the particle
  3712.                    effect(EffectIndex).Particles(LoopC).Used = False
  3713.  
  3714.                     'Subtract from the total particle count
  3715.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  3716.  
  3717.                     'Check if the effect is out of particles
  3718.                    If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  3719.  
  3720.                     'Clear the color (dont leave behind any artifacts)
  3721.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  3722.                 End If
  3723.  
  3724.             Else
  3725.                 'Set the particle information on the particle vertex
  3726.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  3727.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  3728.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  3729.             End If
  3730.         End If
  3731.  
  3732.     Next LoopC
  3733.  
  3734. End Sub
  3735.  
  3736. Function Effect_ChangeClass_Begin(ByVal X As Single, _
  3737.                                   ByVal Y As Single, _
  3738.                                   ByVal Gfx As Integer, _
  3739.                                   ByVal Particles As Integer, _
  3740.                                   Optional ByVal Progression As Single = 1) As Integer
  3741.  
  3742.     Dim EffectIndex As Integer
  3743.     Dim LoopC As Long
  3744.  
  3745.     'Get the next open effect slot
  3746.    EffectIndex = Effect_NextOpenSlot
  3747.  
  3748.     If EffectIndex = -1 Then Exit Function
  3749.  
  3750.     'Return the index of the used slot
  3751.    Effect_ChangeClass_Begin = EffectIndex
  3752.  
  3753.     'Set The Effect's Variables
  3754.    effect(EffectIndex).EffectNum = EffectNum_ChangeClass        'Set the effect number
  3755.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  3756.    effect(EffectIndex).Used = True        'Enable the effect
  3757.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  3758.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  3759.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  3760.    effect(EffectIndex).Progression = Progression        'If we loop the effect
  3761.  
  3762.     'Set the number of particles left to the total avaliable
  3763.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  3764.  
  3765.     'Set the float variables
  3766.    effect(EffectIndex).FloatSize = Effect_FToDW(8)        'Size of the particles
  3767.  
  3768.     'Redim the number of particles
  3769.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  3770.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  3771.  
  3772.     'Create the particles
  3773.  
  3774.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  3775.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  3776.         effect(EffectIndex).Particles(LoopC).Used = True
  3777.        
  3778.         Effect_ChangeClass_Reset EffectIndex, LoopC
  3779.  
  3780.     Next LoopC
  3781.  
  3782.     'Set The Initial Time
  3783.    effect(EffectIndex).PreviousFrame = GetTickCount
  3784.  
  3785. End Function
  3786.  
  3787. Private Sub Effect_ChangeClass_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  3788.  
  3789.     Dim X As Single
  3790.     Dim Y As Single
  3791.  
  3792.     effect(EffectIndex).Sng = effect(EffectIndex).Sng + 0.03
  3793.  
  3794.     If effect(EffectIndex).Sng > 360 * DegreeToRadian Then effect(EffectIndex).Sng = effect(EffectIndex).Sng - 360 * DegreeToRadian
  3795.     effect(EffectIndex).Modifier = effect(EffectIndex).Modifier + 1
  3796.  
  3797.     'Get the positions
  3798.    X = effect(EffectIndex).X - (Sin(effect(EffectIndex).Sng) * 40) + Rnd * 10
  3799.     Y = effect(EffectIndex).Y + (Cos(effect(EffectIndex).Sng) * 40) - (effect(EffectIndex).Modifier / 10) + Rnd * 10
  3800.  
  3801.     'Reset the particle
  3802.    effect(EffectIndex).Particles(Index).ResetIt X, Y, 0, 0, 0, 0
  3803.     effect(EffectIndex).Particles(Index).ResetColor 1, 1, 0, 1, 0.2 + (Rnd * 0.2)
  3804.  
  3805. End Sub
  3806.  
  3807. Private Sub Effect_ChangeClass_Update(ByVal EffectIndex As Integer)
  3808.  
  3809.     Dim ElapsedTime As Single
  3810.     Dim LoopC As Long
  3811.  
  3812.     'Calculate The Time Difference
  3813.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  3814.     effect(EffectIndex).PreviousFrame = GetTickCount
  3815.  
  3816.     'Update the life span
  3817.  
  3818.     If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  3819.  
  3820.     'Go Through The Particle Loop
  3821.  
  3822.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  3823.  
  3824.         'Check If Particle Is In Use
  3825.  
  3826.         If effect(EffectIndex).Particles(LoopC).Used Then
  3827.  
  3828.             'Update The Particle
  3829.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  3830.  
  3831.             'Check if the particle is ready to die
  3832.  
  3833.             If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  3834.  
  3835.                 'Check if the effect is ending
  3836.  
  3837.                 If effect(EffectIndex).Progression > 0 Then
  3838.  
  3839.                     'Reset the particle
  3840.                    Effect_ChangeClass_Reset EffectIndex, LoopC
  3841.  
  3842.                 Else
  3843.  
  3844.                     'Disable the particle
  3845.                    effect(EffectIndex).Particles(LoopC).Used = False
  3846.  
  3847.                     'Subtract from the total particle count
  3848.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  3849.  
  3850.                     'Check if the effect is out of particles
  3851.  
  3852.                     If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  3853.  
  3854.                     'Clear the color (dont leave behind any artifacts)
  3855.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  3856.  
  3857.                 End If
  3858.  
  3859.             Else
  3860.  
  3861.                 'Set the particle information on the particle vertex
  3862.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  3863.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  3864.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  3865.  
  3866.             End If
  3867.  
  3868.         End If
  3869.  
  3870.     Next LoopC
  3871.  
  3872. End Sub
  3873.  
  3874. Function Effect_Armada_Begin(ByVal X As Single, _
  3875.                              ByVal Y As Single, _
  3876.                              ByVal Gfx As Integer, _
  3877.                              ByVal Particles As Integer, _
  3878.                              Optional ByVal Progression As Single = 1) As Integer
  3879.  
  3880.     Dim EffectIndex As Integer
  3881.     Dim LoopC As Long
  3882.  
  3883.     'Get the next open effect slot
  3884.    EffectIndex = Effect_NextOpenSlot
  3885.  
  3886.     If EffectIndex = -1 Then Exit Function
  3887.  
  3888.     'Return the index of the used slot
  3889.    Effect_Armada_Begin = EffectIndex
  3890.  
  3891.     'Set The Effect's Variables
  3892.    effect(EffectIndex).EffectNum = EffectNum_Armada        'Set the effect number
  3893.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  3894.    effect(EffectIndex).Used = True        'Enable the effect
  3895.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  3896.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  3897.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  3898.    effect(EffectIndex).Progression = Progression        'If we loop the effect
  3899.  
  3900.     'Set the number of particles left to the total avaliable
  3901.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  3902.  
  3903.     'Set the float variables
  3904.    effect(EffectIndex).FloatSize = Effect_FToDW(8)        'Size of the particles
  3905.  
  3906.     'Redim the number of particles
  3907.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  3908.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  3909.  
  3910.     'Create the particles
  3911.  
  3912.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  3913.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  3914.         effect(EffectIndex).Particles(LoopC).Used = True
  3915.        
  3916.         Effect_Armada_Reset EffectIndex, LoopC
  3917.  
  3918.     Next LoopC
  3919.  
  3920.     'Set The Initial Time
  3921.    effect(EffectIndex).PreviousFrame = GetTickCount
  3922.  
  3923. End Function
  3924.  
  3925. Private Sub Effect_Armada_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  3926.  
  3927.     Dim X As Single
  3928.     Dim Y As Single
  3929.  
  3930.     Dim a As Single
  3931.     Dim b As Integer
  3932.     Dim aL As Single
  3933.     Dim rG As Single
  3934.  
  3935.     aL = 3.1415 / 2
  3936.     a = 3
  3937.     b = 4
  3938.  
  3939.     rG = (Rnd * 0.6)
  3940.  
  3941.     effect(EffectIndex).Progression = effect(EffectIndex).Progression + 0.14
  3942.  
  3943.     X = a * Sin(effect(EffectIndex).Progression * aL / 12) * 6 + (Rnd * 0.5) - 1
  3944.     Y = b * Sin(effect(EffectIndex).Progression / 12) * 6 - 10 + (Rnd * 0.5) - 10
  3945.  
  3946.     'Reset the particle
  3947.  
  3948.     If RandomNumber(1, 2) = 1 Then
  3949.         effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + X, effect(EffectIndex).Y + Y, 0, 0, 0, 0
  3950.         effect(EffectIndex).Particles(Index).ResetColor 0.1, 0.2, rG, 0.1 + (Rnd * 0.2), 0.1
  3951.     Else
  3952.         effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X - X, effect(EffectIndex).Y - Y - 50, 0, 0, 0, 0
  3953.         effect(EffectIndex).Particles(Index).ResetColor 0.1, 0.2, rG, 0.1 + (Rnd * 0.1), 0.036
  3954.     End If
  3955.  
  3956. End Sub
  3957.  
  3958. Private Sub Effect_Armada_Update(ByVal EffectIndex As Integer)
  3959.  
  3960.     Dim ElapsedTime As Single
  3961.     Dim LoopC As Long
  3962.  
  3963.     'Calculate The Time Difference
  3964.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  3965.     effect(EffectIndex).PreviousFrame = GetTickCount
  3966.  
  3967.     'Effect(EffectIndex).Progression = Effect(EffectIndex).Progression + 0.001
  3968.    'Go Through The Particle Loop
  3969.  
  3970.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  3971.  
  3972.         'Check If Particle Is In Use
  3973.  
  3974.         If effect(EffectIndex).Particles(LoopC).Used Then
  3975.  
  3976.             'Update The Particle
  3977.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  3978.  
  3979.             'Check if the particle is ready to die
  3980.  
  3981.             If effect(EffectIndex).Particles(LoopC).SngA <= 0.5 And RandomNumber(1, 4) = 1 Then
  3982.  
  3983.                 'Check if the effect is ending
  3984.  
  3985.                 If effect(EffectIndex).Progression > 1 Then
  3986.  
  3987.                     'Reset the particle
  3988.                    Effect_Armada_Reset EffectIndex, LoopC
  3989.  
  3990.                 Else
  3991.  
  3992.                     'Disable the particle
  3993.                    effect(EffectIndex).Particles(LoopC).Used = False
  3994.  
  3995.                     'Subtract from the total particle count
  3996.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  3997.  
  3998.                     'Check if the effect is out of particles
  3999.  
  4000.                     If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  4001.  
  4002.                     'Clear the color (dont leave behind any artifacts)
  4003.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  4004.  
  4005.                 End If
  4006.  
  4007.             Else
  4008.  
  4009.                 'Set the particle information on the particle vertex
  4010.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  4011.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  4012.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  4013.  
  4014.             End If
  4015.  
  4016.         End If
  4017.  
  4018.     Next LoopC
  4019.  
  4020. End Sub
  4021.  
  4022. Function Effect_Butterfly_Begin(ByVal X As Single, _
  4023.                                 ByVal Y As Single, _
  4024.                                 ByVal Gfx As Integer, _
  4025.                                 ByVal Particles As Integer, _
  4026.                                 Optional ByVal Progression As Single = 1, _
  4027.                                 Optional ByVal Aura As Byte = 0) As Integer
  4028.  
  4029.     Dim EffectIndex As Integer
  4030.     Dim LoopC As Long
  4031.  
  4032.     'Get the next open effect slot
  4033.    EffectIndex = Effect_NextOpenSlot
  4034.  
  4035.     If EffectIndex = -1 Then Exit Function
  4036.  
  4037.     'Return the index of the used slot
  4038.    Effect_Butterfly_Begin = EffectIndex
  4039.  
  4040.     'Set The Effect's Variables
  4041.    effect(EffectIndex).EffectNum = EffectNum_ButterflyCurve        'Set the effect number
  4042.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  4043.    effect(EffectIndex).Used = True        'Enable the effect
  4044.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  4045.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  4046.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  4047.    effect(EffectIndex).Progression = Progression        'If we loop the effect
  4048.  
  4049.     'Set the number of particles left to the total avaliable
  4050.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  4051.  
  4052.     'Set the float variables
  4053.    effect(EffectIndex).FloatSize = Effect_FToDW(8)        'Size of the particles
  4054.  
  4055.     'Redim the number of particles
  4056.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  4057.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  4058.  
  4059.     'Create the particles
  4060.  
  4061.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  4062.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  4063.         effect(EffectIndex).Particles(LoopC).Used = True
  4064.        
  4065.         Effect_Butterfly_Reset EffectIndex, LoopC, Aura
  4066.  
  4067.     Next LoopC
  4068.  
  4069.     'Set The Initial Time
  4070.    effect(EffectIndex).PreviousFrame = GetTickCount
  4071.  
  4072. End Function
  4073.  
  4074. Private Sub Effect_Butterfly_Reset(ByVal EffectIndex As Integer, _
  4075.                                    ByVal Index As Long, _
  4076.                                    ByVal AuraType As Byte)
  4077.  
  4078.     Dim X As Single
  4079.     Dim Y As Single
  4080.  
  4081.     If AuraType = 1 Then        'la posta del auratype es mandarle una cantidad de 300 particulas
  4082.        effect(EffectIndex).Sng = effect(EffectIndex).Sng + 0.003
  4083.     Else
  4084.         effect(EffectIndex).Sng = effect(EffectIndex).Sng + 0.03
  4085.     End If
  4086.  
  4087.     If effect(EffectIndex).Sng > 360 * DegreeToRadian Then effect(EffectIndex).Sng = effect(EffectIndex).Sng - 360 * DegreeToRadian
  4088.     effect(EffectIndex).Modifier = effect(EffectIndex).Modifier + 1
  4089.  
  4090.     'Get the positions
  4091.    'x = Effect(EffectIndex).x - (Sin(Effect(EffectIndex).Sng) * 40) + Rnd * 10
  4092.    'y = Effect(EffectIndex).y + (Cos(Effect(EffectIndex).Sng) * 40) - (Effect(EffectIndex).Modifier / 10) + Rnd * 10
  4093.  
  4094.     With effect(EffectIndex)
  4095.  
  4096.         If AuraType = 1 Then
  4097.             If RandomNumber(1, 2) = 1 Then
  4098.                 X = .X + (.X * (Sin(.Sng) * (Exp(Cos(.Sng)) - 2 * Cos(4 * .Sng) - Sin((.Sng / 12) ^ 5)))) / 5
  4099.                 Y = .Y - (.Y * (Cos(.Sng) * (Exp(Cos(.Sng)) - 2 * Cos(4 * .Sng) - Sin((.Sng / 12) ^ 5)))) / 5
  4100.             Else
  4101.                 X = .X + (.X * -(Sin(.Sng) * (Exp(Cos(.Sng)) - 2 * Cos(4 * .Sng) - Sin((.Sng / 12) ^ 5)))) / 5
  4102.                 Y = .Y - (.Y * -(Cos(.Sng) * (Exp(Cos(.Sng)) - 2 * Cos(4 * .Sng) - Sin((.Sng / 12) ^ 5)))) / 5
  4103.  
  4104.             End If
  4105.  
  4106.         Else
  4107.             X = .X + (.X * (Sin(.Sng) * (Exp(Cos(.Sng)) - 2 * Cos(4 * .Sng) - Sin((.Sng / 12) ^ 5)))) / 5
  4108.             Y = .Y - (.Y * (Cos(.Sng) * (Exp(Cos(.Sng)) - 2 * Cos(4 * .Sng) - Sin((.Sng / 12) ^ 5)))) / 5
  4109.  
  4110.         End If
  4111.  
  4112.     End With
  4113.  
  4114.     'Reset the particle
  4115.    effect(EffectIndex).Particles(Index).ResetIt X, Y, 0, 0, 0, 0
  4116.     effect(EffectIndex).Particles(Index).ResetColor 1, 1, 0, 1, 0.2 + (Rnd * 0.2)
  4117. End Sub
  4118.  
  4119. Private Sub Effect_Butterfly_Update(ByVal EffectIndex As Integer)
  4120.  
  4121.     Dim ElapsedTime As Single
  4122.     Dim LoopC As Long
  4123.  
  4124.     'Calculate The Time Difference
  4125.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  4126.     effect(EffectIndex).PreviousFrame = GetTickCount
  4127.  
  4128.     'Effect(EffectIndex).Progression = Effect(EffectIndex).Progression + 0.001
  4129.    'Go Through The Particle Loop
  4130.  
  4131.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  4132.  
  4133.         'Check If Particle Is In Use
  4134.  
  4135.         If effect(EffectIndex).Particles(LoopC).Used Then
  4136.  
  4137.             'Update The Particle
  4138.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  4139.  
  4140.             'Check if the particle is ready to die
  4141.  
  4142.             If effect(EffectIndex).Particles(LoopC).SngA <= 0.5 And RandomNumber(1, 4) = 1 Then
  4143.  
  4144.                 'Check if the effect is ending
  4145.  
  4146.                 If effect(EffectIndex).Progression > 1 Then
  4147.  
  4148.                     'Reset the particle
  4149.                    Effect_Armada_Reset EffectIndex, LoopC
  4150.  
  4151.                 Else
  4152.  
  4153.                     'Disable the particle
  4154.                    effect(EffectIndex).Particles(LoopC).Used = False
  4155.  
  4156.                     'Subtract from the total particle count
  4157.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  4158.  
  4159.                     'Check if the effect is out of particles
  4160.  
  4161.                     If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  4162.  
  4163.                     'Clear the color (dont leave behind any artifacts)
  4164.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  4165.  
  4166.                 End If
  4167.  
  4168.             Else
  4169.  
  4170.                 'Set the particle information on the particle vertex
  4171.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  4172.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  4173.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  4174.  
  4175.             End If
  4176.  
  4177.         End If
  4178.  
  4179.     Next LoopC
  4180.  
  4181. End Sub
  4182.  
  4183. Function Effect_Torment_Begin(ByVal X As Single, ByVal Y As Single, ByVal Gfx As Integer, ByVal Particles As Integer, Optional ByVal size As Byte = 30, Optional ByVal Time As Single = 10) As Integer
  4184.     '*****************************************************************
  4185.    'More info: [url=http://www.vbgore.com/CommonCode.Particles.Effect_Torment_Begin]http://www.vbgore.com/CommonCode.Partic ... ment_Begin[/url]
  4186.    '*****************************************************************
  4187.    Dim EffectIndex As Integer
  4188.     Dim LoopC As Long
  4189.  
  4190.     'Get the next open effect slot
  4191.    EffectIndex = Effect_NextOpenSlot
  4192.     If EffectIndex = -1 Then Exit Function
  4193.  
  4194.     'Return the index of the used slot
  4195.    Effect_Torment_Begin = EffectIndex
  4196.  
  4197.     'Set The Effect's Variables
  4198.    effect(EffectIndex).EffectNum = EffectNum_Torment        'Set the effect number
  4199.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  4200.    effect(EffectIndex).Used = True        'Enabled the effect
  4201.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  4202.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  4203.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  4204.    effect(EffectIndex).Modifier = size        'How large the circle is
  4205.    effect(EffectIndex).Progression = Time        'How long the effect will last
  4206.  
  4207.     'Set the number of particles left to the total avaliable
  4208.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  4209.  
  4210.     'Set the float variables
  4211.    effect(EffectIndex).FloatSize = Effect_FToDW(20)        'Size of the particles
  4212.  
  4213.     'Redim the number of particles
  4214.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  4215.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  4216.  
  4217.     'Create the particles
  4218.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  4219.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  4220.         effect(EffectIndex).Particles(LoopC).Used = True
  4221.        
  4222.         Effect_Torment_Reset EffectIndex, LoopC
  4223.     Next LoopC
  4224.  
  4225.     'Set The Initial Time
  4226.    effect(EffectIndex).PreviousFrame = GetTickCount
  4227.  
  4228. End Function
  4229.  
  4230. Private Sub Effect_Torment_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  4231.     '*****************************************************************
  4232.    'More info: [url=http://www.vbgore.com/CommonCode.Particles.Effect_Torment_Reset]http://www.vbgore.com/CommonCode.Partic ... ment_Reset[/url]
  4233.    '*****************************************************************
  4234.    Dim R As Single
  4235.     Dim X As Single
  4236.     Dim Y As Single
  4237.  
  4238.     R = (Index / 21) * Exp(Index * effect(EffectIndex).Progression Mod 2)
  4239.     X = R * Cos(Index)
  4240.     Y = R * Sin(Index)
  4241.  
  4242.     'Reset the particle
  4243.    effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + X, effect(EffectIndex).Y + Y, Rnd * -1, 0, 0, 0
  4244.     effect(EffectIndex).Particles(Index).ResetColor 1, 200, 0, 1, 0.2 + 0.01
  4245.  
  4246. End Sub
  4247.  
  4248. Private Sub Effect_Torment_Update(ByVal EffectIndex As Integer)
  4249.     '*****************************************************************
  4250.    'More info: [url=http://www.vbgore.com/CommonCode.Particles.Effect_Torment_Update]http://www.vbgore.com/CommonCode.Partic ... ent_Update[/url]
  4251.    '*****************************************************************
  4252.    Dim ElapsedTime As Single
  4253.     Dim LoopC As Long
  4254.  
  4255.     'Calculate The Time Difference
  4256.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.1
  4257.     effect(EffectIndex).PreviousFrame = GetTickCount
  4258.  
  4259.     'Update the life span
  4260.    If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime + 0.001
  4261.  
  4262.     'Go Through The Particle Loop
  4263.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  4264.  
  4265.         'Check If Particle Is In Use
  4266.        If effect(EffectIndex).Particles(LoopC).Used Then
  4267.  
  4268.             'Update The Particle
  4269.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  4270.  
  4271.             'Check if the particle is ready to die
  4272.            If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  4273.  
  4274.                 'Check if the effect is ending
  4275.                If effect(EffectIndex).Progression > 0 Then
  4276.  
  4277.                     'Reset the particle
  4278.                    Effect_Torment_Reset EffectIndex, LoopC
  4279.  
  4280.                 Else
  4281.  
  4282.                     'Disable the particle
  4283.                    effect(EffectIndex).Particles(LoopC).Used = False
  4284.  
  4285.                     'Subtract from the total particle count
  4286.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  4287.  
  4288.                     'Check if the effect is out of particles
  4289.                    If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  4290.  
  4291.                     'Clear the color (dont leave behind any artifacts)
  4292.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  4293.  
  4294.                 End If
  4295.  
  4296.             Else
  4297.  
  4298.                 'Set the particle information on the particle vertex
  4299.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  4300.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  4301.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  4302.  
  4303.             End If
  4304.  
  4305.         End If
  4306.  
  4307.     Next LoopC
  4308.  
  4309. End Sub
  4310.  
  4311. Function Effect_Green_Begin(ByVal X As Single, ByVal Y As Single, ByVal Gfx As Integer, ByVal Particles As Integer, Optional ByVal Progression As Single = 1) As Integer
  4312.     '*****************************************************************
  4313.    'Particle effect template for effects as described on the
  4314.    'wiki page: http://www.vbgore.com/Particle_effect_equations
  4315.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Begin
  4316.    '*****************************************************************
  4317.    Dim EffectIndex As Integer
  4318.     Dim LoopC As Long
  4319.  
  4320.     'Get the next open effect slot
  4321.    EffectIndex = Effect_NextOpenSlot
  4322.     If EffectIndex = -1 Then Exit Function
  4323.  
  4324.     'Return the index of the used slot
  4325.    Effect_Green_Begin = EffectIndex
  4326.  
  4327.     'Set The Effect's Variables
  4328.    effect(EffectIndex).EffectNum = EffectNum_Green        'Set the effect number
  4329.    effect(EffectIndex).ParticleCount = Particles - Particles * 0.25
  4330.     effect(EffectIndex).Used = True        'Enable the effect
  4331.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  4332.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  4333.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  4334.    effect(EffectIndex).Progression = Progression        'If we loop the effect
  4335.  
  4336.     'Set the number of particles left to the total avaliable
  4337.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  4338.  
  4339.     'Set the float variables
  4340.    effect(EffectIndex).FloatSize = Effect_FToDW(16)        'Size of the particles
  4341.  
  4342.     'Redim the number of particles
  4343.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  4344.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  4345.  
  4346.     'Create the particles
  4347.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  4348.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  4349.         effect(EffectIndex).Particles(LoopC).Used = True
  4350.        
  4351.         Effect_Green_Reset EffectIndex, LoopC
  4352.     Next LoopC
  4353.  
  4354.     'Set The Initial Time
  4355.    effect(EffectIndex).PreviousFrame = GetTickCount
  4356.  
  4357. End Function
  4358.  
  4359. Private Sub Effect_Green_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  4360.     '*****************************************************************
  4361.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Reset
  4362.    '*****************************************************************
  4363.    Dim X As Single
  4364.     Dim Y As Single
  4365.     Dim R As Single
  4366.     Dim rG As Single
  4367.  
  4368.     rG = (Rnd * 0.5)
  4369.  
  4370.     effect(EffectIndex).Progression = effect(EffectIndex).Progression + 0.1
  4371.     R = (Index / 250) * ((effect(EffectIndex).Progression / 10) ^ 2)
  4372.     X = R * Round(Cos(Index), 0) + (Index * Rnd * 0.07) * Sgn(Cos(Index))
  4373.     Y = R * Round(Sin(Index), 0) + (Index * Rnd * 0.07) * Sgn(Sin(Index))
  4374.  
  4375.     'Reset the particle
  4376.    effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + X, effect(EffectIndex).Y + Y, 0, 0, 0, 0
  4377.     If RandomNumber(1, 2) = 1 Then
  4378.         effect(EffectIndex).Particles(Index).ResetColor 1, 0.2 + rG, 0.2, 0.9, 0.2 + (Rnd * 0.2)
  4379.     Else
  4380.         effect(EffectIndex).Particles(Index).ResetColor 0.2, 0.2 + rG, 1, 0.9, 0.2 + (Rnd * 0.2)
  4381.     End If
  4382.  
  4383.  
  4384. End Sub
  4385.  
  4386. Private Sub Effect_Green_Update(ByVal EffectIndex As Integer)
  4387.     '*****************************************************************
  4388.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Update
  4389.    '*****************************************************************
  4390.    Dim ElapsedTime As Single
  4391.     Dim LoopC As Long
  4392.  
  4393.     'Calculate The Time Difference
  4394.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  4395.     effect(EffectIndex).PreviousFrame = GetTickCount
  4396.  
  4397.  
  4398.  
  4399.     'Go Through The Particle Loop
  4400.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  4401.  
  4402.         'Check If Particle Is In Use
  4403.        If effect(EffectIndex).Particles(LoopC).Used Then
  4404.  
  4405.             'Update The Particle
  4406.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  4407.  
  4408.             'Check if the particle is ready to die
  4409.            If effect(EffectIndex).Particles(LoopC).SngA <= 0.2 Then
  4410.  
  4411.                 'Check if the effect is ending
  4412.                If effect(EffectIndex).Progression < 80 Then
  4413.  
  4414.                     'Reset the particle
  4415.                    Effect_Green_Reset EffectIndex, LoopC
  4416.  
  4417.                 Else
  4418.  
  4419.                     'Disable the particle
  4420.                    effect(EffectIndex).Particles(LoopC).Used = False
  4421.  
  4422.                     'Subtract from the total particle count
  4423.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  4424.  
  4425.                     'Check if the effect is out of particles
  4426.                    If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  4427.  
  4428.                     'Clear the color (dont leave behind any artifacts)
  4429.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  4430.  
  4431.                 End If
  4432.  
  4433.             Else
  4434.  
  4435.                 'Set the particle information on the particle vertex
  4436.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  4437.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  4438.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  4439.  
  4440.             End If
  4441.  
  4442.         End If
  4443.  
  4444.     Next LoopC
  4445.  
  4446. End Sub
  4447.  
  4448. Function Effect_Curse_Begin(ByVal X As Single, ByVal Y As Single, ByVal Gfx As Integer, ByVal Particles As Integer, Optional ByVal Direction As Integer = 180, Optional ByVal Progression As Single = 1) As Integer
  4449.     '*****************************************************************
  4450.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Begin
  4451.    '*****************************************************************
  4452.    Dim EffectIndex As Integer
  4453.     Dim LoopC As Long
  4454.  
  4455.     'Get the next open effect slot
  4456.    EffectIndex = Effect_NextOpenSlot
  4457.     If EffectIndex = -1 Then Exit Function
  4458.  
  4459.     'Return the index of the used slot
  4460.    Effect_Curse_Begin = EffectIndex
  4461.  
  4462.     'Set The Effect's Variables
  4463.    effect(EffectIndex).EffectNum = EffectNum_Curse        'Set the effect number
  4464.    effect(EffectIndex).ParticleCount = Particles - Particles * 0.25        'Set the number of particles
  4465.    effect(EffectIndex).Used = True        'Enabled the effect
  4466.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  4467.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  4468.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  4469.    effect(EffectIndex).Direction = Direction        'The direction the effect is animat
  4470.    effect(EffectIndex).Progression = Progression        'Loop the effect
  4471.  
  4472.     'Set the number of particles left to the total avaliable
  4473.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  4474.  
  4475.     'Set the float variables
  4476.    effect(EffectIndex).FloatSize = Effect_FToDW(12)        'Size of the particles
  4477.  
  4478.     'Redim the number of particles
  4479.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  4480.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  4481.     effect(EffectIndex).TargetAA = 0
  4482.     'Create the particles
  4483.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  4484.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  4485.         effect(EffectIndex).Particles(LoopC).Used = True
  4486.        
  4487.         'Effect_Necro_Reset EffectIndex, LoopC
  4488.    Next LoopC
  4489.  
  4490.     'Set The Initial Time
  4491.    effect(EffectIndex).PreviousFrame = GetTickCount
  4492.  
  4493. End Function
  4494.  
  4495. Private Sub Effect_Curse_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  4496.  
  4497.     'Static TargetA As Single
  4498.    Dim Co As Single
  4499.     Dim Si As Single
  4500.     Dim rG As Single
  4501.  
  4502.     rG = (Rnd * 0.4)
  4503.     'Calculate the angle
  4504.  
  4505.     If effect(EffectIndex).TargetAA = 0 And effect(EffectIndex).GoToX <> -30000 Then effect(EffectIndex).TargetAA = Engine_GetAngle(effect(EffectIndex).X, effect(EffectIndex).Y, effect(EffectIndex).GoToX, effect(EffectIndex).GoToY) + 180
  4506.  
  4507.     Si = Sin(effect(EffectIndex).TargetAA * DegreeToRadian)
  4508.     Co = Cos(effect(EffectIndex).TargetAA * DegreeToRadian)
  4509.  
  4510.     'Reset the particle
  4511.    If RandomNumber(1, 2) = 2 Then
  4512.         'Effect(EffectIndex).Particles(index).ResetIt Effect(EffectIndex).x, Effect(EffectIndex).y, Co * Sin(Effect(EffectIndex).Progression * 3) * 20, Si * Sin(Effect(EffectIndex).Progression * 3) * 20, 0, 0
  4513.        effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + Co * Sin(effect(EffectIndex).Progression) * 15, effect(EffectIndex).Y + Si * Sin(effect(EffectIndex).Progression) * 15, 0, 0, 0, 0
  4514.         effect(EffectIndex).Particles(Index).ResetColor rG, 0.4, rG, 0.5 + (Rnd * 0.2), 0.1 + (Rnd * 4.09)
  4515.     Else
  4516.         'Effect(EffectIndex).Particles(index).ResetIt Effect(EffectIndex).x, Effect(EffectIndex).y, Co * Sin(Effect(EffectIndex).Progression * 3) * -20, Si * Sin(Effect(EffectIndex).Progression * 3) * -20, 0, 0
  4517.        effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + Co * Sin(effect(EffectIndex).Progression) * -15, effect(EffectIndex).Y + Si * Sin(effect(EffectIndex).Progression) * -15, 0, 0, 0, 0
  4518.         effect(EffectIndex).Particles(Index).ResetColor rG, rG, 0.4, 0.7 + (Rnd * 0.2), 0.1 + (Rnd * 4.09)
  4519.     End If
  4520.  
  4521.  
  4522. End Sub
  4523.  
  4524. Private Sub Effect_Curse_Update(ByVal EffectIndex As Integer)
  4525.     '*****************************************************************
  4526.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Update
  4527.    '*****************************************************************
  4528.    Dim ElapsedTime As Single
  4529.     Dim LoopC As Long
  4530.  
  4531.     'Calculate The Time Difference
  4532.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  4533.     effect(EffectIndex).PreviousFrame = GetTickCount
  4534.  
  4535.     'Update the life span
  4536.    If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  4537.  
  4538.     'Go Through The Particle Loop
  4539.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  4540.  
  4541.         'Check If Particle Is In Use
  4542.        If effect(EffectIndex).Particles(LoopC).Used Then
  4543.  
  4544.             'Update The Particle
  4545.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  4546.  
  4547.             'Check if the particle is ready to die
  4548.            If effect(EffectIndex).Particles(LoopC).SngA <= 0.5 And RandomNumber(1, 3) = 3 Then
  4549.  
  4550.                 'Check if the effect is ending
  4551.                If effect(EffectIndex).Progression > 0 Or effect(EffectIndex).Progression = -5000 Then
  4552.  
  4553.  
  4554.                     'Reset the particle
  4555.                    Effect_Curse_Reset EffectIndex, LoopC
  4556.  
  4557.                 Else
  4558.  
  4559.                     'Disable the particle
  4560.                    effect(EffectIndex).Particles(LoopC).Used = False
  4561.  
  4562.                     'Subtract from the total particle count
  4563.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  4564.  
  4565.                     'Check if the effect is out of particles
  4566.                    If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  4567.  
  4568.                     'Clear the color (dont leave behind any artifacts)
  4569.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  4570.  
  4571.                 End If
  4572.  
  4573.             Else
  4574.  
  4575.                 'Set the particle information on the particle vertex
  4576.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  4577.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  4578.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  4579.  
  4580.             End If
  4581.  
  4582.         End If
  4583.  
  4584.     Next LoopC
  4585.  
  4586. End Sub
  4587.  
  4588. Function Effect_Ray_Begin(ByVal X As Single, ByVal Y As Single, ByVal Gfx As Integer, ByVal Particles As Integer, Optional ByVal Direction As Integer = 180, Optional ByVal Progression As Single = 1) As Integer
  4589.     '*****************************************************************
  4590.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Begin
  4591.    '*****************************************************************
  4592.    Dim EffectIndex As Integer
  4593.     Dim LoopC As Long
  4594.  
  4595.     'Get the next open effect slot
  4596.    EffectIndex = Effect_NextOpenSlot
  4597.     If EffectIndex = -1 Then Exit Function
  4598.  
  4599.     'Return the index of the used slot
  4600.    Effect_Ray_Begin = EffectIndex
  4601.  
  4602.     'Set The Effect's Variables
  4603.    effect(EffectIndex).EffectNum = EffectNum_Ray        'Set the effect number
  4604.    effect(EffectIndex).ParticleCount = Particles - Particles * 0.25        'Set the number of particles
  4605.    effect(EffectIndex).Used = True        'Enabled the effect
  4606.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  4607.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  4608.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  4609.    effect(EffectIndex).Direction = Direction        'The direction the effect is animat
  4610.    effect(EffectIndex).Progression = Progression        'Loop the effect
  4611.  
  4612.     'Set the number of particles left to the total avaliable
  4613.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  4614.  
  4615.     'Set the float variables
  4616.    effect(EffectIndex).FloatSize = Effect_FToDW(15)        'Size of the particles
  4617.  
  4618.     'Redim the number of particles
  4619.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  4620.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  4621.  
  4622.     'Create the particles
  4623.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  4624.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  4625.         effect(EffectIndex).Particles(LoopC).Used = True
  4626.        
  4627.         Effect_Ray_Reset EffectIndex, LoopC
  4628.     Next LoopC
  4629.  
  4630.     'Set The Initial Time
  4631.    effect(EffectIndex).PreviousFrame = GetTickCount
  4632.  
  4633. End Function
  4634.  
  4635. Private Sub Effect_Ray_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  4636.     '*****************************************************************
  4637.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Reset
  4638.    '*****************************************************************
  4639.    Dim rG As Single
  4640.     rG = (Rnd * 1)
  4641.     'Reset the particle
  4642.    effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X - 10 + Rnd * 20, effect(EffectIndex).Y - 10 + Rnd * 20, Rnd * 2 * RandomNumber(-1, 1), Rnd * 2 * RandomNumber(-1, 1), 0, 0
  4643.     effect(EffectIndex).Particles(Index).ResetColor rG, rG, 1, 0.8 + (Rnd * 0.2), 0.1 + (Rnd * 4.09)
  4644.  
  4645. End Sub
  4646.  
  4647. Private Sub Effect_Ray_Update(ByVal EffectIndex As Integer)
  4648.     '*****************************************************************
  4649.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Update
  4650.    '*****************************************************************
  4651.    Dim ElapsedTime As Single
  4652.     Dim LoopC As Long
  4653.  
  4654.     'Calculate The Time Difference
  4655.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  4656.     effect(EffectIndex).PreviousFrame = GetTickCount
  4657.  
  4658.     'Update the life span
  4659.    If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  4660.  
  4661.     'Go Through The Particle Loop
  4662.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  4663.  
  4664.         'Check If Particle Is In Use
  4665.        If effect(EffectIndex).Particles(LoopC).Used Then
  4666.  
  4667.             'Update The Particle
  4668.            'If EffectIndex = EIndex Or EffectIndex = EIndex2 Then
  4669.            '    Effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime, True
  4670.            'Else
  4671.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  4672.             'End If
  4673.  
  4674.             'Check if the particle is ready to die
  4675.            If effect(EffectIndex).Particles(LoopC).SngA <= 0.3 And RandomNumber(1, 5) = 1 Then
  4676.  
  4677.                 'Check if the effect is ending
  4678.                If effect(EffectIndex).Progression > 0 Or effect(EffectIndex).Progression = -5000 Then
  4679.  
  4680.  
  4681.                     'Reset the particle
  4682.                    Effect_Ray_Reset EffectIndex, LoopC
  4683.  
  4684.                 Else
  4685.  
  4686.                     'Disable the particle
  4687.                    effect(EffectIndex).Particles(LoopC).Used = False
  4688.  
  4689.                     'Subtract from the total particle count
  4690.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  4691.  
  4692.                     'Check if the effect is out of particles
  4693.                    If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  4694.  
  4695.                     'Clear the color (dont leave behind any artifacts)
  4696.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  4697.  
  4698.                 End If
  4699.  
  4700.             Else
  4701.  
  4702.                 'Set the particle information on the particle vertex
  4703.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  4704.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  4705.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  4706.  
  4707.             End If
  4708.  
  4709.         End If
  4710.  
  4711.     Next LoopC
  4712.  
  4713. End Sub
  4714.  
  4715. Function Effect_Ice_Begin(ByVal X As Single, ByVal Y As Single, ByVal Gfx As Integer, ByVal Particles As Integer, Optional ByVal Progression As Single = 1, Optional Looping As Boolean = False) As Integer
  4716.     '*****************************************************************
  4717.    'Particle effect template for effects as described on the
  4718.    'wiki page: http://www.vbgore.com/Particle_effect_equations
  4719.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Begin
  4720.    '*****************************************************************
  4721.    Dim EffectIndex As Integer
  4722.     Dim LoopC As Long
  4723.  
  4724.     'Get the next open effect slot
  4725.    EffectIndex = Effect_NextOpenSlot
  4726.     If EffectIndex = -1 Then Exit Function
  4727.  
  4728.     'Return the index of the used slot
  4729.    Effect_Ice_Begin = EffectIndex
  4730.  
  4731.     'Set The Effect's Variables
  4732.    effect(EffectIndex).EffectNum = EffectNum_Ice        'Set the effect number
  4733.    effect(EffectIndex).ParticleCount = Particles - Particles * 0.25        'Set the number of particles
  4734.    effect(EffectIndex).Used = True        'Enable the effect
  4735.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  4736.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  4737.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  4738.    effect(EffectIndex).Progression = Progression        'If we loop the effect
  4739.    effect(EffectIndex).Looping = Looping
  4740.     'Set the number of particles left to the total avaliable
  4741.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  4742.  
  4743.     'Set the float variables
  4744.    effect(EffectIndex).FloatSize = Effect_FToDW(16)        'Size of the particles
  4745.  
  4746.     'Redim the number of particles
  4747.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  4748.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  4749.  
  4750.     'Create the particles
  4751.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  4752.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  4753.         effect(EffectIndex).Particles(LoopC).Used = True
  4754.        
  4755.         Effect_Ice_Reset EffectIndex, LoopC
  4756.     Next LoopC
  4757.  
  4758.     'Set The Initial Time
  4759.    effect(EffectIndex).PreviousFrame = GetTickCount
  4760.  
  4761. End Function
  4762.  
  4763. Private Sub Effect_Ice_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  4764.     '*****************************************************************
  4765.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Reset
  4766.    '*****************************************************************
  4767.    Dim X As Single
  4768.     Dim Y As Single
  4769.     Dim R As Single
  4770.     Dim rG As Single
  4771.  
  4772.     rG = (Rnd * 1)
  4773.  
  4774.     effect(EffectIndex).Progression = effect(EffectIndex).Progression + 0.1
  4775.     R = (Index / 20) * Exp(Index / effect(EffectIndex).Progression Mod 3)
  4776.     X = R * Cos(Index) * (Rnd * 1.5)
  4777.     Y = R * Sin(Index) * (Rnd * 1.5)
  4778.  
  4779.     'Reset the particle
  4780.    effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + X, effect(EffectIndex).Y + Y, 0, 0, 0, 0
  4781.     effect(EffectIndex).Particles(Index).ResetColor rG, rG, 1, 0.9, 0.2 + (Rnd * 0.2)
  4782.  
  4783. End Sub
  4784.  
  4785. Private Sub Effect_Ice_Update(ByVal EffectIndex As Integer)
  4786.     '*****************************************************************
  4787.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Update
  4788.    '*****************************************************************
  4789.    Dim ElapsedTime As Single
  4790.     Dim LoopC As Long
  4791.  
  4792.     'Calculate The Time Difference
  4793.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  4794.     effect(EffectIndex).PreviousFrame = GetTickCount
  4795.  
  4796.  
  4797.  
  4798.     'Go Through The Particle Loop
  4799.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  4800.  
  4801.         'Check If Particle Is In Use
  4802.        If effect(EffectIndex).Particles(LoopC).Used Then
  4803.  
  4804.             'Update the particle
  4805.            'If EffectIndex = EIndex Or EffectIndex = EIndex2 Then
  4806.            '    Effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime, True
  4807.            'Else
  4808.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  4809.             'End If
  4810.  
  4811.             'Check if the particle is ready to die
  4812.            If effect(EffectIndex).Particles(LoopC).SngA <= 0.2 Then
  4813.  
  4814.                 'Check if the effect is ending
  4815.                If effect(EffectIndex).Progression < 80 Then
  4816.  
  4817.                     'Reset the particle
  4818.                    Effect_Ice_Reset EffectIndex, LoopC
  4819.  
  4820.                 ElseIf effect(EffectIndex).Looping Then
  4821.                     effect(EffectIndex).Progression = 70
  4822.                 Else
  4823.  
  4824.                     'Disable the particle
  4825.                    effect(EffectIndex).Particles(LoopC).Used = False
  4826.  
  4827.                     'Subtract from the total particle count
  4828.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  4829.  
  4830.                     'Check if the effect is out of particles
  4831.                    If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  4832.  
  4833.                     'Clear the color (dont leave behind any artifacts)
  4834.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  4835.  
  4836.                 End If
  4837.  
  4838.             Else
  4839.  
  4840.                 'Set the particle information on the particle vertex
  4841.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  4842.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  4843.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  4844.  
  4845.             End If
  4846.  
  4847.         End If
  4848.  
  4849.     Next LoopC
  4850.  
  4851. End Sub
  4852.  
  4853. Function Effect_Torch_Begin(ByVal X As Single, ByVal Y As Single, ByVal Gfx As Integer, ByVal Particles As Integer, Optional ByVal Direction As Integer = 180, Optional ByVal Progression As Single = 1) As Integer
  4854.     '*****************************************************************
  4855.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Begin
  4856.    '*****************************************************************
  4857.    Dim EffectIndex As Integer
  4858.     Dim LoopC As Long
  4859.  
  4860.     'Get the next open effect slot
  4861.    EffectIndex = Effect_NextOpenSlot
  4862.     If EffectIndex = -1 Then Exit Function
  4863.  
  4864.     'Return the index of the used slot
  4865.    Effect_Torch_Begin = EffectIndex
  4866.  
  4867.     'Set The Effect's Variables
  4868.    effect(EffectIndex).EffectNum = EffectNum_Torch        'Set the effect number
  4869.    effect(EffectIndex).ParticleCount = Particles - Particles * 0.25        'Set the number of particles
  4870.    effect(EffectIndex).Used = True        'Enabled the effect
  4871.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  4872.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  4873.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  4874.    effect(EffectIndex).Direction = Direction        'The direction the effect is animat
  4875.    effect(EffectIndex).Progression = Progression        'Loop the effect
  4876.  
  4877.     'Set the number of particles left to the total avaliable
  4878.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  4879.  
  4880.     'Set the float variables
  4881.    effect(EffectIndex).FloatSize = Effect_FToDW(15)        'Size of the particles
  4882.  
  4883.     'Redim the number of particles
  4884.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  4885.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  4886.  
  4887.     'Create the particles
  4888.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  4889.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  4890.         effect(EffectIndex).Particles(LoopC).Used = True
  4891.        
  4892.         Effect_Torch_Reset EffectIndex, LoopC
  4893.     Next LoopC
  4894.  
  4895.     'Set The Initial Time
  4896.    effect(EffectIndex).PreviousFrame = GetTickCount
  4897.  
  4898. End Function
  4899.  
  4900. Private Sub Effect_Torch_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  4901.     '*****************************************************************
  4902.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Reset
  4903.    '*****************************************************************
  4904.  
  4905.     'Reset the particle
  4906.    effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X - 10 + Rnd * 20, effect(EffectIndex).Y - 10 + Rnd * 20, Rnd * 2 * RandomNumber(-1, 1), Rnd * 2 * RandomNumber(-1, 1), 0, 0
  4907.     effect(EffectIndex).Particles(Index).ResetColor 1, 0.1 + (Rnd * 0.4), 0.2, 0.4 + (Rnd * 0.2), 0.1 + (Rnd * 0.07)
  4908.  
  4909. End Sub
  4910.  
  4911. Private Sub Effect_Torch_Update(ByVal EffectIndex As Integer)
  4912.     '*****************************************************************
  4913.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Update
  4914.    '*****************************************************************
  4915.    Dim ElapsedTime As Single
  4916.     Dim LoopC As Long
  4917.  
  4918.     'Calculate The Time Difference
  4919.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  4920.     effect(EffectIndex).PreviousFrame = GetTickCount
  4921.  
  4922.     'Update the life span
  4923.    If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  4924.  
  4925.     'Go Through The Particle Loop
  4926.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  4927.  
  4928.         'Check If Particle Is In Use
  4929.        If effect(EffectIndex).Particles(LoopC).Used Then
  4930.  
  4931.             'Update The Particle
  4932.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  4933.  
  4934.             'Check if the particle is ready to die
  4935.            If effect(EffectIndex).Particles(LoopC).SngA <= 0.3 Then
  4936.  
  4937.                 'Check if the effect is ending
  4938.                If effect(EffectIndex).Progression > 0 Or effect(EffectIndex).Progression = -5000 Then
  4939.  
  4940.  
  4941.                     'Reset the particle
  4942.                    Effect_Torch_Reset EffectIndex, LoopC
  4943.  
  4944.                 Else
  4945.  
  4946.                     'Disable the particle
  4947.                    effect(EffectIndex).Particles(LoopC).Used = False
  4948.  
  4949.                     'Subtract from the total particle count
  4950.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  4951.  
  4952.                     'Check if the effect is out of particles
  4953.                    If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  4954.  
  4955.                     'Clear the color (dont leave behind any artifacts)
  4956.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  4957.  
  4958.                 End If
  4959.  
  4960.             Else
  4961.  
  4962.                 'Set the particle information on the particle vertex
  4963.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  4964.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  4965.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  4966.  
  4967.             End If
  4968.  
  4969.         End If
  4970.  
  4971.     Next LoopC
  4972.  
  4973. End Sub
  4974. Function Effect_Implode_Begin(ByVal X As Single, ByVal Y As Single, ByVal Gfx As Integer, ByVal Particles As Integer, Optional ByVal Progression As Single = 1) As Integer
  4975.     '*****************************************************************
  4976.    'Particle effect template for effects as described on the
  4977.    'wiki page: http://www.vbgore.com/Particle_effect_equations
  4978.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Begin
  4979.    '*****************************************************************
  4980.    Dim EffectIndex As Integer
  4981.     Dim LoopC As Long
  4982.  
  4983.     'Get the next open effect slot
  4984.    EffectIndex = Effect_NextOpenSlot
  4985.     If EffectIndex = -1 Then Exit Function
  4986.  
  4987.     'Return the index of the used slot
  4988.    Effect_Implode_Begin = EffectIndex
  4989.  
  4990.     'Set The Effect's Variables
  4991.    effect(EffectIndex).EffectNum = EffectNum_Implode        'Set the effect number
  4992.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  4993.    effect(EffectIndex).Used = True        'Enable the effect
  4994.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  4995.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  4996.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  4997.    effect(EffectIndex).Progression = Progression        'If we loop the effect
  4998.  
  4999.     'Set the number of particles left to the total avaliable
  5000.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  5001.  
  5002.     'Set the float variables
  5003.    effect(EffectIndex).FloatSize = Effect_FToDW(18)        'Size of the particles
  5004.  
  5005.     'Redim the number of particles
  5006.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  5007.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  5008.  
  5009.     'Create the particles
  5010.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  5011.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  5012.         effect(EffectIndex).Particles(LoopC).Used = True
  5013.        
  5014.         Effect_Implode_Reset EffectIndex, LoopC
  5015.     Next LoopC
  5016.  
  5017.     'Set The Initial Time
  5018.    effect(EffectIndex).PreviousFrame = GetTickCount
  5019.  
  5020. End Function
  5021.  
  5022. Private Sub Effect_Implode_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  5023.     '*****************************************************************
  5024.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Reset
  5025.    '*****************************************************************
  5026.    Dim X As Single
  5027.     Dim Y As Single
  5028.     Dim R As Single
  5029.  
  5030.     effect(EffectIndex).Progression = effect(EffectIndex).Progression + 0.1
  5031.     'R = (index / 20) * exp(index / Effect(EffectIndex).Progression Mod 3)
  5032.    R = (91 - (Index / 20) - (effect(EffectIndex).Progression / ((Rnd * 0.1) + 0.9))) * 0.5
  5033.     X = R * Cos(Index)
  5034.     Y = R * Sin(Index) * 0.5
  5035.  
  5036.     'Reset the particle
  5037.    effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + X, effect(EffectIndex).Y + Y, 0, 0, 0, 0
  5038.     effect(EffectIndex).Particles(Index).ResetColor 0.4 + (Rnd * 0.6), 0.4 + (Rnd * 0.6), 0.8, 0.7, 0.4 + (Rnd * 0.2)
  5039.  
  5040. End Sub
  5041.  
  5042. Private Sub Effect_Implode_Update(ByVal EffectIndex As Integer)
  5043.     '*****************************************************************
  5044.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Update
  5045.    '*****************************************************************
  5046.    Dim ElapsedTime As Single
  5047.     Dim LoopC As Long
  5048.  
  5049.     'Calculate The Time Difference
  5050.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  5051.     effect(EffectIndex).PreviousFrame = GetTickCount
  5052.  
  5053.  
  5054.  
  5055.     'Go Through The Particle Loop
  5056.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  5057.  
  5058.         'Check If Particle Is In Use
  5059.        If effect(EffectIndex).Particles(LoopC).Used Then
  5060.  
  5061.             'Update The Particle
  5062.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  5063.  
  5064.             'Check if the particle is ready to die
  5065.            If effect(EffectIndex).Particles(LoopC).SngA <= 0.2 Then
  5066.  
  5067.                 'Check if the effect is ending
  5068.                If effect(EffectIndex).Progression < 50 Then
  5069.  
  5070.                     'Reset the particle
  5071.                    Effect_Implode_Reset EffectIndex, LoopC
  5072.  
  5073.                 Else
  5074.  
  5075.                     'Disable the particle
  5076.                    effect(EffectIndex).Particles(LoopC).Used = False
  5077.  
  5078.                     'Subtract from the total particle count
  5079.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  5080.  
  5081.                     'Check if the effect is out of particles
  5082.                    If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  5083.  
  5084.                     'Clear the color (dont leave behind any artifacts)
  5085.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  5086.  
  5087.                 End If
  5088.  
  5089.             Else
  5090.  
  5091.                 'Set the particle information on the particle vertex
  5092.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  5093.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  5094.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  5095.  
  5096.             End If
  5097.  
  5098.         End If
  5099.  
  5100.     Next LoopC
  5101.  
  5102. End Sub
  5103.  
  5104. Function Effect_Nova_Begin(ByVal X As Single, ByVal Y As Single, ByVal Gfx As Integer, ByVal Particles As Integer, Optional ByVal Progression As Single = 1) As Integer
  5105.     '*****************************************************************
  5106.    'Particle effect template for effects as described on the
  5107.    'wiki page: http://www.vbgore.com/Particle_effect_equations
  5108.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Begin
  5109.    '*****************************************************************
  5110.    Dim EffectIndex As Integer
  5111.     Dim LoopC As Long
  5112.  
  5113.     'Get the next open effect slot
  5114.    EffectIndex = Effect_NextOpenSlot
  5115.     If EffectIndex = -1 Then Exit Function
  5116.  
  5117.     'Return the index of the used slot
  5118.    Effect_Nova_Begin = EffectIndex
  5119.  
  5120.     'Set The Effect's Variables
  5121.    effect(EffectIndex).EffectNum = EffectNum_Nova        'Set the effect number
  5122.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  5123.    effect(EffectIndex).Used = True        'Enable the effect
  5124.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  5125.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  5126.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  5127.    effect(EffectIndex).Progression = Progression        'If we loop the effect
  5128.  
  5129.     'Set the number of particles left to the total avaliable
  5130.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  5131.  
  5132.     'Set the float variables
  5133.    effect(EffectIndex).FloatSize = Effect_FToDW(24)        'Size of the particles
  5134.  
  5135.     'Redim the number of particles
  5136.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  5137.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  5138.  
  5139.     'Create the particles
  5140.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  5141.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  5142.         effect(EffectIndex).Particles(LoopC).Used = True
  5143.        
  5144.         Effect_Nova_Reset EffectIndex, LoopC
  5145.     Next LoopC
  5146.  
  5147.     'Set The Initial Time
  5148.    effect(EffectIndex).PreviousFrame = GetTickCount
  5149.  
  5150. End Function
  5151.  
  5152. Private Sub Effect_Nova_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  5153.     '*****************************************************************
  5154.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Reset
  5155.    '*****************************************************************
  5156.    Dim X As Single
  5157.     Dim Y As Single
  5158.     Dim R As Single
  5159.  
  5160.     effect(EffectIndex).Progression = effect(EffectIndex).Progression + 0.05
  5161.     'R = (index / 20) * exp(index / Effect(EffectIndex).Progression Mod 3)
  5162.    R = (Index / 10) + (effect(EffectIndex).Progression / ((Rnd * 0.3) + 0.7))
  5163.     X = R * Cos(Index) * 2
  5164.     Y = R * Sin(Index) * 0.5
  5165.  
  5166.     'Reset the particle
  5167.    effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + X, effect(EffectIndex).Y + Y, 0, 0, 0, 0
  5168.     effect(EffectIndex).Particles(Index).ResetColor 1, 0.25 + (Rnd * 0.6), 0.2, 0.7, 0.2 + (Rnd * 0.2)
  5169.  
  5170. End Sub
  5171.  
  5172. Private Sub Effect_Nova_Update(ByVal EffectIndex As Integer)
  5173.     '*****************************************************************
  5174.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_EquationTemplate_Update
  5175.    '*****************************************************************
  5176.    Dim ElapsedTime As Single
  5177.     Dim LoopC As Long
  5178.  
  5179.     'Calculate The Time Difference
  5180.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  5181.     effect(EffectIndex).PreviousFrame = GetTickCount
  5182.  
  5183.  
  5184.  
  5185.     'Go Through The Particle Loop
  5186.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  5187.  
  5188.         'Check If Particle Is In Use
  5189.        If effect(EffectIndex).Particles(LoopC).Used Then
  5190.  
  5191.             'Update The Particle
  5192.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  5193.  
  5194.             'Check if the particle is ready to die
  5195.            If effect(EffectIndex).Particles(LoopC).SngA <= 0.3 Then
  5196.  
  5197.                 'Check if the effect is ending
  5198.                If effect(EffectIndex).Progression < 50 Then
  5199.  
  5200.                     'Reset the particle
  5201.                    Effect_Nova_Reset EffectIndex, LoopC
  5202.  
  5203.                 Else
  5204.  
  5205.                     'Disable the particle
  5206.                    effect(EffectIndex).Particles(LoopC).Used = False
  5207.  
  5208.                     'Subtract from the total particle count
  5209.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  5210.  
  5211.                     'Check if the effect is out of particles
  5212.                    If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  5213.  
  5214.                     'Clear the color (dont leave behind any artifacts)
  5215.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  5216.  
  5217.                 End If
  5218.  
  5219.             Else
  5220.  
  5221.                 'Set the particle information on the particle vertex
  5222.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  5223.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  5224.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  5225.  
  5226.             End If
  5227.  
  5228.         End If
  5229.  
  5230.     Next LoopC
  5231.  
  5232. End Sub
  5233.  
  5234. Function Effect_PortalGroso_Begin(ByVal X As Single, ByVal Y As Single, ByVal Gfx As Integer, ByVal Particles As Integer, Optional ByVal Progression As Single = 1) As Integer
  5235.     Dim EffectIndex As Integer
  5236.     Dim LoopC As Long
  5237.  
  5238.     'Get the next open effect slot
  5239.    EffectIndex = Effect_NextOpenSlot
  5240.     If EffectIndex = -1 Then Exit Function
  5241.  
  5242.     'Return the index of the used slot
  5243.    Effect_PortalGroso_Begin = EffectIndex
  5244.  
  5245.     'Set The Effect's Variables
  5246.    effect(EffectIndex).EffectNum = EffectNum_PortalGroso        'Set the effect number
  5247.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  5248.    effect(EffectIndex).Used = True        'Enable the effect
  5249.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  5250.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  5251.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  5252.    effect(EffectIndex).Progression = Progression        'If we loop the effect
  5253.  
  5254.     'Set the number of particles left to the total avaliable
  5255.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  5256.  
  5257.     'Set the float variables
  5258.    effect(EffectIndex).FloatSize = Effect_FToDW(20)        'Size of the particles
  5259.  
  5260.     'Redim the number of particles
  5261.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  5262.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  5263.  
  5264.     'Create the particles
  5265.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  5266.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  5267.         effect(EffectIndex).Particles(LoopC).Used = True
  5268.        
  5269.         Effect_PortalGroso_Reset EffectIndex, LoopC
  5270.     Next LoopC
  5271.  
  5272.     'Set The Initial Time
  5273.    effect(EffectIndex).PreviousFrame = GetTickCount
  5274.  
  5275. End Function
  5276.  
  5277. Private Sub Effect_PortalGroso_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  5278.     Dim X As Single
  5279.     Dim Y As Single
  5280.     Dim R As Single
  5281.     Dim ind As Integer
  5282.     effect(EffectIndex).Progression = effect(EffectIndex).Progression + 0.1
  5283.     ind = CInt(Index / 10) * 10
  5284.     R = ((Index + 100) / 4) * Exp((Index + 100) / 2000)
  5285.     X = R * Cos(Index) * 0.25        '* 0.3 * 0.25
  5286.    Y = R * Sin(Index) * 0.25        '* 0.2 * 0.25
  5287.    'Reset the particle
  5288.    'If Rnd * 20 < 1 Then
  5289.    '    Effect(EffectIndex).Particles(index).ResetIt Effect(EffectIndex).x + x, Effect(EffectIndex).y + y, 0, 0, 0, -1.5 * (ind / Effect(EffectIndex).ParticleCount)
  5290.    'Else
  5291.    effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + X, effect(EffectIndex).Y + Y, 0, 0, 0, 0
  5292.     'End If
  5293.    effect(EffectIndex).Particles(Index).ResetColor 0.2, 0, (0.7 * ind / effect(EffectIndex).ParticleCount), 1, IIf(ind / effect(EffectIndex).ParticleCount / 7 < 0.03, 0.03, ind / effect(EffectIndex).ParticleCount / 7)
  5294.  
  5295. End Sub
  5296.  
  5297. Private Sub Effect_PortalGroso_Update(ByVal EffectIndex As Integer)
  5298.     Dim ElapsedTime As Single
  5299.     Dim LoopC As Long
  5300.     'Dim Owner As Integer
  5301.    'Calculate The Time Difference
  5302.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  5303.     effect(EffectIndex).PreviousFrame = GetTickCount
  5304.  
  5305.     'For LoopC = 1 To LastChar
  5306.    '    If EffectIndex = CharList(LoopC).AuraIndex Then
  5307.    '        Owner = LoopC
  5308.    '    End If
  5309.    'Next
  5310.  
  5311.     'If opciones.bGraphics < 2 Then Effect(EffectIndex).Used = False
  5312.  
  5313.     'If Owner = 0 Then
  5314.    '    Effect(EffectIndex).Used = False
  5315.    'End If
  5316.  
  5317.     'Go Through The Particle Loop
  5318.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  5319.  
  5320.         'Check If Particle Is In Use
  5321.        If effect(EffectIndex).Particles(LoopC).Used Then
  5322.  
  5323.             ''Update The Particle
  5324.            'If EffectIndex <> CharList(UserCharIndex).AuraIndex Then
  5325.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  5326.             'Else
  5327.            '   Effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime, True
  5328.            'End If
  5329.  
  5330.             'Check if the particle is ready to die
  5331.            If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  5332.  
  5333.                 'Check if the effect is ending
  5334.                If effect(EffectIndex).Progression > 0 Then
  5335.  
  5336.                     'Reset the particle
  5337.                    Effect_PortalGroso_Reset EffectIndex, LoopC
  5338.  
  5339.                 Else
  5340.  
  5341.                     'Disable the particle
  5342.                    effect(EffectIndex).Particles(LoopC).Used = False
  5343.  
  5344.                     'Subtract from the total particle count
  5345.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  5346.  
  5347.                     'Check if the effect is out of particles
  5348.                    If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  5349.  
  5350.                     'Clear the color (dont leave behind any artifacts)
  5351.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  5352.  
  5353.                 End If
  5354.  
  5355.             Else
  5356.  
  5357.                 'Set the particle information on the particle vertex
  5358.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  5359.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  5360.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  5361.  
  5362.             End If
  5363.  
  5364.         End If
  5365.  
  5366.     Next LoopC
  5367.  
  5368. End Sub
  5369.  
  5370. Function Effect_teleport_Begin(ByVal X As Single, ByVal Y As Single, ByVal Gfx As Integer, ByVal Particles As Integer, Optional ByVal size As Byte = 30, Optional ByVal Time As Single = 10) As Integer
  5371.     Dim EffectIndex As Integer
  5372.     Dim LoopC As Long
  5373.  
  5374.     'Get the next open effect slot
  5375.    EffectIndex = Effect_NextOpenSlot
  5376.     If EffectIndex = -1 Then Exit Function
  5377.  
  5378.     'Return the index of the used slot
  5379.    Effect_teleport_Begin = EffectIndex
  5380.  
  5381.     'Set The Effect's Variables
  5382.    effect(EffectIndex).EffectNum = EffectNum_Teleport        'Set the effect number
  5383.    effect(EffectIndex).ParticleCount = Particles - Particles * 0.25        'Set the number of particles
  5384.    effect(EffectIndex).Used = True        'Enabled the effect
  5385.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  5386.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  5387.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  5388.    effect(EffectIndex).Modifier = size        'How large the circle is
  5389.    effect(EffectIndex).Progression = Time        'How long the effect will last
  5390.  
  5391.     'Set the number of particles left to the total avaliable
  5392.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  5393.  
  5394.     'Set the float variables
  5395.    effect(EffectIndex).FloatSize = Effect_FToDW(15)        'Size of the particles
  5396.  
  5397.     'Redim the number of particles
  5398.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  5399.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  5400.  
  5401.     'Create the particles
  5402.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  5403.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  5404.         effect(EffectIndex).Particles(LoopC).Used = True
  5405.        
  5406.         Effect_teleport_Reset EffectIndex, LoopC
  5407.     Next LoopC
  5408.  
  5409.     'Set The Initial Time
  5410.    effect(EffectIndex).PreviousFrame = GetTickCount
  5411.  
  5412. End Function
  5413.  
  5414. Private Sub Effect_teleport_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  5415.     Dim a As Single
  5416.     Dim X As Single
  5417.     Dim Y As Single
  5418.  
  5419.  
  5420.     If Rnd * 10 < 5 Then
  5421.         'Get the positions
  5422.        a = Rnd * 360 * DegreeToRadian
  5423.         X = effect(EffectIndex).X - (Sin(a) * effect(EffectIndex).Modifier) / 2.2        '* (0.8 + Rnd * 0.2)
  5424.        Y = effect(EffectIndex).Y + (Cos(a) * effect(EffectIndex).Modifier)
  5425.     Else
  5426.         a = Rnd * 360 * DegreeToRadian
  5427.         X = effect(EffectIndex).X - (Sin(a) * effect(EffectIndex).Modifier / 2) / 2.2        '* (0.8 + Rnd * 0.2)
  5428.        Y = effect(EffectIndex).Y + (Cos(a) * effect(EffectIndex).Modifier / 2)
  5429.     End If
  5430.     'Reset the particle
  5431.    effect(EffectIndex).Particles(Index).ResetIt X, Y, 0, Rnd * -1, 0, -2
  5432.     effect(EffectIndex).Particles(Index).ResetColor 1, Rnd * 0.5, Rnd * 0.5, 0.6 + (Rnd * 0.4), 0.2 + (Rnd * 0.2)
  5433.  
  5434. End Sub
  5435.  
  5436. Private Sub Effect_teleport_Update(ByVal EffectIndex As Integer)
  5437.     Dim ElapsedTime As Single
  5438.     Dim LoopC As Long
  5439.  
  5440.     'Calculate The Time Difference
  5441.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  5442.     effect(EffectIndex).PreviousFrame = GetTickCount
  5443.  
  5444.     'Update the life span
  5445.    'If Effect(EffectIndex).Progression > 0 Then Effect(EffectIndex).Progression = Effect(EffectIndex).Progression - ElapsedTime
  5446.  
  5447.     'Go Through The Particle Loop
  5448.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  5449.  
  5450.         'Check If Particle Is In Use
  5451.        If effect(EffectIndex).Particles(LoopC).Used Then
  5452.  
  5453.             'Update The Particle
  5454.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  5455.  
  5456.             'Check if the particle is ready to die
  5457.            If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  5458.  
  5459.                 'Check if the effect is ending
  5460.                If effect(EffectIndex).Progression > 0 Then
  5461.  
  5462.                     'Reset the particle
  5463.                    Effect_teleport_Reset EffectIndex, LoopC
  5464.  
  5465.                 Else
  5466.  
  5467.                     'Disable the particle
  5468.                    effect(EffectIndex).Particles(LoopC).Used = False
  5469.  
  5470.                     'Subtract from the total particle count
  5471.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  5472.  
  5473.                     'Check if the effect is out of particles
  5474.                    If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  5475.  
  5476.                     'Clear the color (dont leave behind any artifacts)
  5477.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  5478.  
  5479.                 End If
  5480.  
  5481.             Else
  5482.  
  5483.                 'Set the particle information on the particle vertex
  5484.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  5485.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  5486.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  5487.  
  5488.             End If
  5489.  
  5490.         End If
  5491.  
  5492.     Next LoopC
  5493.  
  5494. End Sub
  5495.  
  5496.  
  5497.  
  5498. Function Effect_Atom_Begin(ByVal X As Single, ByVal Y As Single, ByVal Gfx As Integer, ByVal Particles As Integer, Optional ByVal size As Byte = 30, Optional ByVal Time As Single = 10) As Integer
  5499.  
  5500.     Dim EffectIndex As Integer
  5501.     Dim LoopC As Long
  5502.  
  5503.     'Get the next open effect slot
  5504.    EffectIndex = Effect_NextOpenSlot
  5505.     If EffectIndex = -1 Then Exit Function
  5506.  
  5507.     'Return the index of the used slot
  5508.    Effect_Atom_Begin = EffectIndex
  5509.  
  5510.     'Set the effect's variables
  5511.    effect(EffectIndex).EffectNum = EffectNum_Atom        'Set the effect number
  5512.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  5513.    effect(EffectIndex).Used = True        'Enabled the effect
  5514.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  5515.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  5516.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  5517.    effect(EffectIndex).Modifier = size        'How large the circle is
  5518.    effect(EffectIndex).Progression = Time        'How long the effect will last
  5519.  
  5520.     'Set the number of particles left to the total avaliable
  5521.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  5522.  
  5523.     'Set the float variables
  5524.    effect(EffectIndex).FloatSize = Effect_FToDW(16)        'Size of the particles
  5525.  
  5526.     'Redim the number of particles
  5527.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  5528.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  5529.  
  5530.     'Create the particles
  5531.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  5532.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  5533.         effect(EffectIndex).Particles(LoopC).Used = True
  5534.        
  5535.         Effect_Atom_Reset EffectIndex, LoopC
  5536.     Next LoopC
  5537.  
  5538.     'Set The Initial Time
  5539.    effect(EffectIndex).PreviousFrame = GetTickCount
  5540.  
  5541. End Function
  5542.  
  5543. Private Sub Effect_Atom_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  5544.  
  5545.     Dim a As Single
  5546.     Dim X As Single
  5547.     Dim Y As Single
  5548.     Dim R As Single
  5549.     'Get the positions
  5550.    a = Rnd * 360 * DegreeToRadian
  5551.     R = Rnd * 4
  5552.     If R < 1 Then
  5553.         X = effect(EffectIndex).X - (Sin(a) * effect(EffectIndex).Modifier) / 3 + (Cos(a) * effect(EffectIndex).Modifier)
  5554.         Y = effect(EffectIndex).Y + (Cos(a) * effect(EffectIndex).Modifier)
  5555.         effect(EffectIndex).Particles(Index).ResetColor 0.2, 1, 0.2, 0.6 + (Rnd * 0.4), 0.06 + (Rnd * 0.2)
  5556.     ElseIf R < 2 Then
  5557.         X = effect(EffectIndex).X - (Sin(a) * effect(EffectIndex).Modifier)
  5558.         Y = effect(EffectIndex).Y + (Cos(a) * effect(EffectIndex).Modifier) / 3 + (Sin(a) * effect(EffectIndex).Modifier)
  5559.         effect(EffectIndex).Particles(Index).ResetColor 1, 1, 0.2, 0.6 + (Rnd * 0.4), 0.06 + (Rnd * 0.2)
  5560.     ElseIf R < 3 Then
  5561.         X = effect(EffectIndex).X - (Sin(a) * effect(EffectIndex).Modifier) / 3
  5562.         Y = effect(EffectIndex).Y + (Cos(a) * effect(EffectIndex).Modifier)
  5563.         effect(EffectIndex).Particles(Index).ResetColor 1, 0.2, 0.2, 0.6 + (Rnd * 0.4), 0.06 + (Rnd * 0.2)
  5564.     ElseIf R < 4 Then
  5565.         X = effect(EffectIndex).X - (Sin(a) * effect(EffectIndex).Modifier)
  5566.         Y = effect(EffectIndex).Y + (Cos(a) * effect(EffectIndex).Modifier) / 3
  5567.  
  5568.         effect(EffectIndex).Particles(Index).ResetColor 0.2, 0.2, 1, 0.6 + (Rnd * 0.4), 0.06 + (Rnd * 0.2)
  5569.     End If
  5570.  
  5571.     'Reset the particle
  5572.    effect(EffectIndex).Particles(Index).ResetIt X, Y, 0, 0, 0, -1
  5573.  
  5574.  
  5575. End Sub
  5576.  
  5577. Function Effect_RedFountain_Begin(ByVal X As Single, ByVal Y As Single, ByVal Gfx As Integer, ByVal Particles As Integer) As Integer
  5578.  
  5579.     Dim EffectIndex As Integer
  5580.     Dim LoopC As Long
  5581.  
  5582.     'Get the next open effect slot
  5583.  
  5584.     EffectIndex = Effect_NextOpenSlot
  5585.     If EffectIndex = -1 Then Exit Function
  5586.  
  5587.     'Return the index of the used slot
  5588.    Effect_RedFountain_Begin = EffectIndex
  5589.  
  5590.     'Set the effect's variables
  5591.    effect(EffectIndex).EffectNum = EffectNum_RedFountain        'Set the effect number
  5592.    effect(EffectIndex).ParticleCount = Particles - Particles * 0.25        'Set the number of particles
  5593.    effect(EffectIndex).Used = True        'Enabled the effect
  5594.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  5595.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  5596.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  5597.  
  5598.     'Set the number of particles left to the total avaliable
  5599.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  5600.  
  5601.     'Set the float variables
  5602.    effect(EffectIndex).FloatSize = Effect_FToDW(20)        'Size of the particles
  5603.  
  5604.     'Redim the number of particles
  5605.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  5606.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  5607.  
  5608.     'Create the particles
  5609.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  5610.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  5611.         effect(EffectIndex).Particles(LoopC).Used = True
  5612.        
  5613.         Effect_RedFountain_Reset EffectIndex, LoopC
  5614.     Next LoopC
  5615.  
  5616.     'Set The Initial Time
  5617.    effect(EffectIndex).PreviousFrame = GetTickCount
  5618.  
  5619. End Function
  5620.  
  5621. Private Sub Effect_RedFountain_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  5622.  
  5623.     'If Int(Rnd * 10) < 6 Then
  5624.    effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + (Rnd * 10) - 5, effect(EffectIndex).Y - (Rnd * 10), 0, 1, 0, -1 - Rnd * 0.25
  5625.     'Else
  5626.    'Effect(EffectIndex).Particles(index).ResetIt Effect(EffectIndex).x + (Rnd * 10) - 5, Effect(EffectIndex).y - (Rnd * 10), 1 + (Rnd * 5), -15 - (Rnd * 3), 0, 1.1 + Rnd * 0.1
  5627.    'End If
  5628.    effect(EffectIndex).Particles(Index).ResetColor 0.9, Rnd * 0.7, 0.1, 0.6 + (Rnd * 0.4), 0.035 + Rnd * 0.01
  5629.  
  5630. End Sub
  5631.  
  5632. Private Sub Effect_RedFountain_Update(ByVal EffectIndex As Integer)
  5633.     Dim ElapsedTime As Single
  5634.     Dim LoopC As Long
  5635.  
  5636.     'Calculate The Time Difference
  5637.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  5638.     effect(EffectIndex).PreviousFrame = GetTickCount
  5639.  
  5640.     'Update the life span
  5641.    If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  5642.  
  5643.     'Go through the particle loop
  5644.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  5645.  
  5646.         With effect(EffectIndex).Particles(LoopC)
  5647.  
  5648.             'Check if the particle is in use
  5649.            If .Used Then
  5650.  
  5651.                 'Update The Particle
  5652.                .UpdateParticle ElapsedTime
  5653.  
  5654.                 'Check if the particle is ready to die
  5655.                If (.SngA < 0) Or (.sngY > effect(EffectIndex).Y + 100) Then
  5656.  
  5657.                     'Reset the particle
  5658.                    Effect_RedFountain_Reset EffectIndex, LoopC
  5659.  
  5660.                 Else
  5661.  
  5662.                     'Set the particle information on the particle vertex
  5663.                    effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(.SngR, .SngG, .SngB, .SngA)
  5664.                     effect(EffectIndex).PartVertex(LoopC).X = .sngX
  5665.                     effect(EffectIndex).PartVertex(LoopC).Y = .sngY
  5666.  
  5667.                 End If
  5668.  
  5669.             End If
  5670.  
  5671.         End With
  5672.  
  5673.     Next LoopC
  5674.  
  5675. End Sub
  5676.  
  5677.  
  5678. Function Effect_Explode_Begin(ByVal X As Single, ByVal Y As Single, ByVal Gfx As Integer, ByVal Particles As Integer, Optional ByVal size As Byte = 30, Optional ByVal Time As Single = 10) As Integer
  5679.     '*****************************************************************
  5680.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Bless_Begin
  5681.    '*****************************************************************
  5682.    Dim EffectIndex As Integer
  5683.     Dim LoopC As Long
  5684.  
  5685.     'Get the next open effect slot
  5686.    EffectIndex = Effect_NextOpenSlot
  5687.     If EffectIndex = -1 Then Exit Function
  5688.  
  5689.     'Return the index of the used slot
  5690.    Effect_Explode_Begin = EffectIndex
  5691.  
  5692.     'Set The Effect's Variables
  5693.    effect(EffectIndex).EffectNum = EffectNum_Explode        'Set the effect number
  5694.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  5695.    effect(EffectIndex).Used = True        'Enabled the effect
  5696.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  5697.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  5698.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  5699.    effect(EffectIndex).Modifier = size        'How large the circle is
  5700.    effect(EffectIndex).Progression = Time        'How long the effect will last
  5701.  
  5702.     'Set the number of particles left to the total avaliable
  5703.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  5704.  
  5705.     'Set the float variables
  5706.    effect(EffectIndex).FloatSize = Effect_FToDW(20)        'Size of the particles
  5707.  
  5708.     'Redim the number of particles
  5709.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  5710.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  5711.  
  5712.     'Create the particles
  5713.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  5714.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  5715.         effect(EffectIndex).Particles(LoopC).Used = True
  5716.        
  5717.         'Effect_Explode_Reset EffectIndex, LoopC
  5718.    Next LoopC
  5719.  
  5720.  
  5721.     'Set The Initial Time
  5722.    effect(EffectIndex).PreviousFrame = GetTickCount
  5723.     Effect_Explode_Update EffectIndex
  5724.  
  5725. End Function
  5726.  
  5727. Private Sub Effect_Explode_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  5728.  
  5729.     Dim a As Single
  5730.     Dim X As Single
  5731.     Dim Y As Single
  5732.  
  5733.  
  5734.     'Get the positions
  5735.    a = Round(Rnd, 1) * 360 * DegreeToRadian
  5736.  
  5737.  
  5738.     X = effect(EffectIndex).X - (Sin(a) * effect(EffectIndex).Modifier)        '+ index / 20
  5739.    Y = effect(EffectIndex).Y + (Cos(a) * effect(EffectIndex).Modifier)        '+ index / 20
  5740.  
  5741.  
  5742.     'Reset the particle
  5743.    effect(EffectIndex).Particles(Index).ResetIt X, Y, 0, 0, 0, 0
  5744.     effect(EffectIndex).Particles(Index).ResetColor 1, 0.2 + (Rnd * 0.3), 0.2, 0.6 + (Rnd * 0.4), 0.06 + (Rnd * 0.2)
  5745.  
  5746. End Sub
  5747.  
  5748. Private Sub Effect_Explode_Update(ByVal EffectIndex As Integer)
  5749.  
  5750.     Dim ElapsedTime As Single
  5751.     Dim LoopC As Long
  5752.  
  5753.     'Calculate The Time Difference
  5754.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  5755.     effect(EffectIndex).PreviousFrame = GetTickCount
  5756.  
  5757.     'Update the life span
  5758.    If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  5759.  
  5760.     effect(EffectIndex).Modifier = effect(EffectIndex).Modifier + 4
  5761.     'Go Through The Particle Loop
  5762.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  5763.  
  5764.         'Check If Particle Is In Use
  5765.        If effect(EffectIndex).Particles(LoopC).Used Then
  5766.  
  5767.             'Update The Particle
  5768.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  5769.  
  5770.             'Check if the particle is ready to die
  5771.            If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  5772.  
  5773.                 'Check if the effect is ending
  5774.                If effect(EffectIndex).Progression > 0 Then
  5775.  
  5776.                     'Reset the particle
  5777.                    Effect_Explode_Reset EffectIndex, LoopC
  5778.  
  5779.                 Else
  5780.  
  5781.                     'Disable the particle
  5782.                    effect(EffectIndex).Particles(LoopC).Used = False
  5783.  
  5784.                     'Subtract from the total particle count
  5785.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  5786.  
  5787.                     'Check if the effect is out of particles
  5788.                    If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  5789.  
  5790.                     'Clear the color (dont leave behind any artifacts)
  5791.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  5792.  
  5793.                 End If
  5794.  
  5795.             Else
  5796.  
  5797.                 'Set the particle information on the particle vertex
  5798.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  5799.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  5800.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  5801.  
  5802.             End If
  5803.  
  5804.         End If
  5805.  
  5806.     Next LoopC
  5807.  
  5808. End Sub
  5809.  
  5810. Function Effect_Misile_Begin(ByVal X As Single, ByVal Y As Single, ByVal Gfx As Integer, ByVal Particles As Integer, Optional ByVal Direction As Integer = 180) As Integer
  5811.     '*****************************************************************
  5812.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Begin
  5813.    '*****************************************************************
  5814.    Dim EffectIndex As Integer
  5815.     Dim LoopC As Long
  5816.  
  5817.     'Get the next open effect slot
  5818.    EffectIndex = Effect_NextOpenSlot
  5819.     If EffectIndex = -1 Then Exit Function
  5820.  
  5821.     'Return the index of the used slot
  5822.    Effect_Misile_Begin = EffectIndex
  5823.  
  5824.     'Set The Effect's Variables
  5825.    effect(EffectIndex).EffectNum = EffectNum_Misile        'Set the effect number
  5826.    effect(EffectIndex).ParticleCount = Particles - Particles * 0.25        'Set the number of particles
  5827.    effect(EffectIndex).Used = True        'Enabled the effect
  5828.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  5829.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  5830.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  5831.    effect(EffectIndex).Direction = Direction        'The direction the effect is animat
  5832.    effect(EffectIndex).Progression = -5000        'Loop the effect
  5833.  
  5834.     'Set the number of particles left to the total avaliable
  5835.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  5836.  
  5837.     'Set the float variables
  5838.    effect(EffectIndex).FloatSize = Effect_FToDW(15)        'Size of the particles
  5839.  
  5840.     'Redim the number of particles
  5841.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  5842.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  5843.  
  5844.     'Create the particles
  5845.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  5846.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  5847.         effect(EffectIndex).Particles(LoopC).Used = True
  5848.        
  5849.         'Effect_Misile_Reset EffectIndex, LoopC
  5850.    Next LoopC
  5851.  
  5852.     'Set The Initial Time
  5853.    effect(EffectIndex).PreviousFrame = GetTickCount
  5854.  
  5855. End Function
  5856.  
  5857. Public Function Engine_RectDistance(ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal MaxXDist As Long, ByVal MaxYDist As Long) As Byte
  5858.     '*****************************************************************
  5859.    'Check if two tile points are in the same area
  5860.    'More info: http://www.vbgore.com/GameClient.TileEngine.Engine_RectDistance
  5861.    '*****************************************************************
  5862.  
  5863.     If Abs(X1 - X2) < MaxXDist + 1 Then
  5864.         If Abs(Y1 - Y2) < MaxYDist + 1 Then
  5865.             Engine_RectDistance = True
  5866.         End If
  5867.     End If
  5868.  
  5869. End Function
  5870.  
  5871. Private Sub Effect_Misile_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  5872.     '*****************************************************************
  5873.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Reset
  5874.    '*****************************************************************
  5875.    Dim Color As Single
  5876.     Color = (Rnd * 0.4)
  5877.     If effect(EffectIndex).TargetAA = 0 Then effect(EffectIndex).TargetAA = Engine_GetAngle(effect(EffectIndex).X, effect(EffectIndex).Y, effect(EffectIndex).GoToX, effect(EffectIndex).GoToY)
  5878.     'Reset the particle
  5879.    effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X - 10 + Rnd * 20, effect(EffectIndex).Y - 10 + Rnd * 20, -Sin((effect(EffectIndex).TargetAA + (Rnd * 50) - 35) * DegreeToRadian) * 8, Cos((effect(EffectIndex).TargetAA + (Rnd * 50) - 35) * DegreeToRadian) * 8, 0, 0
  5880.     effect(EffectIndex).Particles(Index).ResetColor 0.5 + Color, 0.5 + Color, 0.5 + Color, 0.4 + (Rnd * 0.2), 0.2 + (Rnd * 0.07)
  5881.  
  5882. End Sub
  5883.  
  5884. Private Sub Effect_Misile_Update(ByVal EffectIndex As Integer)
  5885.     '*****************************************************************
  5886.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Update
  5887.    '*****************************************************************
  5888.    Dim ElapsedTime As Single
  5889.     Dim LoopC As Long
  5890.  
  5891.     'Calculate The Time Difference
  5892.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  5893.     effect(EffectIndex).PreviousFrame = GetTickCount
  5894.  
  5895.     'Update the life span
  5896.    If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  5897.  
  5898.     'Go Through The Particle Loop
  5899.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  5900.  
  5901.         'Check If Particle Is In Use
  5902.        If effect(EffectIndex).Particles(LoopC).Used Then
  5903.  
  5904.             'Update The Particle
  5905.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  5906.  
  5907.             'Check if the particle is ready to die
  5908.            If effect(EffectIndex).Particles(LoopC).SngA <= 0 Or Not Engine_RectDistance(effect(EffectIndex).X, effect(EffectIndex).Y, effect(EffectIndex).Particles(LoopC).sngX, effect(EffectIndex).Particles(LoopC).sngY, 32, 32) Then
  5909.  
  5910.                 'Check if the effect is ending
  5911.                If effect(EffectIndex).Progression > 0 Or effect(EffectIndex).Progression = -5000 Then
  5912.  
  5913.                     'Reset the particle
  5914.                    Effect_Misile_Reset EffectIndex, LoopC
  5915.  
  5916.                 Else
  5917.  
  5918.                     'Disable the particle
  5919.                    effect(EffectIndex).Particles(LoopC).Used = False
  5920.  
  5921.                     'Subtract from the total particle count
  5922.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  5923.  
  5924.                     'Check if the effect is out of particles
  5925.                    If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  5926.  
  5927.                     'Clear the color (dont leave behind any artifacts)
  5928.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  5929.  
  5930.                 End If
  5931.  
  5932.             Else
  5933.  
  5934.                 'Set the particle information on the particle vertex
  5935.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  5936.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  5937.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  5938.  
  5939.             End If
  5940.  
  5941.         End If
  5942.  
  5943.     Next LoopC
  5944.  
  5945. End Sub
  5946.  
  5947. Function Effect_Holy_Begin(ByVal X As Single, ByVal Y As Single, ByVal Gfx As Integer, ByVal Particles As Integer, Optional ByVal Direction As Integer = 180, Optional ByVal Progression As Single = 1) As Integer
  5948.     '*****************************************************************
  5949.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Begin
  5950.    '*****************************************************************
  5951.    Dim EffectIndex As Integer
  5952.     Dim LoopC As Long
  5953.  
  5954.     'Get the next open effect slot
  5955.    EffectIndex = Effect_NextOpenSlot
  5956.     If EffectIndex = -1 Then Exit Function
  5957.  
  5958.     'Return the index of the used slot
  5959.    Effect_Holy_Begin = EffectIndex
  5960.  
  5961.     'Set The Effect's Variables
  5962.    effect(EffectIndex).EffectNum = EffectNum_Holy        'Set the effect number
  5963.    effect(EffectIndex).ParticleCount = Particles - Particles * 0.25        'Set the number of particles
  5964.    effect(EffectIndex).Used = True        'Enabled the effect
  5965.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  5966.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  5967.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  5968.    effect(EffectIndex).Direction = Direction        'The direction the effect is animat
  5969.    effect(EffectIndex).Progression = Progression        'Loop the effect
  5970.  
  5971.     'Set the number of particles left to the total avaliable
  5972.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  5973.  
  5974.     'Set the float variables
  5975.    effect(EffectIndex).FloatSize = Effect_FToDW(24)        'Size of the particles
  5976.  
  5977.     'Redim the number of particles
  5978.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  5979.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  5980.  
  5981.     'Create the particles
  5982.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  5983.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  5984.         effect(EffectIndex).Particles(LoopC).Used = True
  5985.        
  5986.         Effect_Holy_Reset EffectIndex, LoopC
  5987.     Next LoopC
  5988.  
  5989.     'Set The Initial Time
  5990.    effect(EffectIndex).PreviousFrame = GetTickCount
  5991.  
  5992. End Function
  5993.  
  5994. Private Sub Effect_Holy_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  5995.     '*****************************************************************
  5996.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Reset
  5997.    '*****************************************************************
  5998.    Dim V As Integer
  5999.     V = RandomNumber(1, 4)
  6000.     'Reset the particle
  6001.    Select Case V
  6002.         Case 1
  6003.             effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X, effect(EffectIndex).Y, 2 + Rnd * 1, 0, 0, 0, effect(EffectIndex).X, effect(EffectIndex).Y
  6004.         Case 2
  6005.             effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X, effect(EffectIndex).Y, 0, 2 + Rnd * 1, 0, 0, effect(EffectIndex).X, effect(EffectIndex).Y
  6006.         Case 3
  6007.             effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X, effect(EffectIndex).Y, -2 - Rnd * 1, 0, 0, 0, effect(EffectIndex).X, effect(EffectIndex).Y
  6008.         Case 4
  6009.             effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X, effect(EffectIndex).Y, 0, -2 - Rnd * 1, 0, 0, effect(EffectIndex).X, effect(EffectIndex).Y
  6010.     End Select
  6011.  
  6012.     effect(EffectIndex).Particles(Index).ResetColor 0.8 + Rnd * 0.1, 0.8 + Rnd * 0.1, 0.6 + (Rnd * 0.2), 0.6 + (Rnd * 0.2), 0.02 + (Rnd * 0.07)
  6013.  
  6014. End Sub
  6015.  
  6016. Private Sub Effect_Holy_Update(ByVal EffectIndex As Integer)
  6017.     '*****************************************************************
  6018.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Update
  6019.    '*****************************************************************
  6020.    Dim ElapsedTime As Single
  6021.     Dim LoopC As Long
  6022.  
  6023.     'Calculate The Time Difference
  6024.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  6025.     effect(EffectIndex).PreviousFrame = GetTickCount
  6026.  
  6027.     'Update the life span
  6028.    If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  6029.  
  6030.     'Go Through The Particle Loop
  6031.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  6032.  
  6033.         'Check If Particle Is In Use
  6034.        If effect(EffectIndex).Particles(LoopC).Used Then
  6035.  
  6036.             'Update The Particle
  6037.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  6038.  
  6039.             'Check if the particle is ready to die
  6040.            If effect(EffectIndex).Particles(LoopC).SngA <= 0.3 Then        'Or Effect(EffectIndex).Particles(LoopC).sngY + 40 < Effect(EffectIndex).y Or Effect(EffectIndex).Particles(LoopC).sngY - 40 > Effect(EffectIndex).y Or Effect(EffectIndex).Particles(LoopC).sngX - 40 > Effect(EffectIndex).x Or Effect(EffectIndex).Particles(LoopC).sngX + 40 < Effect(EffectIndex).x Then
  6041.  
  6042.                 'Check if the effect is ending
  6043.                If effect(EffectIndex).Progression > 0 Or effect(EffectIndex).Progression = -5000 Then
  6044.  
  6045.  
  6046.                     'Reset the particle
  6047.                    Effect_Holy_Reset EffectIndex, LoopC
  6048.  
  6049.                 Else
  6050.  
  6051.                     'Disable the particle
  6052.                    effect(EffectIndex).Particles(LoopC).Used = False
  6053.  
  6054.                     'Subtract from the total particle count
  6055.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  6056.  
  6057.                     'Check if the effect is out of particles
  6058.                    If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  6059.  
  6060.                     'Clear the color (dont leave behind any artifacts)
  6061.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  6062.  
  6063.                 End If
  6064.  
  6065.             Else
  6066.  
  6067.                 'Set the particle information on the particle vertex
  6068.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  6069.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  6070.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  6071.  
  6072.             End If
  6073.  
  6074.         End If
  6075.  
  6076.     Next LoopC
  6077.  
  6078. End Sub
  6079. Function Effect_Spell_Begin(ByVal X As Single, ByVal Y As Single, ByVal Gfx As Integer, ByVal Particles As Integer, Optional SizeP As Single = 4, Optional size As Byte = 10, Optional R As Single = 1, Optional g As Single = 1, Optional b As Single = 1, Optional ByVal Direction As Integer = 180, Optional ByVal Progression As Single = 1, Optional Ray As Byte = 5, Optional a As Single = 4.09) As Integer
  6080.     '*****************************************************************
  6081.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Begin
  6082.    '*****************************************************************
  6083.    Dim EffectIndex As Integer
  6084.     Dim LoopC As Long
  6085.  
  6086.     'Get the next open effect slot
  6087.    EffectIndex = Effect_NextOpenSlot
  6088.     If EffectIndex = -1 Then Exit Function
  6089.  
  6090.     'Return the index of the used slot
  6091.    Effect_Spell_Begin = EffectIndex
  6092.  
  6093.     'Set The Effect's Variables
  6094.    effect(EffectIndex).EffectNum = EffectNum_Spell        'Set the effect number
  6095.    effect(EffectIndex).ParticleCount = Particles - Particles * 0.25        'Set the number of particles
  6096.    effect(EffectIndex).Used = True        'Enabled the effect
  6097.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  6098.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  6099.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  6100.    effect(EffectIndex).Direction = Direction        'The direction the effect is animat
  6101.    effect(EffectIndex).Progression = Progression        'Loop the effect
  6102.  
  6103.     effect(EffectIndex).R = R
  6104.     effect(EffectIndex).g = g
  6105.     effect(EffectIndex).b = b
  6106.     effect(EffectIndex).size = size
  6107.     effect(EffectIndex).Ray = Ray
  6108.     effect(EffectIndex).SizeP = SizeP
  6109.  
  6110.     'Set the number of particles left to the total avaliable
  6111.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  6112.  
  6113.     'Set the float variables
  6114.    effect(EffectIndex).FloatSize = Effect_FToDW(SizeP)        'Size of the particles
  6115.  
  6116.     'Redim the number of particles
  6117.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  6118.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  6119.  
  6120.     'Create the particles
  6121.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  6122.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  6123.         effect(EffectIndex).Particles(LoopC).Used = True
  6124.        
  6125.         Effect_Spell_Reset EffectIndex, LoopC, size, R, g, b, a
  6126.     Next LoopC
  6127.  
  6128.     'Set The Initial Time
  6129.    effect(EffectIndex).PreviousFrame = GetTickCount
  6130.  
  6131. End Function
  6132.  
  6133. Private Sub Effect_Spell_Reset(ByVal EffectIndex As Integer, ByVal Index As Long, ByVal size As Byte, ByVal R As Single, ByVal g As Single, ByVal b As Single, a As Single)
  6134.     '*****************************************************************
  6135.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Reset
  6136.    '*****************************************************************
  6137.  
  6138.     'Reset the particle
  6139.    effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X - 10 + Rnd * size, effect(EffectIndex).Y - 10 + Rnd * size, Rnd * 0 * RandomNumber(-1, 1), Rnd * 0 * RandomNumber(-1, 1), 0, 0
  6140.     effect(EffectIndex).Particles(Index).ResetColor R / 2 + (R / 2 * Rnd), g / 2 + (g / 2 * Rnd), b / 2 + (b / 2 * Rnd), 0.8 + (Rnd * 0.2), 0.1 + (Rnd * a)
  6141.  
  6142. End Sub
  6143.  
  6144. Private Sub Effect_Spell_Update(ByVal EffectIndex As Integer)
  6145.     '*****************************************************************
  6146.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Update
  6147.    '*****************************************************************
  6148.    Dim ElapsedTime As Single
  6149.     Dim LoopC As Long
  6150.  
  6151.     'Calculate The Time Difference
  6152.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  6153.     effect(EffectIndex).PreviousFrame = GetTickCount
  6154.  
  6155.     'Update the life span
  6156.    If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  6157.  
  6158.     'Go Through The Particle Loop
  6159.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  6160.  
  6161.         'Check If Particle Is In Use
  6162.        If effect(EffectIndex).Particles(LoopC).Used Then
  6163.  
  6164.             'Update The Particle
  6165.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  6166.  
  6167.             'Check if the particle is ready to die
  6168.            If effect(EffectIndex).Particles(LoopC).SngA <= 0.3 And RandomNumber(1, effect(EffectIndex).Ray) = 1 Then
  6169.  
  6170.                 'Check if the effect is ending
  6171.                If effect(EffectIndex).Progression > 0 Then        'Or Effect(EffectIndex).Progression = -5000 Then
  6172.  
  6173.  
  6174.                     'Reset the particle
  6175.                    Effect_Spell_Reset EffectIndex, LoopC, effect(EffectIndex).size, effect(EffectIndex).R, effect(EffectIndex).g, effect(EffectIndex).b, effect(EffectIndex).a
  6176.  
  6177.                 Else
  6178.  
  6179.                     'Disable the particle
  6180.                    effect(EffectIndex).Particles(LoopC).Used = False
  6181.  
  6182.                     'Subtract from the total particle count
  6183.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  6184.  
  6185.                     'Check if the effect is out of particles
  6186.                    If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  6187.  
  6188.                     'Clear the color (dont leave behind any artifacts)
  6189.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  6190.  
  6191.                 End If
  6192.  
  6193.             Else
  6194.  
  6195.                 'Set the particle information on the particle vertex
  6196.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  6197.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  6198.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  6199.  
  6200.             End If
  6201.  
  6202.         End If
  6203.  
  6204.     Next LoopC
  6205.  
  6206. End Sub
  6207.  
  6208. Function Effect_Necro_Begin(ByVal X As Single, ByVal Y As Single, ByVal Gfx As Integer, ByVal Particles As Integer, Optional ByVal Direction As Integer = 180, Optional ByVal Progression As Single = 1) As Integer
  6209.     '*****************************************************************
  6210.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Begin
  6211.    '*****************************************************************
  6212.    Dim EffectIndex As Integer
  6213.     Dim LoopC As Long
  6214.  
  6215.     'Get the next open effect slot
  6216.    EffectIndex = Effect_NextOpenSlot
  6217.     If EffectIndex = -1 Then Exit Function
  6218.  
  6219.     'Return the index of the used slot
  6220.    Effect_Necro_Begin = EffectIndex
  6221.  
  6222.     'Set The Effect's Variables
  6223.    effect(EffectIndex).EffectNum = EffectNum_Necro        'Set the effect number
  6224.    effect(EffectIndex).ParticleCount = Particles - Particles * 0.25        'Set the number of particles
  6225.    effect(EffectIndex).Used = True        'Enabled the effect
  6226.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  6227.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  6228.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  6229.    effect(EffectIndex).Direction = Direction        'The direction the effect is animat
  6230.    effect(EffectIndex).Progression = Progression        'Loop the effect
  6231.  
  6232.     'Set the number of particles left to the total avaliable
  6233.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  6234.  
  6235.     'Set the float variables
  6236.    effect(EffectIndex).FloatSize = Effect_FToDW(16)        'Size of the particles
  6237.  
  6238.     'Redim the number of particles
  6239.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  6240.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  6241.     effect(EffectIndex).TargetAA = 0
  6242.     'Create the particles
  6243.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  6244.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  6245.         effect(EffectIndex).Particles(LoopC).Used = True
  6246.        
  6247.         'Effect_Necro_Reset EffectIndex, LoopC
  6248.    Next LoopC
  6249.  
  6250.     'Set The Initial Time
  6251.    effect(EffectIndex).PreviousFrame = GetTickCount
  6252.  
  6253. End Function
  6254.  
  6255. Private Sub Effect_Necro_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  6256.  
  6257.     'Static TargetA As Single
  6258.    Dim Co As Single
  6259.     Dim Si As Single
  6260.     'Calculate the angle
  6261.  
  6262.     If effect(EffectIndex).TargetAA = 0 And effect(EffectIndex).GoToX <> -30000 Then effect(EffectIndex).TargetAA = Engine_GetAngle(effect(EffectIndex).X, effect(EffectIndex).Y, effect(EffectIndex).GoToX, effect(EffectIndex).GoToY) + 180
  6263.  
  6264.     Si = Sin(effect(EffectIndex).TargetAA * DegreeToRadian)
  6265.     Co = Cos(effect(EffectIndex).TargetAA * DegreeToRadian)
  6266.  
  6267.     'Reset the particle
  6268.    If RandomNumber(1, 2) = 2 Then
  6269.         'Effect(EffectIndex).Particles(index).ResetIt Effect(EffectIndex).x, Effect(EffectIndex).y, Co * Sin(Effect(EffectIndex).Progression * 3) * 20, Si * Sin(Effect(EffectIndex).Progression * 3) * 20, 0, 0
  6270.        effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + Co * Sin(effect(EffectIndex).Progression) * 25, effect(EffectIndex).Y + Si * Sin(effect(EffectIndex).Progression) * 25, 0, 0, 0, 0
  6271.         effect(EffectIndex).Particles(Index).ResetColor 0.2, 0.2 + (Rnd * 0.5), 1, 0.5 + (Rnd * 0.2), 0.1 + (Rnd * 4.09)
  6272.     Else
  6273.         'Effect(EffectIndex).Particles(index).ResetIt Effect(EffectIndex).x, Effect(EffectIndex).y, Co * Sin(Effect(EffectIndex).Progression * 3) * -20, Si * Sin(Effect(EffectIndex).Progression * 3) * -20, 0, 0
  6274.        effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + Co * Sin(effect(EffectIndex).Progression) * -25, effect(EffectIndex).Y + Si * Sin(effect(EffectIndex).Progression) * -25, 0, 0, 0, 0
  6275.         effect(EffectIndex).Particles(Index).ResetColor 1, 0.2 + (Rnd * 0.5), 0.2, 0.7 + (Rnd * 0.2), 0.1 + (Rnd * 4.09)
  6276.     End If
  6277.  
  6278.  
  6279. End Sub
  6280.  
  6281. Private Sub Effect_Necro_Update(ByVal EffectIndex As Integer)
  6282.     '*****************************************************************
  6283.    'More info: http://www.vbgore.com/CommonCode.Particles.Effect_Fire_Update
  6284.    '*****************************************************************
  6285.    Dim ElapsedTime As Single
  6286.     Dim LoopC As Long
  6287.  
  6288.     'Calculate The Time Difference
  6289.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  6290.     effect(EffectIndex).PreviousFrame = GetTickCount
  6291.  
  6292.     'Update the life span
  6293.    If effect(EffectIndex).Progression > 0 Then effect(EffectIndex).Progression = effect(EffectIndex).Progression - ElapsedTime
  6294.  
  6295.     'Go Through The Particle Loop
  6296.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  6297.  
  6298.         'Check If Particle Is In Use
  6299.        If effect(EffectIndex).Particles(LoopC).Used Then
  6300.  
  6301.             'Update The Particle
  6302.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  6303.  
  6304.             'Check if the particle is ready to die
  6305.            If effect(EffectIndex).Particles(LoopC).SngA <= 0.5 And RandomNumber(1, 3) = 3 Then
  6306.  
  6307.                 'Check if the effect is ending
  6308.                If effect(EffectIndex).Progression > 0 Or effect(EffectIndex).Progression = -5000 Then
  6309.  
  6310.  
  6311.                     'Reset the particle
  6312.                    Effect_Necro_Reset EffectIndex, LoopC
  6313.  
  6314.                 Else
  6315.  
  6316.                     'Disable the particle
  6317.                    effect(EffectIndex).Particles(LoopC).Used = False
  6318.  
  6319.                     'Subtract from the total particle count
  6320.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  6321.  
  6322.                     'Check if the effect is out of particles
  6323.                    If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  6324.  
  6325.                     'Clear the color (dont leave behind any artifacts)
  6326.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  6327.  
  6328.                 End If
  6329.  
  6330.             Else
  6331.  
  6332.                 'Set the particle information on the particle vertex
  6333.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  6334.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  6335.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  6336.  
  6337.             End If
  6338.  
  6339.         End If
  6340.  
  6341.     Next LoopC
  6342.  
  6343. End Sub
  6344.  
  6345. Function Effect_LissajousTrip_Begin(ByVal X As Single, _
  6346.                                     ByVal Y As Single, _
  6347.                                     ByVal Gfx As Integer, _
  6348.                                     ByVal Particles As Integer, _
  6349.                                     Optional ByVal Progression As Single = 0) As Integer
  6350.  
  6351.     '*****************************************************************
  6352.    'More info: [url=http://www.vbgore.com/CommonCode.Particles.Effect_LissajousTrip_Begin]http://www.vbgore.com/CommonCode.Partic ... Trip_Begin[/url]
  6353.    '*****************************************************************
  6354.  
  6355.     Dim EffectIndex As Integer
  6356.     Dim LoopC As Long
  6357.  
  6358.     'Get the next open effect slot
  6359.    EffectIndex = Effect_NextOpenSlot
  6360.  
  6361.     If EffectIndex = -1 Then Exit Function
  6362.  
  6363.     'Return the index of the used slot
  6364.    Effect_LissajousTrip_Begin = EffectIndex
  6365.  
  6366.     'Set The Effect's Variables
  6367.    effect(EffectIndex).EffectNum = EffectNum_LissajousTrip        'Set the effect number
  6368.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  6369.    effect(EffectIndex).Used = True        'Enable the effect
  6370.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  6371.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  6372.    effect(EffectIndex).Gfx = Gfx        'Set the graphic
  6373.    effect(EffectIndex).Progression = Progression
  6374.     effect(EffectIndex).KillWhenAtTarget = True        'End the effect when it reaches the target (progression = 0)
  6375.    effect(EffectIndex).KillWhenTargetLost = True        'End the effect if the target is lost (progression = 0)
  6376.  
  6377.     'Set the number of particles left to the total avaliable
  6378.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  6379.  
  6380.     'Set the float variables
  6381.    effect(EffectIndex).FloatSize = Effect_FToDW(8)        'Size of the particles
  6382.  
  6383.     'Redim the number of particles
  6384.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  6385.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  6386.  
  6387.     'Create the particles
  6388.  
  6389.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  6390.  
  6391.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  6392.         effect(EffectIndex).Particles(LoopC).Used = True
  6393.        
  6394.         Effect_LissajousTrip_Reset EffectIndex, LoopC
  6395.  
  6396.     Next LoopC
  6397.  
  6398.     'Set The Initial Time
  6399.    effect(EffectIndex).PreviousFrame = GetTickCount
  6400.  
  6401. End Function
  6402.  
  6403. Private Sub Effect_LissajousTrip_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  6404.  
  6405.     '*****************************************************************
  6406.    'More info: [url=http://www.vbgore.com/CommonCode.Particles.Effect_LissajousTrip_Reset]http://www.vbgore.com/CommonCode.Partic ... Trip_Reset[/url]
  6407.    '*****************************************************************
  6408.  
  6409.     Dim X As Single
  6410.     Dim Y As Single
  6411.     Dim a As Single
  6412.  
  6413.     effect(EffectIndex).Progression = effect(EffectIndex).Progression + 0.01
  6414.  
  6415.     a = effect(EffectIndex).Progression
  6416.  
  6417.     If RandomNumber(1, 2) = 1 Then
  6418.         X = effect(EffectIndex).X - (Sin(a)) * 120
  6419.         Y = effect(EffectIndex).Y + Cos(5 * a) * 20        'The 40s state the radius of circle
  6420.        effect(EffectIndex).Particles(Index).ResetIt X, Y, 0, 0, 0, 0
  6421.         effect(EffectIndex).Particles(Index).ResetColor 0.1 * (Rnd * 0.5), 0.1 * (Rnd * 0.5), 0.1 * (Rnd * 0.5), 1, 0.2 + (Rnd * 0.2)
  6422.     Else
  6423.         X = effect(EffectIndex).X - (Sin(a)) * 120
  6424.         Y = effect(EffectIndex).Y - Cos(5 * a) * 20        'The 40s state the radius of circle
  6425.        effect(EffectIndex).Particles(Index).ResetIt X, Y, 0, 0, 0, 0
  6426.         effect(EffectIndex).Particles(Index).ResetColor 0.05 * (Rnd * 0.5), 0.05 * (Rnd * 0.5), 0.05 * (Rnd * 0.5), 1, 0.2 + (Rnd * 0.2)
  6427.     End If
  6428.  
  6429. End Sub
  6430.  
  6431. Private Sub Effect_LissajousTrip_Update(ByVal EffectIndex As Integer)
  6432.  
  6433.     '*****************************************************************
  6434.    'More info: [url=http://www.vbgore.com/CommonCode.Particles.Effect_LissajousTrip_Update]http://www.vbgore.com/CommonCode.Partic ... rip_Update[/url]
  6435.    '*****************************************************************
  6436.  
  6437.     Dim ElapsedTime As Single
  6438.     Dim LoopC As Long
  6439.  
  6440.     'Calculate The Time Difference
  6441.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  6442.     effect(EffectIndex).PreviousFrame = GetTickCount
  6443.  
  6444.     'Go Through The Particle Loop
  6445.    For LoopC = 0 To effect(EffectIndex).ParticleCount
  6446.  
  6447.         'Check If Particle Is In Use
  6448.        If effect(EffectIndex).Particles(LoopC).Used Then
  6449.  
  6450.             'Update The Particle
  6451.            effect(EffectIndex).Particles(LoopC).UpdateParticle ElapsedTime
  6452.  
  6453.             'Check if the particle is ready to die
  6454.            If effect(EffectIndex).Particles(LoopC).SngA <= 0 Then
  6455.  
  6456.                 'Check if the effect is ending
  6457.                If effect(EffectIndex).Progression > 0 Then
  6458.  
  6459.                     'Reset the particle
  6460.                    Effect_LissajousTrip_Reset EffectIndex, LoopC
  6461.                 Else
  6462.                     'Disable the particle
  6463.                    effect(EffectIndex).Particles(LoopC).Used = False
  6464.  
  6465.                     'Subtract from the total particle count
  6466.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  6467.  
  6468.                     'Check if the effect is out of particles
  6469.                    If effect(EffectIndex).ParticlesLeft = 0 Then effect(EffectIndex).Used = False
  6470.  
  6471.                     'Clear the color (dont leave behind any artifacts)
  6472.                    effect(EffectIndex).PartVertex(LoopC).Colour = 0
  6473.  
  6474.                 End If
  6475.  
  6476.             Else
  6477.                 'Set the particle information on the particle vertex
  6478.                effect(EffectIndex).PartVertex(LoopC).Colour = D3DColorMake(effect(EffectIndex).Particles(LoopC).SngR, effect(EffectIndex).Particles(LoopC).SngG, effect(EffectIndex).Particles(LoopC).SngB, effect(EffectIndex).Particles(LoopC).SngA)
  6479.                 effect(EffectIndex).PartVertex(LoopC).X = effect(EffectIndex).Particles(LoopC).sngX
  6480.                 effect(EffectIndex).PartVertex(LoopC).Y = effect(EffectIndex).Particles(LoopC).sngY
  6481.  
  6482.             End If
  6483.  
  6484.         End If
  6485.  
  6486.     Next LoopC
  6487.  
  6488. End Sub
  6489.  
  6490. Sub Engine_Weather_Update()
  6491.     If bRain And CurMapAmbient.Rain Then
  6492.         If WeatherEffectIndex <= 0 Then
  6493.             WeatherEffectIndex = Effect_Rain_Begin(9, 100)
  6494.         ElseIf effect(WeatherEffectIndex).EffectNum <> EffectNum_Rain Then
  6495.             Effect_Kill WeatherEffectIndex
  6496.             WeatherEffectIndex = Effect_Rain_Begin(9, 100)
  6497.         ElseIf Not effect(WeatherEffectIndex).Used Then
  6498.             WeatherEffectIndex = Effect_Rain_Begin(9, 100)
  6499.         End If
  6500.     End If
  6501.  
  6502.     If CurMapAmbient.Snow Then
  6503.         If WeatherEffectIndex <= 0 Then
  6504.             WeatherEffectIndex = Effect_Snow_Begin(14, 200)
  6505.         ElseIf effect(WeatherEffectIndex).EffectNum <> EffectNum_Snow Then
  6506.             Effect_Kill WeatherEffectIndex
  6507.             WeatherEffectIndex = Effect_Snow_Begin(14, 200)
  6508.         ElseIf Not effect(WeatherEffectIndex).Used Then
  6509.             WeatherEffectIndex = Effect_Snow_Begin(14, 200)
  6510.         End If
  6511.     End If
  6512.  
  6513.     If CurMapAmbient.Fog <> -1 Then
  6514.         Engine_Weather_UpdateFog
  6515.     End If
  6516.  
  6517.     If OnRampageImgGrh <> 0 Then
  6518.         DDrawTransGrhIndextoSurface OnRampageImgGrh, 0, 0, 0, Normal_RGBList(), 0, True
  6519.     End If
  6520.  
  6521. End Sub
  6522.  
  6523. Sub Engine_Weather_UpdateFog()
  6524.     '*****************************************************************
  6525.    'Update the fog effects
  6526.    '*****************************************************************
  6527.  
  6528.     Dim i As Long
  6529.     Dim X As Long
  6530.     Dim Y As Long
  6531.     Dim CC(3) As Long
  6532.     Dim ElapsedTime As Single
  6533.     ElapsedTime = Engine_ElapsedTime
  6534.  
  6535.     If WeatherFogCount = 0 Then WeatherFogCount = 13
  6536.  
  6537.     WeatherFogX1 = WeatherFogX1 + (ElapsedTime * (0.018 + Rnd * 0.01)) + (LastOffsetX - ParticleOffsetX)
  6538.     WeatherFogY1 = WeatherFogY1 + (ElapsedTime * (0.013 + Rnd * 0.01)) + (LastOffsetY - ParticleOffsetY)
  6539.  
  6540.     Do While WeatherFogX1 < -512
  6541.         WeatherFogX1 = WeatherFogX1 + 512
  6542.     Loop
  6543.     Do While WeatherFogY1 < -512
  6544.         WeatherFogY1 = WeatherFogY1 + 512
  6545.     Loop
  6546.     Do While WeatherFogX1 > 0
  6547.         WeatherFogX1 = WeatherFogX1 - 512
  6548.     Loop
  6549.     Do While WeatherFogY1 > 0
  6550.         WeatherFogY1 = WeatherFogY1 - 512
  6551.     Loop
  6552.  
  6553.     WeatherFogX2 = WeatherFogX2 - (ElapsedTime * (0.037 + Rnd * 0.01)) + (LastOffsetX - ParticleOffsetX)
  6554.     WeatherFogY2 = WeatherFogY2 - (ElapsedTime * (0.021 + Rnd * 0.01)) + (LastOffsetY - ParticleOffsetY)
  6555.     Do While WeatherFogX2 < -512
  6556.         WeatherFogX2 = WeatherFogX2 + 512
  6557.     Loop
  6558.     Do While WeatherFogY2 < -512
  6559.         WeatherFogY2 = WeatherFogY2 + 512
  6560.     Loop
  6561.     Do While WeatherFogX2 > 0
  6562.         WeatherFogX2 = WeatherFogX2 - 512
  6563.     Loop
  6564.     Do While WeatherFogY2 > 0
  6565.         WeatherFogY2 = WeatherFogY2 - 512
  6566.     Loop
  6567.  
  6568.     'Render fog 2
  6569.    X = 2
  6570.     Y = -1
  6571.  
  6572.     CC(0) = D3DColorARGB(CurMapAmbient.Fog, 255, 255, 255)
  6573.     CC(1) = CC(0)
  6574.     CC(2) = CC(0)
  6575.     CC(3) = CC(0)
  6576.  
  6577.     For i = 1 To WeatherFogCount
  6578.         DDrawTransGrhIndextoSurface 27300, (X * 512) + WeatherFogX2, (Y * 512) + WeatherFogY2, 0, CC(), 0, False
  6579.         X = X + 1
  6580.         If X > (1 + (ScreenWidth \ 512)) Then
  6581.             X = 0
  6582.             Y = Y + 1
  6583.         End If
  6584.     Next i
  6585.  
  6586.     'Render fog 1
  6587.    X = 0
  6588.     Y = 0
  6589.  
  6590.     CC(0) = D3DColorARGB(CurMapAmbient.Fog / 2, 255, 255, 255)
  6591.     CC(1) = CC(0)
  6592.     CC(2) = CC(0)
  6593.     CC(3) = CC(0)
  6594.  
  6595.     For i = 1 To WeatherFogCount
  6596.         DDrawTransGrhIndextoSurface 27301, (X * 512) + WeatherFogX1, (Y * 512) + WeatherFogY1, 0, CC(), 0, False
  6597.         X = X + 1
  6598.         If X > (2 + (ScreenWidth \ 512)) Then
  6599.             X = 0
  6600.             Y = Y + 1
  6601.         End If
  6602.     Next i
  6603.  
  6604. End Sub
  6605.  
  6606. Function Effect_BloodSpray_Begin(ByVal X As Single, _
  6607.                                  ByVal Y As Single, _
  6608.                                  ByVal Particles As Integer, _
  6609.                                  ByVal Direction As Single, _
  6610.                                  Optional ByVal Intensity As Single = 1) As Integer
  6611.  
  6612.     Dim EffectIndex As Integer
  6613.     Dim LoopC As Long
  6614.  
  6615.     'Get the next open effect slot
  6616.    EffectIndex = Effect_NextOpenSlot
  6617.  
  6618.     If EffectIndex = -1 Then Exit Function
  6619.     'Return the index of the used slot
  6620.    Effect_BloodSpray_Begin = EffectIndex
  6621.     'Set the effect's variables
  6622.    effect(EffectIndex).EffectNum = EffectNum_BloodSpray        'Set the effect number
  6623.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  6624.    effect(EffectIndex).Used = True        'Enable the effect
  6625.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  6626.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  6627.    effect(EffectIndex).Direction = Direction        'Direction
  6628.    effect(EffectIndex).Modifier = Intensity
  6629.     'Set the number of particles left to the total avaliable
  6630.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  6631.     'Set the float variables
  6632.    effect(EffectIndex).FloatSize = Effect_FToDW(7)        'Size of the particles
  6633.    'Redim the number of particles
  6634.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  6635.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  6636.  
  6637.     'Create the particles
  6638.  
  6639.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  6640.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  6641.         effect(EffectIndex).Particles(LoopC).Used = True
  6642.        
  6643.         Effect_BloodSpray_Reset EffectIndex, LoopC
  6644.  
  6645.     Next LoopC
  6646.  
  6647.     'Set the initial time
  6648.    effect(EffectIndex).PreviousFrame = GetTickCount
  6649. End Function
  6650.  
  6651. Private Sub Effect_BloodSpray_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  6652.  
  6653.     'Reset the particle
  6654.  
  6655.     With effect(EffectIndex)
  6656.         .Particles(Index).ResetIt .X + (Rnd * 16) - 8, .Y + (Rnd * 32) - 16, Sin((.Direction - 10 + (Rnd * 20)) * DegreeToRadian) * (30 * .Modifier * Rnd), -Cos((.Direction - 10 + (Rnd * 20)) * DegreeToRadian) * (30 * .Modifier * Rnd), 0, 0, -10, -2 - (Rnd * 30), 8 + Rnd * 4
  6657.         .Particles(Index).ResetColor 1, 1, 1, 0.8, 0
  6658.     End With
  6659.  
  6660. End Sub
  6661.  
  6662. Private Sub Effect_BloodSpray_Update(ByVal EffectIndex As Integer)
  6663.  
  6664.     Dim ElapsedTime As Single
  6665.     Dim LoopC As Long
  6666.     Dim TileX As Long
  6667.     Dim TileY As Long
  6668.  
  6669.     'Calculate the time difference
  6670.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  6671.     effect(EffectIndex).PreviousFrame = GetTickCount
  6672.  
  6673.     'Go through the particle loop
  6674.  
  6675.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  6676.  
  6677.         With effect(EffectIndex).Particles(LoopC)
  6678.  
  6679.             'Check if particle is in Use
  6680.  
  6681.             If .Used Then
  6682.                 'Update the particle
  6683.                .UpdateParticle ElapsedTime
  6684.                 'Don't pass any walls/etc
  6685.                TileX = Engine_SPtoTPX(.sngX)
  6686.                 TileY = Engine_SPtoTPY(.sngY)
  6687.  
  6688.                 If TileX < 1 Then
  6689.                     .sngZ = 1.1
  6690.                 ElseIf TileY < 1 Then
  6691.                     .sngZ = 1.1
  6692.                 ElseIf TileX > 82 Then
  6693.                     .sngZ = 1.1
  6694.                 ElseIf TileY > 92 Then
  6695.                     .sngZ = 1.1
  6696.                 End If
  6697.  
  6698.                 If .sngZ <> 1.1 Then
  6699.                     'If MapData(TileX, TileY).BlockedAttack Then
  6700.                    '.sngZ = 1.1
  6701.                    'End If
  6702.                End If
  6703.  
  6704.                 'Blood trails
  6705.  
  6706.                 If LoopC = 0 Or LoopC Mod 15 = 0 Then
  6707.                     If Int(Rnd * 3) = 0 Then
  6708.                         If Int(Rnd * 2) = 0 Then
  6709.                             Engine_Blood_Create .sngX + ParticleOffsetX, .sngY + ParticleOffsetY, 2
  6710.                         Else
  6711.                             Engine_Blood_Create .sngX + ParticleOffsetX, .sngY + ParticleOffsetY, 1
  6712.                         End If
  6713.                     End If
  6714.                 End If
  6715.  
  6716.                 'Check if to kill off the particle
  6717.  
  6718.                 If .sngZ > 1 Then
  6719.                     'Disable the particle
  6720.                    .Used = False
  6721.                     'Subtract from the total particle count
  6722.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  6723.                     'Clear the color (dont leave behind any artifacts)
  6724.                    effect(EffectIndex).Particles(LoopC).SngA = 0
  6725.  
  6726.                     'Check if we lost all the particles
  6727.  
  6728.                     If effect(EffectIndex).ParticlesLeft <= 0 Then effect(EffectIndex).Used = False
  6729.                     'Create the blood splatter
  6730.                    Engine_Blood_Create .sngX + ParticleOffsetX, .sngY + ParticleOffsetY, 0
  6731.                 Else
  6732.                     'Set the particle information on the particle vertex
  6733.                    effect(EffectIndex).PartVertex(LoopC).Colour = 1258291200
  6734.                     effect(EffectIndex).PartVertex(LoopC).X = .sngX
  6735.                     effect(EffectIndex).PartVertex(LoopC).Y = .sngY
  6736.                 End If
  6737.             End If
  6738.  
  6739.         End With
  6740.  
  6741.     Next LoopC
  6742.  
  6743. End Sub
  6744.  
  6745. Function Effect_BloodSplatter_Begin(ByVal X As Single, _
  6746.                                     ByVal Y As Single, _
  6747.                                     ByVal Particles As Integer) As Integer
  6748.  
  6749.     Dim EffectIndex As Integer
  6750.     Dim LoopC As Long
  6751.  
  6752.     'Get the next open effect slot
  6753.    EffectIndex = Effect_NextOpenSlot
  6754.  
  6755.     If EffectIndex = -1 Then Exit Function
  6756.     'Return the index of the used slot
  6757.    Effect_BloodSplatter_Begin = EffectIndex
  6758.     'Set the effect's variables
  6759.    effect(EffectIndex).EffectNum = EffectNum_BloodSplatter        'Set the effect number
  6760.    effect(EffectIndex).ParticleCount = Particles        'Set the number of particles
  6761.    effect(EffectIndex).Used = True        'Enable the effect
  6762.    effect(EffectIndex).X = X        'Set the effect's X coordinate
  6763.    effect(EffectIndex).Y = Y        'Set the effect's Y coordinate
  6764.    'Set the number of particles left to the total avaliable
  6765.    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticleCount
  6766.     'Set the float variables
  6767.    effect(EffectIndex).FloatSize = Effect_FToDW(7)        'Size of the particles
  6768.    'Redim the number of particles
  6769.    ReDim effect(EffectIndex).Particles(0 To effect(EffectIndex).ParticleCount)
  6770.     ReDim effect(EffectIndex).PartVertex(0 To effect(EffectIndex).ParticleCount)
  6771.  
  6772.     'Create the particles
  6773.  
  6774.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  6775.         Set effect(EffectIndex).Particles(LoopC) = New Particle
  6776.         effect(EffectIndex).Particles(LoopC).Used = True
  6777.        
  6778.         Effect_BloodSplatter_Reset EffectIndex, LoopC
  6779.  
  6780.     Next LoopC
  6781.  
  6782.     'Set the initial time
  6783.    effect(EffectIndex).PreviousFrame = GetTickCount
  6784. End Function
  6785.  
  6786. Private Sub Effect_BloodSplatter_Reset(ByVal EffectIndex As Integer, ByVal Index As Long)
  6787.  
  6788.     Dim Direction As Single
  6789.  
  6790.     'Find the direction
  6791.    Direction = Rnd * 360
  6792.     'Reset the particle
  6793.    effect(EffectIndex).Particles(Index).ResetIt effect(EffectIndex).X + (Rnd * 16) - 8, effect(EffectIndex).Y + (Rnd * 32) - 16, Sin(Direction * DegreeToRadian) * (24 * Rnd), -Cos(Direction * DegreeToRadian) * (24 * Rnd), 0, 0, -25, -3 - (Rnd * 40), 10 + Rnd * 4
  6794.     effect(EffectIndex).Particles(Index).ResetColor 1, 0, 0, 0.8, 0
  6795. End Sub
  6796.  
  6797. Private Sub Effect_BloodSplatter_Update(ByVal EffectIndex As Integer)
  6798.  
  6799.     Dim ElapsedTime As Single
  6800.     Dim LoopC As Long
  6801.     Dim TileX As Long
  6802.     Dim TileY As Long
  6803.  
  6804.     'Calculate the time difference
  6805.    ElapsedTime = (GetTickCount - effect(EffectIndex).PreviousFrame) * 0.01
  6806.     effect(EffectIndex).PreviousFrame = GetTickCount
  6807.  
  6808.     'Go through the particle loop
  6809.  
  6810.     For LoopC = 0 To effect(EffectIndex).ParticleCount
  6811.  
  6812.         With effect(EffectIndex).Particles(LoopC)
  6813.  
  6814.             'Check if particle is in Use
  6815.  
  6816.             If .Used Then
  6817.                 'Update the particle
  6818.                .UpdateParticle ElapsedTime
  6819.                 'Don't pass any walls/etc
  6820.                TileX = Engine_SPtoTPX(.sngX)
  6821.                 TileY = Engine_SPtoTPY(.sngY)
  6822.  
  6823.                 If TileX < 1 Then
  6824.                     .sngZ = 1.1
  6825.                 ElseIf TileY < 1 Then
  6826.                     .sngZ = 1.1
  6827.                 ElseIf TileY > 92 Then
  6828.                     .sngZ = 1.1
  6829.                 ElseIf TileY > 82 Then
  6830.                     .sngZ = 1.1
  6831.                 End If
  6832.  
  6833.                 If .sngZ <> 1.1 Then
  6834.                     'If MapData(TileX, TileY).BlockedAttack Then
  6835.                    '.sngZ = 1.1
  6836.                    'End If
  6837.                End If
  6838.  
  6839.                 'Blood trails
  6840.  
  6841.                 If LoopC = 0 Or LoopC Mod 10 = 0 Then
  6842.                     If Int(Rnd * 3) = 0 Then
  6843.                         If Int(Rnd * 2) = 0 Then
  6844.                             Engine_Blood_Create .sngX + ParticleOffsetX, .sngY + ParticleOffsetY, 2
  6845.                         Else
  6846.                             Engine_Blood_Create .sngX + ParticleOffsetX, .sngY + ParticleOffsetY, 1
  6847.                         End If
  6848.                     End If
  6849.                 End If
  6850.  
  6851.                 'Check if to kill off the particle
  6852.  
  6853.                 If .sngZ > 1 Then
  6854.                     'Disable the particle
  6855.                    .Used = False
  6856.                     'Subtract from the total particle count
  6857.                    effect(EffectIndex).ParticlesLeft = effect(EffectIndex).ParticlesLeft - 1
  6858.                     'Clear the color (dont leave behind any artifacts)
  6859.                    effect(EffectIndex).Particles(LoopC).SngA = 0
  6860.  
  6861.                     'Check if we lost all the particles
  6862.  
  6863.                     If effect(EffectIndex).ParticlesLeft <= 0 Then effect(EffectIndex).Used = False
  6864.                     'Create the blood splatter
  6865.                    Engine_Blood_Create .sngX + ParticleOffsetX, .sngY + ParticleOffsetY, 0
  6866.                 Else
  6867.                     'Set the particle information on the particle vertex
  6868.                    effect(EffectIndex).PartVertex(LoopC).Colour = 1258291200
  6869.                     effect(EffectIndex).PartVertex(LoopC).X = .sngX
  6870.                     effect(EffectIndex).PartVertex(LoopC).Y = .sngY
  6871.                 End If
  6872.             End If
  6873.  
  6874.         End With
  6875.  
  6876.     Next LoopC
  6877.  
  6878. End Sub
  6879.  
  6880.  
  6881.  
  6882.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement