• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • It's time for the first HD Modeling Contest of 2025. Join the theme discussion for Hive's HD Modeling Contest #7! Click here to post your idea!

[JASS] Structs dont work with new patch O_O

Status
Not open for further replies.
Level 10
Joined
Feb 20, 2008
Messages
448
[Solved]Game is bugged with new patch(structs ?)

I i am a new jasser o_O after few test i saw new patch make my strutcs unable to be in map..... those librairy were really usefull for me is there any way to fix it??

i got 2 structs i mainly use o_O isnt there any way to fix or at least a system that could replace them o_O..........

+rep will be give + credits in my map project Called ''Naruto tribute''

EDIT : PROBLEM IS FIX its wasnt structs it was an indexing problem.... somehow special effect cant be index now @_@, we can close topics i juast hope poeple will fix it in jngp

i use Newjassgen 1.5d i updated it with files gave by ''dr.supergood'' on topics o_O

JASS:
//SYSTEM FOT(Fading OverTime)
library FOT initializer Init
    
    private keyword Data
    
    globals
        private timer tim
        private constant real interval = 0.05
        private Data array dat
        private integer total = 0
    endglobals
    
    private function Loop takes nothing returns nothing
        local Data d
        local integer i = 0
        local integer i2 = R2I( 100. * I2R( 255 ) * 0.01 )
        
        loop
            exitwhen i >= total
            set d = dat[i]
            
            set d.fadecheck = d.fadecheck - d.fade
            if d.fadecheck > 0. then
                call SetUnitVertexColor( d.faded, i2, i2, i2, R2I( d.fadecheck * I2R( 255 ) * 0.01 ) )
            else
                call RemoveUnit( d.faded )
                set d.faded = null
                
                call d.destroy( )
                
                set total = total - 1
                set dat[i] = dat[total]
            endif
            set i = i + 1
        endloop
        
        if total == 0 then
            call PauseTimer( tim )
        endif                
    endfunction
    
    private struct Data
        unit faded
        real duration
        real fade
        
        real fadecheck
        
        static method Create takes unit faded, real duration returns nothing
            local Data d = Data.allocate( )
            
            set d.faded = faded
            set d.fade = 100. / duration * interval
            set d.fadecheck = 100.
            
            if total == 0 then
                call TimerStart( tim, interval, true, function Loop )
            endif
            
            set dat[total] = d
            set total = total + 1
        endmethod
    endstruct
    
    function Fade takes unit faded, real duration returns nothing
        call Data.Create( faded, duration )
    endfunction
    
    private function Init takes nothing returns nothing
        set tim = CreateTimer( )
    endfunction

endlibrary

SYSTEM DOT(Damage OverTime)

JASS:
library DOT initializer Init
//DOT system current version 1.2 - Personally updated by Wizardum
private keyword Data

globals
    private constant real interval = 0.05
    private timer tim
    private Data array dat
    private integer total = 0
    group DOTunits
endglobals

private function Loop takes nothing returns nothing
    local Data d
    local integer i = 0
    local real array r
    
    loop
        exitwhen i >= total
        set d = dat[i]
        
        set r[1] = d.dmg * d.dur
        set r[2] = d.heal * d.dur
        set r[3] = GetWidgetLife( d.target )
        
        if r[3] < 0.405 then
            set d.dmgcount = r[1]
            set d.healcount = r[2]
        endif
        
        set d.counter = d.counter + interval
        if d.counter >= d.icheck then
            set d.counter = 0.
            if d.dmgcount < r[1] or d.healcount < r[2] then
                set d.dmgcount = d.dmgcount + d.dmg
                set d.healcount = d.healcount + d.heal
                call SetWidgetLife( d.target, GetWidgetLife( d.target) + d.heal )
                call UnitDamageTarget( d.source, d.target, d.dmg, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null )
                call DestroyEffect( AddSpecialEffectTarget( d.insEffect, d.target, d.attach ) )
            else
                call DestroyEffect( d.effectOT )
                call GroupRemoveUnit( DOTunits, d.target )
                set d.effectOT = null
                set d.source = null
                set d.target = null
                
                call d.destroy( )
                set total = total - 1
                set dat[i] = dat[total]
            endif
        endif
        
        set i = i + 1
    endloop
                
    if total == 0 then
        call PauseTimer( tim )
    endif
endfunction

private struct Data
    unit source
    unit target
    real dmg
    real heal
    real dur
    real icheck
    string insEffect
    effect effectOT
    string attach
    
    real counter
    real dmgcount
    real healcount
    
    static method Create takes unit source, unit target, real dmg, real heal, real dur, real icheck, string insEffect, effect effectOT, string attach returns nothing
        local Data d = Data.allocate( )
        
        set d.source = source
        set d.target = target
        set d.dmg = dmg / dur / icheck
        set d.heal = heal / dur / icheck
        set d.dur = dur
        set d.icheck = icheck
        set d.insEffect = insEffect
        set d.effectOT = effectOT
        if attach == "" then
            set d.attach = "chest"
        else
            set d.attach = attach
        endif
        set d.counter = 0.
        set d.dmgcount = 0.
        set d.healcount = 0.
        call GroupAddUnit( DOTunits, d.target )
        if total == 0 then
            call TimerStart( tim, interval, true, function Loop )
        endif
        
        set dat[total] = d
        set total = total + 1
    endmethod
endstruct

function DamageAttach takes unit source, unit target, real totaldmg, real duration, real intervalcheck, string insEffect, string effectOT, string attach returns nothing
    local effect e 
    if not IsUnitInGroup( target, DOTunits ) then
        set e = AddSpecialEffectTarget( effectOT, target, attach )
        call Data.Create( source, target, totaldmg, 0., duration, intervalcheck, insEffect, e, attach )
        set e = null
    endif
endfunction

function HealAttach takes unit target, real totalheal, real duration, real intervalcheck, string insEffect, string effectOT, string attach returns nothing
    local effect e 
    if not IsUnitInGroup( target, DOTunits ) then
        set e = AddSpecialEffectTarget( effectOT, target, attach )
        call Data.Create(  null, target, 0., totalheal, duration, intervalcheck, insEffect, e, attach )
        set e = null
    endif
endfunction
private function Init takes nothing returns nothing
    set tim = CreateTimer( )
    set DOTunits = CreateGroup( )
endfunction

endlibrary
 
Last edited:
Level 10
Joined
Feb 20, 2008
Messages
448
well i didnt get any error when i saved, i reinstalled jnpg fix while JNGP was closed afteri opened jngp and test my map wc3 ran but map cant be found, when i remove dot & fot i can play the map great ....... o_O

so i think those structs got error that jnpg cant say @_@ i dont know jass that much to know whats wrong ......im ready to send map if it need @_@ working on map since march....... with my job and school .... i dont wanna lost this o_O

what did i do wrong.... i got no error when i save o_O.... if its my jngp can u send me real file, i will reinstall it o_O ....or some1 could test it to see if its me or map

edit the error i got from we its UNregistered native function o_O
 
Last edited:
Level 9
Joined
Nov 28, 2008
Messages
704
Structs are basically indexes to global arrays with a friendlier syntax. They do not in any way exploit H2I, and thus should and will work perfect.

If you are having problems, it is probably with anything using H2I in your map. Otherwise, perhaps your editor is corrupted or you are using an outdated version of JNGP.

Structs can't possibly be the problem :p.
 
Level 10
Joined
Feb 20, 2008
Messages
448
I dont know h2I much o_O is there anyway i can learn what is H2I o_O im new jasser i dont know alot lol

my jass folder isnt installed on same hard drive as my wc3 o_O my thought, maybe like u said its corrupted

the problem happening between structs i showed up and saving if the structs i showed is ok and work in ur map its mean its my JNGP

Im ready to send map o_O and reinstalled my JNGP , i will reinstall it and ill edit to show what is the result cuz now i got 2 go at work!!!
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Basically any function that looks something like this should be edited:

JASS:
function H2I takes unit u returns integer
    return u
    return 0
endfunction

There are more functions similar to this, but the most used one is that.
If you have that function, change it to this:

JASS:
function H2I takes unit u returns integer
    return GetHandleId(u)
endfunction

If you have other functions, other solutions would be needed, depending on what they take and return.

Aside from that, in the future please put long codes in '[hidden=name]code[/hidden]' tag. It makes the page smaller and less laggy.
 
Level 10
Joined
Feb 20, 2008
Messages
448
can the h21 can be used in gui or called ?

{EDIT}
i read all jass trigger i had , i dont think i got this!!! but im not sure, if its my map ormy jnpg editor that is broken o_O, i deleted it and reinstalled with 1.5d and supergood file that showed in 1.24..... nothing work...............

Can i Pm the map to some1 ? i dont wanna attach it here cuz i dont want my idea and working spell be copying or used without giving credits o_O

if u can test and play map as well its will mean its my editor if not ull be able to fix....... im about to crash my computers out of the building >.< and im about to PLAY DOTA OMFG its corrupting my mind.... plz help me so i can still map making my wonderful map :D like i said i will gave rep to who help me and credits in my map loading screen of course ^^

edit : wtf double post o_O thought the previous msg didnt showed when i refresh page sorry

URGENT EDIT : OMFG some error that showed in we isnt showed in jngp, i had an werror as ' attemp to index an none-indexable vars'' but my variable is an index and were working before new patch........ o_O if u use special effect array dont make them indexed o_O i dont know if it will fix my problem

I FOUND THE PROBLEM.... IN JNGP INDX VARIABLE ERROR for special effect ARENT SHOWED.... so if u do an error its will only tell u in original we :eek:, theres nowhere that you see them changed indexing variable that in 1.24 cant be index o_O i think its a bug that they created in 1.24

we can close topics i also add +rep to evry1 ^^ and i write the msg in 1.24 patch
 
Last edited by a moderator:
Level 17
Joined
Jun 17, 2007
Messages
1,433
Basically any function that looks something like this should be edited:

JASS:
function H2I takes unit u returns integer
    return u
    return 0
endfunction
There are more functions similar to this, but the most used one is that.
If you have that function, change it to this:

JASS:
function H2I takes unit u returns integer
    return GetHandleId(u)
endfunction
If you have other functions, other solutions would be needed, depending on what they take and return.

Aside from that, in the future please put long codes in '[hidden=name]code[/hidden]' tag. It makes the page smaller and less laggy.
Remember, it's H2I, not U2I. It should look like this:

JASS:
function H2I takes handle h returns integer
    return h
    return 0
endfunction
 
Level 10
Joined
Feb 20, 2008
Messages
448
Remember, it's H2I, not U2I. It should look like this:

JASS:
function H2I takes handle h returns integer
    return h
    return 0
endfunction
Whats differenty of U2I and H2I ? whats job they are doing different ?

You could PM me it, but I don't think you have to worry about it being stolen. Just a suspicion.
i dont worry my map being stolen ,i worry about my exclusive spell i had from some map maker ^^ but thx anyway i found problem

PROBLEM WAS : special effect cant be index in 1.24, somehow it will only tell you this error if you use WE, not jngp ^^ but i will worry know i know it :p and developer i work with dont use h2i cuz they system work lot better ^^
 
Basically any function that looks something like this should be edited:

JASS:
function H2I takes unit u returns integer
    return u
    return 0
endfunction

There are more functions similar to this, but the most used one is that.
If you have that function, change it to this:

JASS:
function H2I takes unit u returns integer
    return GetHandleId(u)
endfunction

If you have other functions, other solutions would be needed, depending on what they take and return.

Aside from that, in the future please put long codes in '[hidden=name]code[/hidden]' tag. It makes the page smaller and less laggy.


I tried to give that advice too once but was corrected - apparently blizzard is implementing an own H2I, so functions should not have that name. Simply name it something else, then use the search and replace function in JNPG to replace it in the rest of the code.
 
Level 12
Joined
Aug 7, 2004
Messages
875
I had the same problem too, involves a Boomerang skill that uses a Data struct, the map wouldn't work when I test it, it just went straight to the main console. But hey, you don't need a struct to create a Damage over Time skill.

If you deleted that spell and your map works, then I'm really sure there are no return bug errors or other stuff in your map, it must be that spell. I'm not sure why this happens to some structs.
 
Level 10
Joined
Feb 20, 2008
Messages
448
You right i dont need system for damage over time but this system is mui ans jass, efficient and wont lag in game ^^ and spell im amking with will nearly be mui and u can use it in jass or gui :p thats why i like his system!!!!

and for the structs it wont work if u got returns bug, but any other will work, some glitch appeared, i succesfully fix my map now i can host it .... gay indexing vars....lol

we can close topics
 
Status
Not open for further replies.
Top