Returning Jass, simple problem

MagnaGuard

Active Member
Reaction score
49
So after coming back to map making, I'm trying to relearn some Jass and ran into a few problems with this simple code.

JASS:
function Trig_Flare_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000' 
endfunction

function Trig_Flare_Actions takes nothing returns nothing
local unit trig = GetTriggerUnit()
local ability lev = GetUnitAbilityLevel(trig,'A000') //Cannot convert integer to ability
local real damage = 100* lev //bad types for binary operator
local location loc = GetSpellTargetLoc()
    call UnitDamagePoint(trig, 1.0, 1800, GetLocationX(loc), GetLocationY(loc), damage, true, false, ATTACK_TYPE_UNIVERSAL, DAMAGE_TYPE_CHAOS, WEAPON_TYPE_CHAOS) // Undeclared variable TTACK_TYPE_UNIVERSAL, DAMAGE_TYPE_CHAOS, WEAPON_TYPE_CHAOS
endfunction

//===========================================================================
function InitTrig_Flare takes nothing returns nothing
    set gg_trg_Flare = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Flare, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Flare, Condition( function Trig_Flare_Conditions ) )
    call TriggerAddAction( gg_trg_Flare, function Trig_Flare_Actions )
endfunction




If you can just tell me whats wrong, that would be helpful.
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
local ability lev > this variable should be integer type, not ability

local real damage = 100* lev > should be 100. * I2R(lev)

btw you are leaking that point
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
Lies. You don't need to add I2R.

lol it's not a lie

it's same either way, but it can be safer like that in some situtations (like in converting reals to integer then to string...)
 

T.s.e

Wish I was old and a little sentimental
Reaction score
133
Is he converting it into a string?

The result from multiplying an integer with a real is a real, the result from multiplying two reals is a real. There's no difference, except for that the latter requires an extra function call.
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
JASS:

local ability lev = GetUnitAbilityLevel(trig,'A000') //Cannot convert integer to ability


Should probably be:

JASS:

local integer lev = GetUnitAbilityLevel(trig,'A000') //Cannot convert integer to ability


----------------------

JASS:

ATTACK_TYPE_UNIVERSAL, DAMAGE_TYPE_CHAOS, WEAPON_TYPE_CHAOS


None of these exist. Perhaps you meant ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS?
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
local integer lev = GetUnitAbilityLevel(trig,'A000')
local real damage = 100. * lev

ATTACK_TYPE_UNIVERSAL
DAMAGE_TYPE_CHAOS
WEAPON_TYPE_CHAOS

Refer to common.j to see all type.
 

Zaraf

New Member
Reaction score
22
Might I recommend you learn and use vJass instead of normal Jass? It's MUCH easier to use, and makes your code cleaner and easier to read. I've also cleaned up a location leak.

I've converted your code to vJass so you can see:

JASS:
scope Flare initializer Init

    globals
        private constant integer SPELL_ID = 'A000'
        
        private constant real DELAY  = 1.0
        private constant real RADIUS = 1800.0
        
        private constant attacktype A_TYPE = ATTACK_TYPE_CHAOS
        private constant damagetype D_TYPE = DAMAGE_TYPE_UNIVERSAL
        private constant weapontype W_TYPE = WEAPON_TYPE_WHOKNOWS
    endglobals
    
//===========================================================================
    
private constant function Damage takes integer lev returns real
    return 0.0 + 100.0 * lev
endfunction

//===========================================================================

private function Cond takes nothing returns boolean
    return GetSpellAbilityId() == SPELL_ID
endfunction

private function Actions takes nothing returns nothing
    local integer lev = GetUnitAbilityLevel(GetTriggerUnit(), SPELL_ID)
    local location loc = GetSpellTargetLoc()
    local real x = GetLocationX(loc)
    local real y = GetLocationY(loc)
    
    call UnitDamagePoint(GetTriggerUnit(), DELAY, RADIUS, x, y, Damage(lev), true, false, A_TYPE, D_TYPE, W_TYPE)
    call RemoveLocation(loc)
    set loc = null
endfunction

//===========================================================================

private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(trig, Condition( function Cond))
    call TriggerAddAction(trig, function Actions)
endfunction

endscope


I actually never even learned Jass...just jumped straight into vJass, so it's not hard to learn :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top