help with 1.24 coding

masta_orc

Cool Member
Reaction score
0
hi,
well i read many threads about fixing old scripts but.. i cant get this one to work. would be very nice if someone could help me :(

original 1.23 script:
JASS:
function GetSiphonGoldCache takes nothing returns gamecache
    return gg_trg_Siphon_Gold
    call DoNothing()
    return null
endfunction

function Initialize_SiphonGold_Variables takes nothing returns nothing
    local gamecache  g = GetSiphonGoldCache()
    local integer array gold

    local integer SiphonGoldAbility = 'A00C'
    set gold[1] = 8    // Level 1 this value is per second
    set gold[2] = 8    // Level 2 this value is per second
    set gold[3] = 8    // Level 3 this value is per second

    call StoreIntegerBJ( SiphonGoldAbility, "Ability", "Ability", g )
    call StoreIntegerBJ( gold[1], "Level1", "Gold", g )
    call StoreIntegerBJ( gold[2], "Level2", "Gold", g )
    call StoreIntegerBJ( gold[3], "Level3", "Gold", g )
endfunction

function SiphonGoldAbility takes nothing returns integer
    return GetStoredInteger(GetSiphonGoldCache(), "Ability", "Ability")
endfunction

function SiphonGoldGameCache2Trigger takes gamecache g returns trigger
    return g
    call DoNothing()
    return null
endfunction

function SiphonGoldHandle2Integer takes handle h returns integer
    return h
    call DoNothing()
    return 0
endfunction

function SiphonGoldInteger2Effect takes integer i returns effect
    return i
    call DoNothing()
    return null
endfunction

function SiphonGoldInteger2Unit takes integer i returns unit
    return i
    call DoNothing()
    return null
endfunction

function SiphonGoldInteger2Timer takes integer i returns timer
    return i
    call DoNothing()
    return null
endfunction

function SiphonGoldInteger2Trigger takes integer i returns trigger
    return i
    call DoNothing()
    return null
endfunction

function SiphonGoldInteger2TextTag takes integer i returns texttag
    return i
    call DoNothing()
    return null
endfunction

function Trig_Siphon_Gold_Floating takes nothing returns nothing
    local gamecache g = GetSiphonGoldCache()
    local texttag text1 = SiphonGoldInteger2TextTag( GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), "text1") )
    local texttag text2 = SiphonGoldInteger2TextTag( GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), "text2") )
    local integer transp = GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), "transp")
    if (transp < 100) then
        set transp = transp + 5
        call SetTextTagColorBJ( text1, 100, 100, 0.00, transp )
        call SetTextTagColorBJ( text2, 100, 100, 0.00, transp )
        call StoreIntegerBJ( transp, "transp", I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), g )
    else
        call DestroyTextTag(text1)
        call DestroyTextTag(text2)
        call DestroyTimer(GetExpiredTimer())
        call DestroyTrigger(GetTriggeringTrigger())
    endif
endfunction

function Trig_Siphon_Gold_Timer takes nothing returns nothing
    local gamecache g = GetSiphonGoldCache()
    local unit caster = SiphonGoldInteger2Unit( GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), "caster") )
    local unit target = SiphonGoldInteger2Unit( GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), "target") )
    local integer max = GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), "max")
    local integer floating = GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), "counter")
    local integer on = GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(caster)), "on")
    local integer floatgold = 0

    local trigger   t
    local timer     c

    if (on == 0) then
        if (floating > 1) then
            set floatgold = floating*2
            call StoreIntegerBJ( 0, "counter", I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), g )
        endif
        call DestroyEffect( SiphonGoldInteger2Effect( GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(caster)), "Effect1") ) )
        call DestroyEffect( SiphonGoldInteger2Effect( GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(caster)), "Effect2") ) )
        call DestroyTimer( SiphonGoldInteger2Timer( GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(caster)), "timer") ) )
        call DestroyTrigger( SiphonGoldInteger2Trigger( GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(caster)), "trigger") ) )
    else
        if ( GetPlayerState(GetOwningPlayer(target), PLAYER_STATE_RESOURCE_GOLD) > 1 ) then
            call AdjustPlayerStateBJ( 2, GetOwningPlayer(caster), PLAYER_STATE_RESOURCE_GOLD )
            call AdjustPlayerStateBJ( -2, GetOwningPlayer(target), PLAYER_STATE_RESOURCE_GOLD )
            if (floating == (max/4)) then
                set floatgold = max*2/4
                set floating = 0
            endif
            call StoreIntegerBJ( floating + 1, "counter", I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), g )
        elseif (floating > 1) then
            set floatgold = (floating-1)*2
            call StoreIntegerBJ( 0, "counter", I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), g )
        endif
    endif
    if (floatgold > 0) then
        set t = CreateTrigger(  )
        set c = CreateTimer()
        call TriggerRegisterTimerExpireEventBJ( t, c )
        call TriggerAddAction( t, function Trig_Siphon_Gold_Floating )
        call StartTimerBJ( c, true, 0.07  )
        call CreateTextTagUnitBJ( "+" + I2S(floatgold), caster, 0, 10, 100, 100, 100, 0 )
        call SetTextTagColorBJ( GetLastCreatedTextTag(), 100, 100, 0.00, 0 )
        call SetTextTagVelocityBJ( GetLastCreatedTextTag(), 100, 90 )
        call StoreIntegerBJ( SiphonGoldHandle2Integer(GetLastCreatedTextTag()), "text1", I2S(SiphonGoldHandle2Integer(c)), g )
        call CreateTextTagUnitBJ( "-" + I2S(floatgold), target, 0, 10, 100, 100, 100, 0 )
        call SetTextTagColorBJ( GetLastCreatedTextTag(), 100, 100, 0.00, 0 )
        call SetTextTagVelocityBJ( GetLastCreatedTextTag(), 100, 90 )
        call StoreIntegerBJ( SiphonGoldHandle2Integer(GetLastCreatedTextTag()), "text2", I2S(SiphonGoldHandle2Integer(c)), g )
        call StoreIntegerBJ( 0, "transp", I2S(SiphonGoldHandle2Integer(c)), g )
    endif
endfunction

function Trig_Siphon_Gold_Conditions takes nothing returns boolean
    return ( GetSpellAbilityId() == SiphonGoldAbility() )
endfunction

function Trig_Siphon_Gold_Actions takes nothing returns nothing
    local unit      caster = GetSpellAbilityUnit()
    local effect    e
    local gamecache g = GetSiphonGoldCache()
    local trigger   t = CreateTrigger(  )
    local timer     c = CreateTimer()
    local integer   level = GetUnitAbilityLevelSwapped(SiphonGoldAbility(), caster)
    set e = AddSpecialEffectTarget("war3mapImported\\goldout.mdx",GetSpellTargetUnit(),"origin")
    call StoreIntegerBJ( SiphonGoldHandle2Integer(e), "Effect1", I2S(SiphonGoldHandle2Integer(caster)), g )
    set e = AddSpecialEffectTarget("war3mapImported\\goldin.mdx",caster,"origin")
    call StoreIntegerBJ( SiphonGoldHandle2Integer(e), "Effect2", I2S(SiphonGoldHandle2Integer(caster)), g )
    call TriggerRegisterTimerExpireEventBJ( t, c )
    call TriggerAddAction( t, function Trig_Siphon_Gold_Timer )
    call StoreIntegerBJ( 1, "on", I2S(SiphonGoldHandle2Integer(caster)), g )
    call StoreIntegerBJ( SiphonGoldHandle2Integer(c), "timer", I2S(SiphonGoldHandle2Integer(caster)), g )
    call StoreIntegerBJ( SiphonGoldHandle2Integer(t), "trigger", I2S(SiphonGoldHandle2Integer(caster)), g )
    call StoreIntegerBJ( SiphonGoldHandle2Integer(GetSpellTargetUnit()), "target", I2S(SiphonGoldHandle2Integer(c)), g )
    call StoreIntegerBJ( SiphonGoldHandle2Integer(caster), "caster", I2S(SiphonGoldHandle2Integer(c)), g )
    call StoreIntegerBJ( 1, "counter", I2S(SiphonGoldHandle2Integer(c)), g )
    call StoreIntegerBJ( GetStoredInteger(g, "Gold", "Level" + I2S(level)), "max", I2S(SiphonGoldHandle2Integer(c)), g )
    call StartTimerBJ( c, true, (I2R(2) / I2R(GetStoredInteger(g, "Gold", "Level" + I2S(level)) ))  )
endfunction

function Trig_Siphon_Gold_End_Actions takes nothing returns nothing
    local unit      caster = GetSpellAbilityUnit()
    local effect    e
    local gamecache g = GetSiphonGoldCache()
    call StoreIntegerBJ( 0, "on", I2S(SiphonGoldHandle2Integer(caster)), g )
endfunction

//===========================================================================
function InitTrig_Siphon_Gold takes nothing returns nothing
    local integer i = 0
    local trigger t1 = CreateTrigger(  )
    local trigger t2 = CreateTrigger(  )
    local trigger g = CreateTrigger(  )
    set gg_trg_Siphon_Gold = SiphonGoldGameCache2Trigger(InitGameCache( "SiphonGold.w3v" ))
    call Initialize_SiphonGold_Variables()
    loop
        exitwhen i > 11
        if ( GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING ) then
            call TriggerRegisterPlayerUnitEventSimple( t1, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT )
            call TriggerRegisterPlayerUnitEventSimple( t2, Player(i), EVENT_PLAYER_UNIT_SPELL_ENDCAST )
        endif
        set i = i + 1
    endloop
    call TriggerAddCondition( t1, Condition( function Trig_Siphon_Gold_Conditions ) )
    call TriggerAddAction( t1, function Trig_Siphon_Gold_Actions )
    call TriggerAddCondition( t2, Condition( function Trig_Siphon_Gold_Conditions ) )
    call TriggerAddAction( t2, function Trig_Siphon_Gold_End_Actions )
endfunction
 

_whelp

New Member
Reaction score
54
Use vJass, it will make your code easier to read and more efficient... and those typecasting things are really outdated... Also, use [noparse]
JASS:
[/noparse] tags.
 

SanKakU

Member
Reaction score
21
and try to replace as many of the red functions as you can...
looks like you are having a gamecache problem, looks like the same one i had...
you'll have to search for thread by my name and hit the one with 1.24 in the title...someone helped me with that already.
well nevermind i don't really understand all that gamecache stuff...your problem may be quite different...

anyway you might need to get someone (perhaps yourself) to convert the jass into vjass so it's easier for some expert here to give you a hand.

oh wait a sec, i looked at your code again and i see your H2I function now...haha yeah...uhm...i'm not sure but it looks like your code is way too complicated...why don't you use for example ISGV and then do //Initialize_SiphonGold_Variables as a comment? it's easier to type ISGV many times and if the code takes up less space, you can read the entire trigger faster. especially if you already read the comments, you can ignore them...
edit: yeah this thread here http://www.thehelper.net/forums/showthread.php?t=137492 might help some...
 

Jesus4Lyf

Good Idea™
Reaction score
397
Everyone else is being kinda not useful.

Basically, your code stores a gamecache object typecasted to a trigger in the trigger variable. You will need to create a gamecache variable or something to store it instead.

This means you either need to indicate you have NewGen, or indicate that you know something about hashtables. If you have NewGen, someone can rewrite this for you a bit. But you haven't said you have NewGen, or are willing to use it.
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
Is there such a thing as a JASSer that doesn't use NewGen? (or at least JassHelper.)
 

SerraAvenger

Cuz I can
Reaction score
234
Is there such a thing as a JASSer that doesn't use NewGen? (or at least JassHelper.)

new ones.
actually, if your project is tiny and doesn't need much coding, it's most probably not necessary. But when you start to make more complex maps, it's incredibly helpful...

I guess you need a global hashtable. In this hashtable, you store handles to their handle id.
That way you can do

handle -> handleid:
StoreHandle( myHashTable, GetHandleId( handle ), 0, handle )
return GetHandleId( handle )

handleid -> handle:
return LoadHandle( myHashTable, GetHandleId( handle ), 0 )

This will mess up all your handle recycling, but it is 100% safe to use.

for the gamecache -> trigger...

just store the trigger into the gamecache!

for the gamecache, do what our friend 4Lyf said.
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
NewGen is really useful for JASSing.
It has JassHelper and TESH. :D
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top