Spell Fire Boom

Joker(Div)

Always Here..
Reaction score
86
Fire Boom:
Shoots a fireball that explodes.

Credits, Import info, and Requirements are all in the map. The ability uses XE. I attached the XE documentation to those new to the system.

Screenies:
ss1b.jpg

ss2r.jpg

ss3lsq.jpg

Code:
JASS:
scope FireBoom initializer onInit
//By Joker(Div)
//Uses:
// - xebasic
// - xepreload
// - xefx
// - xedamage
// - xecollider
// - SpellEvent
// - BoundSentinel

    globals
        private constant integer ABILITY_ID = 'A000'
        private constant real MISSILE_OFFSET = 100.0
    
        private constant string PRIMARY_MISSILE             = "Abilities\\Weapons\\RedDragonBreath\\RedDragonMissile.mdl" 
        private constant real   PRIMARY_MISSILE_SCALE       = 1.5
        private constant real   PRIMARY_MISSILE_SPEED       = 750.0 
        private constant real   PRIMARY_MISSILE_ACCEL       = 125.0  
        private constant real   PRIMARY_MISSILE_MAX_SPEED   = 1000.0
        private constant real   PRIMARY_MISSILE_LIFE        = 2.0
        private constant real   PRIMARY_MISSILE_Z           = 85.0
        private constant real   PRIMARY_MISSILE_COLLISION   = 80.0
        
        
        private constant integer MAX_SECONDARY_MISSILE = 16
        
        private constant string SECONDARY_MISSILE           = "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile_mini.mdl"
        private constant real   SECONDARY_MISSILE_SCALE     = 0.75
        private constant real   SECONDARY_MISSILE_SPEED     = 750.0 
        private constant real   SECONDARY_MISSILE_ACCEL     = -350.0
        private constant real   SECONDARY_MISSILE_MAX_SPEED = 750.0
        private constant real   SECONDARY_MISSILE_LIFE      = 0.5
        private constant real   SECONDARY_MISSILE_Z         = 65.0
        private constant real   SECONDARY_MISSILE_COLLISION = 50.0
        
        private constant string IMPACT_EFFECT = "Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\NeutralBuildingExplosion.mdl"
    endglobals
    
    private function DamageSettings takes xedamage d returns nothing
        set d.dtype = DAMAGE_TYPE_FIRE   // Do spell, fire (magic) damage
        set d.atype = ATTACK_TYPE_NORMAL 

        call d.factor( UNIT_TYPE_STRUCTURE , 0.5) //half damage to buildings.
    
        set d.damageEnemies = true 
        set d.damageAllies  = false  
        set d.damageNeutral = true  
        set d.damageSelf    = false
    endfunction
    
    private constant function PrimaryDamage takes integer lvl returns real
        return (lvl * 100.0)
    endfunction
    
    private constant function SecondaryDamage takes integer lvl returns real
        return (lvl * 50.0)
    endfunction
    //============================================================
    
    globals
        private xedamage DamageConfig
        private constant real TWO_PI = 6.28212
    endglobals
    
    private struct MiniFire extends xecollider
        unit cast
        integer level 

        private method onUnitHit takes unit target returns nothing
            if DamageConfig.allowedTarget( this.cast, target ) then
                call DamageConfig.damageTarget( this.cast, target, SecondaryDamage(this.level) )
            endif
        endmethod
    endstruct

    private struct Fire extends xecollider
       unit cast
       unit target
       boolean hit
       integer level    
       
        delegate xefx fx //so that I can change the scale
       
        private method onDestroy takes nothing returns nothing
          local real rad = 0
          local real incre = TWO_PI/MAX_SECONDARY_MISSILE

          local real x = GetUnitX( this.target )
          local real y = GetUnitY( this.target )
        
          local MiniFire mfire = 0
          
            if this.hit then
                set this.hit = false
                loop
                    exitwhen rad > TWO_PI
                      set mfire = MiniFire.create( x, y, rad )
                        set mfire.fxpath         = SECONDARY_MISSILE
                        set mfire.speed          = SECONDARY_MISSILE_SPEED
                        set mfire.acceleration   = SECONDARY_MISSILE_ACCEL
                        set mfire.maxSpeed       = SECONDARY_MISSILE_MAX_SPEED
                        set mfire.z              = SECONDARY_MISSILE_Z
                        set mfire.expirationTime = SECONDARY_MISSILE_LIFE
                        set mfire.cast           = this.cast 
                        set mfire.level          = GetUnitAbilityLevel( this.cast, ABILITY_ID)
                        set mfire.scale          = SECONDARY_MISSILE_SCALE
                        set mfire.collisionSize  = SECONDARY_MISSILE_COLLISION
                      set rad = rad + incre
                endloop
            endif
        endmethod

        private method onUnitHit takes unit target returns nothing
            if DamageConfig.allowedTarget( this.cast, target ) then
                set this.target = target
                set this.hit = true //so that the minifire doesn't run if it doesn't collide with a unit
                
                call DestroyEffect( AddSpecialEffect( IMPACT_EFFECT, GetUnitX( target ), GetUnitY( target ) ) )
                call DamageConfig.damageTarget( this.cast, target, PrimaryDamage(this.level) )
                call this.terminate()
            endif
        endmethod
    endstruct
    //============================================================
    
    private function onCast takes nothing returns nothing
      local unit cast = SpellEvent.CastingUnit
      local real x = GetUnitX( cast )
      local real y = GetUnitY( cast )
      local real angle = Atan2( SpellEvent.TargetY - y, SpellEvent.TargetX - x )
      local Fire fire = Fire.create( x + MISSILE_OFFSET * Cos(angle), y + MISSILE_OFFSET * Sin(angle), angle )
      
        set fire.fxpath         = PRIMARY_MISSILE
        set fire.speed          = PRIMARY_MISSILE_SPEED
        set fire.acceleration   = PRIMARY_MISSILE_ACCEL
        set fire.maxSpeed       = PRIMARY_MISSILE_MAX_SPEED
        set fire.z              = PRIMARY_MISSILE_Z
        set fire.expirationTime = PRIMARY_MISSILE_LIFE
        set fire.cast           = cast 
        set fire.level          = GetUnitAbilityLevel( cast, ABILITY_ID )
        set fire.scale          = PRIMARY_MISSILE_SCALE
        set fire.collisionSize  = PRIMARY_MISSILE_COLLISION
         
      set cast = null
    endfunction
    
    private function onInit takes nothing returns nothing
        set DamageConfig = xedamage.create()    
        call DamageSettings( DamageConfig ) 
        
        call Preload( PRIMARY_MISSILE )
        call Preload( SECONDARY_MISSILE )
        call Preload( IMPACT_EFFECT )
        call XE_PreloadAbility( ABILITY_ID )
        call RegisterSpellEffectResponse( ABILITY_ID, onCast )
    endfunction

endscope
 

Attachments

  • Joker(Div) - FireBoom.w3x
    129.4 KB · Views: 219
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top