HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Where oh where is that Boomerang? Oh No! h2i? crap!

09-13-2009, 05:39 AM#1
Brash
i'm not really good with jass but i can usually figure out how to plug a script, but i can't program worth a crap outside of gui.. which isn't programming, yet i had a script from someone a long time ago that generated a very nice dual boomerange effect.. similiar to that of Rexxars twin axes from dota.

but, problem is the code is broken now since it was h2i script so i couldnt' host it on bnet anymore and it seems too complex for me to break it down into that new hashtable system for a conversion.. which i dont even understand hashtables.

soo, i was wondering if anyone knows of any new script or gui i could use that is solid/unleakable?
09-13-2009, 05:52 AM#2
Earth-Fury
Quote:
Originally Posted by Brash
but i can't program worth a crap outside of gui..
So learn. Your post shows that you obviously have a brain in your head, so get to learning! :P The sooner you start, the sooner you're done, and the less time you waste on GUI crap.

Quote:
Originally Posted by Brash
which isn't programming
Yes, it is programming. It's using a predefined grammar to define a series of behaviours. It's just not a good way to program.

Quote:
Originally Posted by Brash
but, problem is the code is broken now since it was h2i script so i couldnt' host it on bnet anymore and it seems too complex for me to break it down into that new hashtable system for a conversion.. which i dont even understand hashtables.

If it only uses H2I, and no other uses of the return bug, simply delete the H2I function and replace all instances of calling it with GetHandleId(). If it uses local handle variables (gamecache + return bug), look at this: http://www.wc3c.net/showthread.php?t=106558 It's basically handle vars for 1.24(b). (May work as a drop-in replacement, may need some more work. Requires vJass which requires using the NewGen editor.)

If you have further questions or require further assistance, please post the code you are asking aboot.
09-13-2009, 07:36 AM#3
Brash
This is in the map's main script.. not in a regular trig. you know, where the name of the map is.. and it loads up during the loading screen.



Collapse JASS:
// You need all functions , The first 5 are there to make it easy to copy and change it


function AxeID takes nothing returns integer
return 'h00Y'  //Just replace it with your Unit ID or copy the unit ( It is the Axe missle )
endfunction

function DamageAbilityID takes nothing returns integer
return 'A08R'  //Just replace it with your Ability ID or copy the Ability ( Its the Damage spell of the Axes )
endfunction

function AbilityID takes nothing returns integer
return 'A08Q'  //Just replace it with your Ability ID or copy the Ability ( It is the Ability which calls the functions ,In this case the Mountainking got it ) )
endfunction

function periodictime takes nothing returns real
return 0.03   // This is the time between the movement of the Axe ( Similar to a peridic Event ) , 0.03 is good . higher Valur will cause less lags but is not such smooth
endfunction

function boomspeed takes nothing returns real
return 26.00   // The Speed of the Axe
endfunction

function Spreadangle takes nothing returns real
return 35.00   //The Spread  between both axes (Angle)
endfunction


// Cache functions ( Not needed to change )====================================================

function H2I takes handle h returns integer 
return h 
return 0 
endfunction 

function I2U takes integer i returns unit 
return i 
return null 
endfunction 

function I2E takes integer i returns effect 
return i 
return null 
endfunction 

function I2L takes integer i returns location 
return i 
return null 
endfunction 

function I2It takes integer i returns item 
return i 
return null 
endfunction 


function get_object_iparam takes handle h, string key returns integer 
return GetStoredInteger(udg_cache, I2S(H2I(h)), key) 
endfunction 

function set_object_iparam takes handle h, string key, integer val returns nothing 
call StoreInteger(udg_cache, I2S(H2I(h)), key, val) 
endfunction 

function get_object_rparam takes handle h, string key returns real 
return GetStoredReal(udg_cache, I2S(H2I(h)), key) 
endfunction 

function set_object_rparam takes handle h, string key, real val returns nothing 
call StoreReal(udg_cache, I2S(H2I(h)), key, val) 
endfunction 

function get_object_bparam takes handle h, string key returns boolean 
return GetStoredBoolean(udg_cache, I2S(H2I(h)), key) 
endfunction 

function set_object_bparam takes handle h, string key, boolean val returns nothing 
call StoreBoolean(udg_cache, I2S(H2I(h)), key, val) 
endfunction 

function get_object_sparam takes handle h, string key returns string 
return GetStoredString(udg_cache, I2S(H2I(h)), key) 
endfunction 

function set_object_sparam takes handle h, string key, string val returns nothing 
call StoreString(udg_cache, I2S(H2I(h)), key, val) 
endfunction 

function get_object_uparam takes handle h, string key returns unit 
return I2U(GetStoredInteger(udg_cache, I2S(H2I(h)), key)) 
endfunction 

function get_object_eparam takes handle h, string key returns effect 
return I2E(GetStoredInteger(udg_cache, I2S(H2I(h)), key)) 
endfunction 

function get_object_lparam takes handle h, string key returns location 
return I2L(GetStoredInteger(udg_cache, I2S(H2I(h)), key)) 
endfunction 

function get_object_itparam takes handle h, string key returns item 
return I2It(GetStoredInteger(udg_cache, I2S(H2I(h)), key)) 
endfunction 

function flush_object takes handle h returns nothing 
call FlushStoredMission(udg_cache, I2S(H2I(h))) 
endfunction

//====================================================================================


then this is for moving it in a trig

Collapse JASS:
function Trig_Boomerang_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == AbilityID() ) ) then
        return false
    endif
    return true
endfunction

function BooMove takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local location casterloc = GetUnitLoc(I2U(get_object_iparam(t,"caster")))
    local unit boo1 = I2U(get_object_iparam(t,"boo1"))
    local boolean bol = get_object_bparam(t,"bol")
    local location loc1 = GetUnitLoc(boo1)
    local location mov1 = PolarProjectionBJ(loc1, boomspeed(), GetUnitFacing(boo1))
    local location target = Location(get_object_rparam(t,"x"),get_object_rparam(t,"y"))
    local real distance1 = DistanceBetweenPoints(loc1, target)
    local real face1 = ( distance1/((1.00/periodictime())*boomspeed()))/1.25
    call SetUnitPositionLoc( boo1, mov1 )
    if bol then
    else
        set distance1 = ((DistanceBetweenPoints(loc1, casterloc)))
        set face1 = ( distance1/((1.00/periodictime())*boomspeed()))/4.0
    endif
    if (distance1 < 80) then
        if bol == true then
            call set_object_bparam(t,"bol", false)
            call TimerStart(t,periodictime(),false,function BooMove)
        else 
            if (distance1 < 45) then
                call flush_object(boo1)
                call RemoveUnit( boo1 )
                call PlaySoundOnUnitBJ( gg_snd_TwinBladesReceive, 100, udg_TwinBladesCasterU )
                call SetUnitAnimationByIndex( udg_TwinBladesCasterU, 2 )
                call SetUnitTimeScalePercent( udg_TwinBladesCasterU, 300.00 )
                call StartTimerBJ( udg_TwinBlades_AnimationTimer, false, 1.00 )
            else
            call TimerStart(t,periodictime(),false,function BooMove)
            endif
        endif
    else
        call TimerStart(t,periodictime(),false,function BooMove)
    endif
    if bol then
        call SetUnitFacingToFaceLocTimed( boo1, target, face1 )
    else 
        call SetUnitFacingToFaceLocTimed( boo1, casterloc, face1 )
    endif
    call RemoveLocation(target)
    call RemoveLocation(casterloc)
    call RemoveLocation(mov1)
    call RemoveLocation(loc1)
endfunction

function Trig_Boomerang_Actions takes nothing returns nothing
    local unit caster = GetSpellAbilityUnit()
    local location casterloc = GetUnitLoc(caster)
    local location target = GetSpellTargetLoc()
    local unit boo1
    local unit boo2 
    local location target2
    local timer t =CreateTimer()
    local timer t2 =CreateTimer()
    local real angle = AngleBetweenPoints(casterloc, target)
    local real distance = DistanceBetweenPoints(casterloc, target) 
    if distance < 450 then 
        set target2 = PolarProjectionBJ(casterloc, 450.00, angle)
    else 
        set target2 = target
    endif
    call CreateNUnitsAtLoc( 1, AxeID(), GetOwningPlayer(GetSpellAbilityUnit()), casterloc, (angle+Spreadangle()))
    set boo1 = GetLastCreatedUnit()
    call SetUnitAbilityLevelSwapped( DamageAbilityID(), GetLastCreatedUnit(), GetUnitAbilityLevelSwapped(GetSpellAbilityId(), GetSpellAbilityUnit()) )
    call CreateNUnitsAtLoc( 1, AxeID(), GetOwningPlayer(GetSpellAbilityUnit()), casterloc, (angle-Spreadangle()))
    set boo2 = GetLastCreatedUnit()
    call SetUnitAbilityLevelSwapped( DamageAbilityID(), GetLastCreatedUnit(), GetUnitAbilityLevelSwapped(GetSpellAbilityId(), GetSpellAbilityUnit()) )
    call TimerStart(t,periodictime(),false,function BooMove)
    call set_object_iparam(t,"caster", H2I(caster))
    call set_object_iparam(t,"boo1", H2I(boo1))
    call set_object_bparam(t,"bol", true)
    call set_object_rparam(t,"x", GetLocationX(target2))
    call set_object_rparam(t,"y", GetLocationY(target2))
    call TimerStart(t2,periodictime(),false,function BooMove)
    call set_object_iparam(t2,"caster", H2I(caster))
    call set_object_iparam(t2,"boo1", H2I(boo2))
    call set_object_bparam(t2,"bol", true)
    call set_object_rparam(t2,"x", GetLocationX(target2))
    call set_object_rparam(t2,"y", GetLocationY(target2))
    call RemoveLocation(casterloc)
    call RemoveLocation(target)
    call RemoveLocation(target2) 
endfunction

//===========================================================================
function InitTrig_Boomerang takes nothing returns nothing
    set gg_trg_Boomerang = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Boomerang, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Boomerang, Condition( function Trig_Boomerang_Conditions ) )
    call TriggerAddAction( gg_trg_Boomerang, function Trig_Boomerang_Actions )
endfunction


and here is some cache it needed

Trigger:
Cache
Collapse Events
Map initialization
Conditions
Collapse Actions
-------- Creating the Cache for the handy functions in the mapscript --------
Game Cache - Create a game cache from cache
Set cache = (Last created game cache)


Then i have a few other trigs that are gui for hit-detection and such but they are easy to figure out.

But all that script above that i pasted is too tough for me to figure out how to convert.
I look at it and start sweating and getting stressed out. it just seems so over my head to convert.
09-13-2009, 11:30 AM#4
TheWye
Hmm.. I might be able to work on something for this. One question though, do you use JNGP?

EDIT: try replacing the "main script" with this:
Collapse JASS:
// You need all functions , The first 5 are there to make it easy to copy and change it


function AxeID takes nothing returns integer
return 'h00Y'  //Just replace it with your Unit ID or copy the unit ( It is the Axe missle )
endfunction

function DamageAbilityID takes nothing returns integer
return 'A08R'  //Just replace it with your Ability ID or copy the Ability ( Its the Damage spell of the Axes )
endfunction

function AbilityID takes nothing returns integer
return 'A08Q'  //Just replace it with your Ability ID or copy the Ability ( It is the Ability which calls the functions ,In this case the Mountainking got it ) )
endfunction

function periodictime takes nothing returns real
return 0.03   // This is the time between the movement of the Axe ( Similar to a peridic Event ) , 0.03 is good . higher Valur will cause less lags but is not such smooth
endfunction

function boomspeed takes nothing returns real
return 26.00   // The Speed of the Axe
endfunction

function Spreadangle takes nothing returns real
return 35.00   //The Spread  between both axes (Angle)
endfunction


// Cache functions ( Not needed to change )====================================================

function get_object_iparam takes agent h, string name returns integer 
return LoadInteger(udg_hashtable, GetHandleId(h), StringHash(name)) 
endfunction 

function set_object_iparam takes agent h, string name, integer val returns nothing 
if (val==0) then
    call RemoveSavedInteger(udg_hashtable, GetHandleId(h), StringHash(name))
else
    call SaveInteger(udg_hashtable, GetHandleId(h), StringHash(name), val)
endif
endfunction 

function get_object_rparam takes agent h, string name returns real 
return LoadReal(udg_hashtable, GetHandleId(h), StringHash(name))
endfunction 

function set_object_rparam takes agent h, string name, real val returns nothing 
if (val==0.0) then
    call RemoveSavedReal(udg_hashtable, GetHandleId(h), StringHash(name))
else
    call SaveReal(udg_hashtable, GetHandleId(h), StringHash(name), val)
endif
endfunction 

function get_object_bparam takes agent h, string name returns boolean 
return LoadBoolean(udg_hashtable, GetHandleId(h), StringHash(name))
endfunction 

function set_object_bparam takes agent h, string name, boolean val returns nothing 
if (val==false) then
    call RemoveSavedBoolean(udg_hashtable, GetHandleId(h), StringHash(name))
else
    call SaveBoolean(udg_hashtable, GetHandleId(h), StringHash(name), val)
endif
endfunction 

function get_object_sparam takes agent h, string name returns string 
return LoadStr(udg_hashtable, GetHandleId(h), StringHash(name))
endfunction 

function set_object_sparam takes agent h, string name, string val returns nothing 
if ((val=="") or (val==null)) then
    call RemoveSavedString(udg_hashtable, GetHandleId(h), StringHash(name))
else
    call SaveStr(udg_hashtable, GetHandleId(h), StringHash(name), val)
endif
endfunction 

function get_object_uparam takes agent h, string name returns unit 
return LoadUnitHandle( udg_hashtable, GetHandleId(h), StringHash(name))
endfunction 

function get_object_eparam takes agent h, string name returns effect 
return LoadEffectHandle( udg_hashtable, GetHandleId(h), StringHash(name))
endfunction 

function get_object_lparam takes agent h, string name returns location 
return LoadLocationHandle( udg_hashtable, GetHandleId(h), StringHash(name))
endfunction 

function get_object_itparam takes agent h, string name returns item 
return LoadItemHandle( udg_hashtable, GetHandleId(h), StringHash(name))
endfunction 

function flush_object takes agent h returns nothing 
call FlushChildHashtable(udg_hashtable, GetHandleId(h))
endfunction

//====================================================================================

EDIT2: oh I almost forgot, you need to initialize the hashtable too:
Trigger:
Collapse Events
Map initialization
Conditions
Collapse Actions
Hashtable - Create a hashtable
Set hashtable = (Last created hashtable)

hope that works :p

EDIT3: interesting... I just realized you can actually attach stuffs to handles with GUI in version 1.24b now... This should help a lot of GUI users.