• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

What and Hows about Jass

Status
Not open for further replies.
Level 18
Joined
Sep 14, 2012
Messages
3,413
Instead of :
JASS:
scope Shreding
//==========================================================================
//=============================SETUP========================================
//==========================================================================

    globals
        private constant integer SPELL_ID = 'B000'
        private constant real perte = 0.9    //La vie sera multipliée par ce nombre
        private constant string model = "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl"
    endglobals

    private function Targ takes unit targ returns boolean
        return (GetWidgetLife( targ ) > 0.405 ) and ( IsUnitType( targ, UNIT_TYPE_MAGIC_IMMUNE ) == false ) and ( IsUnitAlly( targ, GetOwningPlayer( GetTriggerUnit() ) ) == false )
    endfunction
    
    private function Range takes integer level returns integer
        return 400 + 10 * level
    endfunction
    
    private function Damage takes integer level returns integer
        return 75 * level
    endfunction
    
    private function Armor takes integer level returns integer
        return 3*level
    endfunction
    
    private function MoveSpeed takes integer level returns real
        return I2R( 10 + 5 * level )
    endfunction
    
    private function AttackSpeed takes integer level returns integer
        return 10 + 5 * level
    endfunction
//==========================================================================
//=============================END SETUP====================================
//==========================================================================
    globals
        group g
        boolexpr b
    endglobals
    
    private function Pick takes nothing returns boolean
        return Targ( GetFilterUnit() )
    endfunction
    
    private function Cond takes nothing returns boolean
        local unit u = GetSpellAbilityUnit()
        local integer level = GetUnitAbilityLevel( u, SPELL_ID )
        local real x = GetUnitX( u )
        local real y = GetUnitY( u )
        local unit f
        if ( GetSpellAbilityId() == SPELL_ID ) then
            call GroupEnumUnitsInRange( g, x, y, Range( level ), b )
            loop
                set f = FirstOfGroup( g )
                exitwhen ( f == null )
                call GroupRemoveUnit( g, f )
                call UnitDamageTarget( u, f, Damage( level ), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null )
                call Debuff.UnitAddDoubleSlowReducArmor( f, 6, MoveSpeed( level ), AttackSpeed( level ), Armor( level ) )
            endloop
            call SetWidgetLife( u, GetWidgetLife( u )  * perte )
            call DestroyEffect( AddSpecialEffect( model, x, y ) )
        endif
        set u = null
        return false
    endfunction
//===========================================================================
    private function Init takes nothing returns nothing
        local trigger Shreding = CreateTrigger(  )
        call TriggerRegisterAnyUnitEventBJ( Shreding, EVENT_PLAYER_UNIT_SPELL_EFFECT ) 
        call TriggerAddCondition( Shreding, Condition( function Cond ) )
        
        set g = CreateGroup()
        set b = Condition( function Pick )
        
        //Preloading effect
        call Preload( model )
        
        //Preloading ability
        set bj_lastCreatedUnit = CreateUnit( Player(15), dummy, 0, 0, 0 )
        call UnitAddAbility( bj_lastCreatedUnit, SPELL_ID )
        call KillUnit( bj_lastCreatedUnit )
        set Shreding = null
    endfunction
endscope

I write
JASS:
scope Shreding initializer Init
//==========================================================================
//=============================SETUP========================================
//==========================================================================

    globals
        private constant integer SPELL_ID = 'B000'
        private constant real perte = 0.9    //La vie sera multipliée par ce nombre
        private constant string model = "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl"
    endglobals

    private function Targ takes unit targ returns boolean
        return (GetWidgetLife( targ ) > 0.405 ) and ( IsUnitType( targ, UNIT_TYPE_MAGIC_IMMUNE ) == false ) and ( IsUnitAlly( targ, GetOwningPlayer( GetTriggerUnit() ) ) == false )
    endfunction
    
    private function Range takes integer level returns integer
        return 400 + 10 * level
    endfunction
    
    private function Damage takes integer level returns integer
        return 75 * level
    endfunction
    
    private function Armor takes integer level returns integer
        return 3*level
    endfunction
    
    private function MoveSpeed takes integer level returns real
        return I2R( 10 + 5 * level )
    endfunction
    
    private function AttackSpeed takes integer level returns integer
        return 10 + 5 * level
    endfunction
//==========================================================================
//=============================END SETUP====================================
//==========================================================================
    globals
        group g
        boolexpr b
    endglobals
    
    private function Pick takes nothing returns boolean
        return Targ( GetFilterUnit() )
    endfunction
    
    private function Cond takes nothing returns boolean
        local unit u = GetSpellAbilityUnit()
        local integer level = GetUnitAbilityLevel( u, SPELL_ID )
        local real x = GetUnitX( u )
        local real y = GetUnitY( u )
        local unit f
        if ( GetSpellAbilityId() == SPELL_ID ) then
            call GroupEnumUnitsInRange( g, x, y, Range( level ), b )
            loop
                set f = FirstOfGroup( g )
                exitwhen ( f == null )
                call GroupRemoveUnit( g, f )
                call UnitDamageTarget( u, f, Damage( level ), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null )
                call Debuff.UnitAddDoubleSlowReducArmor( f, 6, MoveSpeed( level ), AttackSpeed( level ), Armor( level ) )
            endloop
            call SetWidgetLife( u, GetWidgetLife( u )  * perte )
            call DestroyEffect( AddSpecialEffect( model, x, y ) )
        endif
        set u = null
        return false
    endfunction
//===========================================================================
    private module MyModule
    private static method onInit takes nothing returns nothing
        //this is run on map init
        call init()
    endmethod
endmodule

private struct Hello extends array
    private static method init takes nothing returns nothing
        local trigger Shreding = CreateTrigger(  )
        call TriggerRegisterAnyUnitEventBJ( Shreding, EVENT_PLAYER_UNIT_SPELL_EFFECT ) 
        call TriggerAddCondition( Shreding, Condition( function Cond ) )
        
        set g = CreateGroup()
        set b = Condition( function Pick )
        
        //Preloading effect
        call Preload( model )
        
        //Preloading ability
        set bj_lastCreatedUnit = CreateUnit( Player(15), dummy, 0, 0, 0 )
        call UnitAddAbility( bj_lastCreatedUnit, SPELL_ID )
        call KillUnit( bj_lastCreatedUnit )
        set Shreding = null
    endmethod

    implement MyModule
endstruct
endscope

?
 
@DeathChef
Player(16)? Do you mean Player(15) because 16 doesn't exist :D

Right. :D
I'm used to my own way of looping and over looked.

The loop that the bj uses is set at 16. Although doesn't run through the registration then and instead ends the loop strait after it hit 16.

Curses blizzards logic.
 
Last edited:
Level 15
Joined
Oct 29, 2012
Messages
1,474
GETTING BACK TO THE TOPIC :
If you want to learn Jass , Basic Jass , Learn What functions xxxx takes xxx returns xxx
I probably learned JASS myself without looking on tutorials :D by converting GUI to Jass
Starting with BJs ending with natives . It's really easy . But I am still using GUI

P.S NOTE WARNING : I'm the dudest guy in the hive B)
 
Status
Not open for further replies.
Top