• 🏆 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] Problems with functions

Status
Not open for further replies.
Level 6
Joined
Mar 26, 2008
Messages
239
When I try to import some spells downloaded from Hive Workshop,some of them don't work,because some functions don't exist in my map,though I have 1.23 WarCraft and many tools.What should I add to my map to fix that?
 
Level 6
Joined
Mar 26, 2008
Messages
239
'undeclared function ...' and some other(don't remember),but not like it'mistake in function,but as if function doesn't exist in my map,but exists in the map with spell.
For example Telura beam by Daelin...
 
Level 11
Joined
Apr 6, 2008
Messages
760
You for got to import the Handle vars.. in the map header

JASS:
// ===========================
function H2I takes handle h returns integer
    return h
    return 0
endfunction
 
// ===========================
function LocalVars takes nothing returns gamecache
    if udg_cach == null then
        call FlushGameCache(InitGameCache("cach"))
        set udg_cach=InitGameCache("cach")
    endif
    return udg_cach
endfunction
 
function SetHandleHandle takes handle subject, string name, handle value returns nothing
    if value==null then
        call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(), I2S(H2I(subject)), name, H2I(value))
    endif
endfunction
 
function SetHandleInt takes handle subject, string name, integer value returns nothing
    if value==0 then
        call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction
 
function SetHandleReal takes handle subject, string name, real value returns nothing
    if value==0 then
        call FlushStoredReal(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreReal(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction
 
function SetHandleString takes handle subject, string name, string value returns nothing
    if value==null then
        call FlushStoredString(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreString(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction
 
function GetHandleHandle takes handle subject, string name returns handle
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleInt takes handle subject, string name returns integer
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleReal takes handle subject, string name returns real
    return GetStoredReal(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleString takes handle subject, string name returns string
    return GetStoredString(LocalVars(), I2S(H2I(subject)), name)
endfunction
 
function GetHandleUnit takes handle subject, string name returns unit
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTimer takes handle subject, string name returns timer
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTrigger takes handle subject, string name returns trigger
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleEffect takes handle subject, string name returns effect
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleGroup takes handle subject, string name returns group
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTextTag takes handle subject, string name returns texttag
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction 

function FlushHandleLocals takes handle subject returns nothing
    call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction

//$$$$$$$$$$$$$$$$$$$$
//AUXILIARY FUNCTIONS
//$$$$$$$$$$$$$$$$$$$$

function GetDistanceBetweenPoints takes real x1, real y1, real x2, real y2 returns real
    return SquareRoot((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))
endfunction

function PolarProjectionX takes real x, real dist, real angle returns real
return x+dist*Cos(angle*bj_DEGTORAD)
endfunction

function PolarProjectionY takes real y, real dist, real angle returns real
return y+dist*Sin(angle*bj_DEGTORAD)
endfunction

function GetAngleBetweenPoints takes real x1, real y1, real x2, real y2 returns real
return bj_RADTODEG*Atan2(y2-y1, x2-x1)
endfunction

function SubjectManaBurn takes unit whichUnit, player inflictor, real amount returns real
    local unit dumb
    local real RealAmount
    local real mana = GetUnitState(whichUnit, UNIT_STATE_MANA)
    local real life = GetUnitState(whichUnit, UNIT_STATE_LIFE)
    

    if mana<=0 then
        return 0.00
    endif
    if amount>mana then
        set amount = GetUnitState(whichUnit, UNIT_STATE_MANA)
    endif
    
    set dumb = CreateUnit(inflictor, 'nalb', GetUnitX(whichUnit), GetUnitY(whichUnit), 0.00)
    //call ShowUnit(dumb, false)
    call UnitDamageTarget(dumb, whichUnit, amount, true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MIND, WEAPON_TYPE_WHOKNOWS)
    set RealAmount = life-GetUnitState(whichUnit, UNIT_STATE_LIFE)
    call SetUnitState(whichUnit, UNIT_STATE_MANA, mana-RealAmount)
    call RemoveUnit(dumb)
    set dumb = null
    return RealAmount
endfunction

function IsUnitInvulnerable takes unit whichUnit returns boolean
    local unit helper = CreateUnit(Player(15), 'nalb', GetUnitX(whichUnit), GetUnitY(whichUnit), 0.00)
    local real life = GetUnitState(whichUnit, UNIT_STATE_LIFE)
    if life<GetUnitState(whichUnit, UNIT_STATE_MAX_LIFE) then
        call SetUnitState(whichUnit, UNIT_STATE_LIFE, life+0.01)
        set life = life+0.01
        call UnitDamageTarget(helper, whichUnit, 0.01, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNKNOWN, WEAPON_TYPE_WHOKNOWS)
        call RemoveUnit(helper)
        if GetUnitState(whichUnit, UNIT_STATE_LIFE)<life then
            return false
        else
            call SetUnitState(whichUnit, UNIT_STATE_LIFE, life-0.01)
            return true
        endif
    else
        call UnitDamageTarget(helper, whichUnit, 0.01, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNKNOWN, WEAPON_TYPE_WHOKNOWS)
        call RemoveUnit(helper)
        if GetUnitState(whichUnit, UNIT_STATE_LIFE)<life then
            call SetUnitState(whichUnit, UNIT_STATE_LIFE, life)
            return false
        else
            return true     
        endif       
    endif
endfunction

function GroupGetUnitMaxMana takes group g returns unit
local group k = CreateGroup()
local unit u 
local unit max
local real quota

if FirstOfGroup(g)!=null then
call GroupAddGroup(g,k)
set max = FirstOfGroup(k)
set quota = GetUnitState(max, UNIT_STATE_MANA)
call GroupRemoveUnit(k,max)

loop
    set u = FirstOfGroup(k)
    exitwhen u==null
    call GroupRemoveUnit(k,u)
    if GetUnitState(u, UNIT_STATE_MANA)>quota then
    set quota = GetUnitState(u, UNIT_STATE_MANA)
    set max = u
    endif
    set u = FirstOfGroup(k)
endloop
return max
endif
return null
endfunction


//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
//SIMULATE FLOATNG TEXT FOR MANA BURN

function ManaBurnText_Remove takes nothing returns nothing
local timer t = GetExpiredTimer()
call DestroyTextTag(GetHandleTextTag(t, "burntext"))
call FlushHandleLocals(t)
call DestroyTimer(t)
set t = null
endfunction

function ManaBurnText takes real amount, unit whichUnit returns nothing
local texttag tt = CreateTextTag()
local timer t = CreateTimer()
call SetTextTagText(tt, "-"+I2S(R2I(amount)), 0.023)
call SetTextTagPosUnit(tt, whichUnit, -50.00)
call SetTextTagColor(tt, 90, 70, 255, 255)
call SetTextTagVelocityBJ( tt, 64, 90 )
call SetHandleHandle(t, "burntext",tt)
call TimerStart(t, 2.50, false, function ManaBurnText_Remove)
set tt = null
endfunction

that wont work in 1.24 because the H2I function bugg will stop working (gets replaced by GetHandleId() instead)
 
Level 6
Joined
Mar 26, 2008
Messages
239
Maybe it is new version of spell,I downloaded it long ago,but this isn't a solution...The problem is like if I write 'AddSpecialEffectLoc.....' асе syntax check writes that this function doesn't exist at all...
It seems like I must add these functions to my map somehow,but don't know how...
 
Level 11
Joined
Apr 6, 2008
Messages
760
JASS:
        call FlushHandleLocals(t)
        set e = AddSpecialEffectTarget("Abilities\\Weapons\\SpiritOfVengeanceMissile\\SpiritOfVengeanceMissile.mdl", targ, "chest")
        call DestroyEffect(e) //This made me lol

JASS:
    set e = AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIma\\AImaTarget.mdl", cast, "chest")
    call DestroyEffect(e)
    set e  = null

these are the only lines i found with special effects, and i think your problem is call FlushHandleLocals(t). face it its the handle vars that is your problem....(and no its not a new code it dont even have vjass and is uneffecent as hell)
 
Level 6
Joined
Mar 26, 2008
Messages
239
Undeclared function: GetHandleGroup,IsUnitInvulnerable,GetHandleUnit,GetHandleReal,GetAngleBetweenPoints,SetHandleReal,FlushHandleLocals,SetHandleHandle,ManaBurnText
Bad types for binary operator
Cannot convert null to integer
And some other similar errors
i tried to disable syntax check,but even without it map stops working
 
Level 6
Joined
Mar 26, 2008
Messages
239
Telura beam now works, thanks, +rep=)
But "Seal of Chaos" in Chaos spells by Conix,for example, still doesn't work
I understood that there are some custom functions in this map, and you found them to import, but how can I find them myself? Because there are no custon functions in Trigger Editor like you wrote.
In this spell TableVars are used, as I understood
 
Level 11
Joined
Apr 6, 2008
Messages
760
You can check the map header (the red ring in the screen shot)

attachment.php
 

Attachments

  • Mapheader.JPG
    Mapheader.JPG
    41.8 KB · Views: 151
Status
Not open for further replies.
Top