System help...

XeNiM666

I lurk for pizza
Reaction score
138
I'm no JASS master but I made a small cast time system that I use it for every spell on my heroes only and some items. I was wondering how to get the instance of a struct without copy/pasting this on every spell I have, maybe similar to KT2's KT_GetData()...

Code:
JASS:
scope CT initializer onInit

    private struct Cast
        unit caster
        real time
        real t = 0.00
        integer order
        
        unit bar
        
        static method Update takes nothing returns boolean
            local Cast c = KT_GetData()
            
            set c.t = c.t + 0.01
            call SetUnitAnimationByIndex( c.bar, R2I( ( c.t / c.time ) * 20 ) + 1 )
            if c.t >= c.time or GetUnitCurrentOrder( c.caster ) != c.order then
                // call function here
                call c.destroy()
                
                return true
            endif
            
            return false
        endmethod
        
        method onDestroy takes nothing returns nothing
            call UnitApplyTimedLife( .bar, 'BTLF', 0.25 )
            call FadeUnit( .bar, 255.00, 0.00, 0.25 ) //custom function
            call IssueImmediateOrder( .caster, "stop" )
            set .caster = null
        endmethod
        
    endstruct

    public function Apply takes unit caster, real time, string order returns Cast
        local Cast c = Cast.create()
        
        set c.caster = caster
        set c.time = time
        set c.order = OrderId( order )
        
        set c.bar = CreateUnit( GetOwningPlayer( c.caster ), 'h00P', GetUnitX( c.caster ), GetUnitY( c.caster ), 270.00 ) // Hatebreeder's w/e Bars-modeled unit
        call SetUnitAnimationByIndex( c.bar, 0 )

        call KT_Add( function Cast.Update, c, 0.01 )
                
        return c
    endfunction

endscope


I want to be able to do something like this but don't know how.
JASS:
struct Spell
    unit caster
    unit target
    
    static method After 
        local Spell s = Cast.GetData()
        call KillUnit( s.target )
        call something( s.caster )
    endmethod
    
endstruct

function Test1
    local Spell s = Spell.create()
    set s.caster = GetTriggerUnit()
    set s.target = GetSpellTargetUnit()
    call CT_Apply( s.caster, 2.00, "holybolt", function Spell.After )
endfunction


Any suggestions? Also, is it fast/efficient?
TIA :)
 

XeNiM666

I lurk for pizza
Reaction score
138
ok, i read it in the jass manual and have 1 question..
how do i determine which are function interfaces and which are not?
 

Laiev

Hey Listen!!
Reaction score
187
JASS:
interface myFunc
    function //....................
endinterface

struct myStruct extends myFunc

endstruct


If I remember right..

Edit: PS: You should do all with struct (at your code posted before...)
 

chobibo

Level 1 Crypt Lord
Reaction score
48
Attach the data to the casting unit via a hash table or a unit indexing attachment.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • jonas jonas:
    Oh, I see. I thought Chinese version of A-levels :D
  • jonas jonas:
    I've been using the translate app a lot on my phone. take a photo, translate. take another photo, translate again :D
  • jonas jonas:
    it also has voice translation, my colleagues sometimes use that
  • jonas jonas:
    You came during the 0 covid policy right? How'd you get through quarantine? Did you have some help with the apps and green codes?
  • tom_mai78101 tom_mai78101:
    If you have any Chinese you need help with, let me know.
    +1
  • vypur85 vypur85:
    @jonas Those were the things I did too. Translate app and VPN are always the most important things to have to survive. Lol.
  • vypur85 vypur85:
    Yea I came last year. I was quarantined for about 30 days. Fml. The first day of my quarantine was the eve of Chinese new year last year. Fml again... Lol.
  • vypur85 vypur85:
    @tom_mai78101 IIRC you're from Taiwan right.
  • The Helper The Helper:
    I thought China had cracked down on having any foreign teachers?
  • vypur85 vypur85:
    Yeah I've heard of the news before. My school is still actively hiring foreign teachers. Not sure how things work now.
  • The Helper The Helper:
    yeah it is hard to get reliable information about that kind of stuff
  • The Helper The Helper:
    but you are doing it so it is still doable
  • vypur85 vypur85:
    I think it doesn't affect existing foreign teachers. Then again, its still weird that my school is hiring.
  • The Helper The Helper:
    Happy Monday people hope everyone has a fantastic week!
  • Ghan Ghan:
    Happy Monday?! That's a contradiction.
  • jonas jonas:
  • jonas jonas:
    please put this in the news section, it's crazy
  • tom_mai78101 tom_mai78101:
    Technically, you can post in the Headline News. Just posted your news there.
  • tom_mai78101 tom_mai78101:
    I'm not aware of you not being able to post news.
  • jonas jonas:
    I think technically I can I just forget how
    +1
  • The Helper The Helper:
    Happy Thursday!
  • The Helper The Helper:
    Happy Friday Night!
    +1
  • V-SNES V-SNES:
    Happy Friday night!
    +1
  • vypur85 vypur85:
    Happy Sunday. Sigh. Work day tomorrow.
    +1

    The Helper Discord

    Staff online

    Members online

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top