1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. The poll for our 11th Music Contest is up! Help us choose the most awesome cinematic tracks by casting a vote!
    Dismiss Notice
  3. Melee Mapping contest #3 - Poll is up! Vote for the best 4v4 melee maps!
    Dismiss Notice
  4. The 30th edition of the Modeling Contest is finally up! The Portable Buildings need your attention, so come along and have a blast!
    Dismiss Notice
  5. The Aftermath has been revealed for the 19th Terraining Contest! Be sure to check out the Results and see what came out of it.
    Dismiss Notice

[vJASS] Phoenix Strike v1.0.0.8

Submitted by Doomlord
This bundle is marked as approved. It works and satisfies the submission rules.
In proving how the amount of code is inversely proportional to the amount of library used, I present to you my first ever vJASS spell to be uploaded. The code is short enough and the library count is high enough also.

Besides, I haven't uploaded anything in a while. So why not?

PHOENIX STRIKE

Gives a percentage chance to unleash a raging phoenix that deals damage to enemies in its wake when attacking.

Level 1 - 3xAGI damage, 10% chance.
Level 2 - 5xAGI damage, 20% chance.
Level 3 - 7xAGI damage, 30% chance.
Level 4 - 9xAGI damage, 40% chance.

Required Libraries:

Optional Library (for more swag):

Credit:
  • Dirac for Missile, Linked List Module, Loc, Adv Loc.
  • Cokemonkey11 for Structured DD, DamageType.
  • Garfield1337 for GetTerrainZ | UnitZ.
  • Maker for ArcingFloatingText.
  • Nestharus for Alloc Alternative, UnitIndexer, Event, World Bounds, Dummy, CTL, Error Message.
  • Vexorian for JassHelper, Table.

To import:

  • Step 1: Copy all required libraries to your map.
  • Step 2: Copy al library-related objects in the test map (1 dummy, 1 ability) to your map. Readjust the raw codes in the Dummy library and the DamageType library.
  • Step 3: Copy the Phoenix Strike ability and configure it.
  • Step 4: ???
  • Step 5: Profit!!!


Script:

Code (vJASS):
library PhoenixStrike /* v1.0.0.8 by Doomlord
*************************************************************************************
*
*   Gives a percentage chance to unleash a raging phoenix
*   that deals damage to enemies in its wake when attacking.
*
*************************************************************************************
*
*   Credits
*
*       Dirac
*       -----------------------
*
*           Missile library
*
*       Cokemonkey11
*       -----------------------
*
*           DamageType library
*
*       Garfield1337
*       -----------------------
*
*           UnitZ library
*
*       Nestharus
*       -----------------------
*
*           Alloc Alternative
*
*       Maker
*       -----------------------
*
*           Arcing Floating Text library
*
*************************************************************************************
*
*   */
uses /*
*  
*       */
Missile                      /* hiveworkshop.com/forums/jass-resources-412/system-missile-207854/
*       */
DamageType                   /* hiveworkshop.com/forums/jass-resources-412/system-damagetype-structureddd-extension-228883/
*       */
UnitZ                        /* hiveworkshop.com/forums/jass-resources-412/snippet-getterrainz-unitz-236942/
*       */
Alloc                        /* hiveworkshop.com/forums/jass-resources-412/snippet-alloc-alternative-221493/
*       */
optional FloatingTextArc     /* hiveworkshop.com/forums/spells-569/arcing-floating-text-1-0-0-3-a-228710/
*
************************************************************************************
*
*   SETTINGS
*
*/

   
    globals
        // Ability raw code
        private constant integer ABI_ID = 'A002'
        // Maximum travel range
        private constant real MAX_TRAVEL_RANGE = 1000
        // Missile model
        private constant string MISSILEFX = "Units\\Human\\Phoenix\\Phoenix.mdl"
        // On Collide Model
        private constant string COLLIDEFX = "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl"
        // Attachment point
        private constant string ATTACHPOINT = "chest"
        // Attack type
        private constant attacktype ATT = ATTACK_TYPE_HERO
        // Damage type
        private constant damagetype DAM = DAMAGE_TYPE_NORMAL
        // Weapon type
        private constant weapontype WEA = WEAPON_TYPE_METAL_HEAVY_SLICE
    endglobals
   
    // Trigger chance
    private function getChance takes integer level returns boolean
        return GetRandomInt(1, 100) <= 10*level
    endfunction
   
    // Area of effect
    private function getAoE takes integer level returns real
        return 200.
    endfunction
   
    // Agility multiplier
    private function getMultiplier takes integer level returns integer
        return 1 + level*2
    endfunction
   
    // Damage on collide
    private function getDamage takes unit u, integer level, integer multiplier returns real
        if not IsUnitType(u, UNIT_TYPE_HERO) then
            return 100 + level*50.
        endif
       
        return GetHeroAgi(u, true)*multiplier*1.
    endfunction
   
    // Missile speed per 0.03125s
    private function getSpeed takes integer lvl returns real
        return 45.
    endfunction
   
    // Filter out some targets
    private function filterUnit takes unit caster, unit u returns boolean
        return /*
       
        */
IsUnitEnemy(u, GetOwningPlayer(caster)) and /* Target is an enemy of caster
        */
not IsUnitType(u, UNIT_TYPE_DEAD) and /* Target is alive
        */
GetUnitAbilityLevel(u, 'Avul') == 0 and /* Target is not invulnerable
        */
not IsUnitType(u, UNIT_TYPE_STRUCTURE) /* Target is not a structure
        */

    endfunction
   
    // Just skip this if you want. There is not much to read anyway.
    private struct PS extends array
        implement Alloc

        Missile m
       
        static method onFinish takes Missile m returns boolean
            call DestroyEffect(AddSpecialEffect(MISSILEFX, m.impact.x, m.impact.y))
            call thistype(m.data).deallocate()
            return true
        endmethod
       
        static method onCollide takes Missile m, unit justHit returns boolean
            if filterUnit(m.source, justHit) then
                // Reproduce the weapon sound
                call UnitDamageTarget(m.source, justHit, 0, false, false, ATT, DAM, WEA)
                // The function somehow reverses the damage dealt. Hence the need to use a negative amount.
                call DamageType.dealCodeDamage(m.source, justHit, getDamage(m.source, GetUnitAbilityLevel(m.source, ABI_ID), getMultiplier(GetUnitAbilityLevel(m.source, ABI_ID))))
                call DestroyEffect(AddSpecialEffectTarget(COLLIDEFX, justHit, ATTACHPOINT))
            endif
           
            return false
        endmethod
       
        implement MissileStruct
       
        private static method create takes nothing returns thistype
            local real a = GetRandomReal(-bj_PI, bj_PI)
            local unit u = GetEventDamageSource()
            local integer i = GetUnitAbilityLevel(u, ABI_ID)
            local real r = GetRandomReal(300, MAX_TRAVEL_RANGE)
            local real x = GetUnitX(u) + r*Cos(a)
            local real y = GetUnitY(u) + r*Sin(a)
            local unit u1 = GetTriggerUnit()
            local thistype this = thistype.allocate()
           
            set .m = Missile.create (x, y, GetUnitZ(u), Atan2(GetUnitY(u1) - y, GetUnitX(u1) - x), MAX_TRAVEL_RANGE, GetUnitZ(u1))
            set m.source = u
            set m.speed = getSpeed(i)
            set m.model = MISSILEFX
            set m.collision = getAoE(i)
            set m.scale = 1.5
            set m.data = this
                   
            static if LIBRARY_FloatingTextArc then
                call ArcingTextTag.create("|c00ECEC00 PHOENIX STRIKE!|r", u)
            endif

            call launch(m)
            return this
        endmethod
   
        static method handler takes nothing returns nothing
            local unit u = GetEventDamageSource ()
       
            if DamageType.get() == DamageType.ATTACK  and /*
            */
GetUnitAbilityLevel(u, ABI_ID) > 0 and /*
            */
IsUnitEnemy(GetTriggerUnit(), GetOwningPlayer(u)) and /*
            */
getChance(GetUnitAbilityLevel(u, ABI_ID)) then
           
                call thistype.create ()
               
            endif
           
            set u = null
        endmethod
       
        private static method onInit takes nothing returns nothing
            call StructuredDD.addHandler(function thistype.handler)
        endmethod
    endstruct
endlibrary


Changelog

+ v1.0.0.0: Initial release.
+ v1.0.0.1: Made struct PS extends array.
+ v1.0.0.2: Idiot-proofed create/destroy method.
+ v1.0.0.3: Switched to using Nestharus' Alloc Alternative.
+ v1.0.0.4: Improved code readability.
+ v1.0.0.5: Improved code readability further.
+ v1.0.0.6: Fixed an issue with physical damage type.
+ v1.0.0.7: Updated spell lib with new Alloc.
+ v1.0.0.8: Updated spell lib with new StructuredDD and DamageType.


Tip to other spell makers: Always mention Magtheridon96's name in the keyword for maximum swag.

Keywords:
phoenix, swag, yolo, magtheridon96, vJASS
Contents

Phoenix Strike (Map)

Reviews
Moderator
13:45, 22nd Jul 2013 PurgeandFire: Approved. A wonderful, swagtastic spell.
  1. 13:45, 22nd Jul 2013
    PurgeandFire: Approved. A wonderful, swagtastic spell.
     
  2. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,839
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    Make struct PS extend array for more swag.
     
  3. Doomlord

    Doomlord

    Joined:
    Dec 15, 2011
    Messages:
    1,150
    Resources:
    14
    Spells:
    12
    JASS:
    2
    Resources:
    14
    Alright then. You can never have too much swag anyway.

    edit

    Added more swag.

    edit

    Added even more swag. Thanks to edo494 for helping with the create/destroy methods.
     
    Last edited: Jul 21, 2013
  4. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,004
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    You, my friend, did almost everything correctly here.
     
  5. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    lol thats pretty damn funny. xD

    Step One: Attack shit till spell takes effect.
    Step Two: Pheonix comes out of nowhere and charges at stuff.
    Step Three: Everything dies instantly.
    Step Four: Rinse and repeat.
     
  6. Doomlord

    Doomlord

    Joined:
    Dec 15, 2011
    Messages:
    1,150
    Resources:
    14
    Spells:
    12
    JASS:
    2
    Resources:
    14
    Mag's swag kills everything instantly :ogre_hurrhurr:
     
  7. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    Update your signature, omg peasasnt.
     
  8. Doomlord

    Doomlord

    Joined:
    Dec 15, 2011
    Messages:
    1,150
    Resources:
    14
    Spells:
    12
    JASS:
    2
    Resources:
    14
    Not before it is approved :D I never put a pending spell in my sig.
     
  9. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,839
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    Make "Missile m" private.

    I recommend combining create with handler.
    You can also remove "thistype" on static calls.
     
  10. Doomlord

    Doomlord

    Joined:
    Dec 15, 2011
    Messages:
    1,150
    Resources:
    14
    Spells:
    12
    JASS:
    2
    Resources:
    14
    1/ Alright.

    2/ Not necessary. It makes the code easier to read.
     
  11. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,004
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Why should he make Missile m private if the struct is already private?
    It's just added verbosity, but oh well~
     
  12. Doomlord

    Doomlord

    Joined:
    Dec 15, 2011
    Messages:
    1,150
    Resources:
    14
    Spells:
    12
    JASS:
    2
    Resources:
    14
    Private-ception :D

    Now that Mag said that, I won't make any further change :)
     
  13. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    I'm seriously starting to dislike swag. >.> lame as shit now :c so overused
     
  14. Doomlord

    Doomlord

    Joined:
    Dec 15, 2011
    Messages:
    1,150
    Resources:
    14
    Spells:
    12
    JASS:
    2
    Resources:
    14
    Swag rulez by default. Your arguement is invalid.

    \m/ swag on.
     
  15. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,839
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    I have a Crimson Lord of Darkness with Swag, your argument is invalid.
     
  16. Doomlord

    Doomlord

    Joined:
    Dec 15, 2011
    Messages:
    1,150
    Resources:
    14
    Spells:
    12
    JASS:
    2
    Resources:
    14
    SWAG HI-FIVE bro _o/
     
  17. UngThanhNhan

    UngThanhNhan

    Joined:
    Jan 30, 2013
    Messages:
    116
    Resources:
    0
    Resources:
    0
    how can I change the attack and damage type?
    when I change it, the spell will have errors
     
  18. Doomlord

    Doomlord

    Joined:
    Dec 15, 2011
    Messages:
    1,150
    Resources:
    14
    Spells:
    12
    JASS:
    2
    Resources:
    14
    The bug has been addressed, I will upload the new version later.
     
  19. MasterTrainer

    MasterTrainer

    Joined:
    Apr 14, 2012
    Messages:
    2,768
    Resources:
    3
    Icons:
    1
    Maps:
    1
    Spells:
    1
    Resources:
    3
    Doomlord- vJASS huh? You rock!