• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Another Spell Problem

Status
Not open for further replies.
Level 7
Joined
Jul 9, 2008
Messages
253
Hey guys, I have another problem. As I said before I am new to JASS so this might seem stupid for you good JASS'ers.

Code:

JASS:
function Trig_Energy_Sap_Conditions takes nothing returns unit
    return GetUnitTypeId(GetAttacker) == 'H009' //This line gives an error that says it needs another "("
endfunction

function Trig_Energy_Sap_Actions takes nothing returns nothing
    local unit attacker = GetAttacker()
    local unit attacked = GetTriggerUnit()
    local real X = GetUnitX(attacked)
    local real Y = GetUnitY(attacked)
    local integer level = GetUnitAbilityLevel(attacker, 'A00F')
    local real mana = GetUnitState(attacked,UNIT_STATE_MANA)
    local real agi = (I2R(GetHeroAgi(attacker,true))
    local real burn = ((I2R(level)) * agi)
    local string sfx = "Abilities\\Spells\\Human\\Feedback\\ArcaneTowerAttack.mdl"      
    //Actions//
    if mana >= burn then
        call UnitDamageTarget(attacker,attacked,burn,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
        call SetUnitState(attacked,UNIT_STATE_MANA, (mana - burn))
        call DestroyEffect(AddSpecialEffect(sfx, X,Y)
    endif
    //Actions//
    set attacked = null
    set attacker = null
    set sfx = null        
endfunction

//===========================================================================
function InitTrig_Energy_Sap takes nothing returns nothing
    set gg_trg_Energy_Sap = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Energy_Sap, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Energy_Sap, Condition( function Trig_Energy_Sap_Conditions ) )
    call TriggerAddAction( gg_trg_Energy_Sap, function Trig_Energy_Sap_Actions )
    set gg_trg_Energy_Sap = null
endfunction
 
Level 14
Joined
Nov 23, 2008
Messages
187
GetAttacker(), not GetAttacker.

JASS:
function Trig_Energy_Sap_Conditions takes nothing returns unit
    return GetUnitTypeId(GetAttacker()) == 'H009'
endfunction

When I began learning jass, I had the same issue :)

EDIT:

also, you have forgotten another ")" in the line:

JASS:
// syntax error:
call DestroyEffect(AddSpecialEffect(sfx, X,Y)

// correct:
call DestroyEffect(AddSpecialEffect(sfx, X,Y))
 
Level 14
Joined
Nov 23, 2008
Messages
187
JASS:
// this function should return boolean, not unit
function Trig_Energy_Sap_Conditions takes nothing returns boolean
    // fixed missing "()" :
    return GetUnitTypeId(GetAttacker()) == 'H009'
endfunction

function Trig_Energy_Sap_Actions takes nothing returns nothing
    local unit attacker = GetAttacker()
    local unit attacked = GetTriggerUnit()
    local real X = GetUnitX(attacked)
    local real Y = GetUnitY(attacked)
    local integer level = GetUnitAbilityLevel(attacker, 'A00F')
    local real mana = GetUnitState(attacked,UNIT_STATE_MANA)
    // fixed missing ")" :
    local real agi = (I2R(GetHeroAgi(attacker,true)))
    local real burn = ((I2R(level)) * agi)
    local string sfx = "Abilities\\Spells\\Human\\Feedback\\ArcaneTowerAttack.mdl"
    //Actions//
    if mana >= burn then
        call UnitDamageTarget(attacker,attacked,burn,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
        call SetUnitState(attacked,UNIT_STATE_MANA, (mana - burn))
        // fixed missing ")" :
        call DestroyEffect(AddSpecialEffect(sfx, X,Y))
    endif
    //Actions//
    set attacked = null
    set attacker = null
    set sfx = null
endfunction

//===========================================================================
function InitTrig_Energy_Sap takes nothing returns nothing
    set gg_trg_Energy_Sap = CreateTrigger( )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Energy_Sap, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Energy_Sap, Condition( function Trig_Energy_Sap_Conditions ) )
    call TriggerAddAction( gg_trg_Energy_Sap, function Trig_Energy_Sap_Actions )
    // you have no need to null anything, that should exist during all game time:
    // set gg_trg_Energy_Sap = null
endfunction
 
Status
Not open for further replies.
Top