• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] 4 Questions

Status
Not open for further replies.
Level 5
Joined
Oct 9, 2008
Messages
112
Hi its me again! ;>

I hope ya can help me again:goblin_yeah::
1. :> Okay, how can i transport Local Variables between two more more functions?

2. :> And why the JNGP says that the Return is missing if i return a variable?
3. :> Is it right that when i call a function like this in GUI?=
call functionA(GetTriggeringUnit())
that i can make this?:
function functionA takes unit u returns nothing
call RemoveUnit(u)
endfunction
4. and the last one! ;> how can i call functions likea chain?
like:
call functionA()
in function functionA
call functionB()
in functionB
call functionC()
in functionC
call functionA()

okay thank you in advance i hope there are some resolutions! ;>>
:goblin_jawdrop:
-Atami :goblin_yeah:
 
Atami said:
Okay, how can i transport Local Variables between two more more functions?

You need to use global variables or hashtables.

Atami said:
And why the JNGP says that the Return is missing if i return a variable?

We can't tell you unless you post your code.

Atami said:
Is it right that when i call a function like this in GUI?=

Yes, that would work.

Atami said:
and the last one! ;> how can i call functions likea chain?

Um.

JASS:
function C takes nothing returns nothing
endfunction

function B takes nothing returns nothing
    call C()
endfunction

function A takes nothing returns nothing
    call B()
endfunction
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
JASS:
function C takes nothing returns nothing
endfunction
I think he wants to continue the chain with function C.

JASS:
function C takes nothing returns nothing
    call A.execute() // Or A.evaluate() 
endfunction
You could also use ExecuteFunc("YourFunctionName") if the function doesn't take any parameters though it may be slower than execute/evaluate.

You should know that will cause an infinite loop so be sure to know how to stop it.
 
Level 5
Joined
Oct 9, 2008
Messages
112
Okay heres the Code, i hope u can help me! :>

JASS:
function lightning_storm_height takes unit caster, boolean b returns nothing
    local real height = 500.00
    local real rate = 100.00
    call UnitAddAbilityBJ( 'Arav', caster )
    call SetUnitFlyHeightBJ( caster, height, rate )
    call UnitRemoveAbilityBJ( 'Arav', caster )
    if ( not ( GetUnitFlyHeight(caster) >= height ) ) then
            set b = true
            call cast_lightning_storm(b) // the editor says that this i wrong!
        else
            set b = false
        endif
endfunction

function lightnings takes unit caster returns nothing
    call RemoveUnit(caster)
endfunction

function cast_lightning_storm takes unit caster, boolean b returns nothing
    local boolean b
    call lightning_storm_height(caster, b)
if (b == true) then
    call lightnings(caster)
    set b = false
    else
endif
endfunction
 
Last edited:
Level 11
Joined
Sep 12, 2008
Messages
657
alot of BJS, no use to the else, unorganized.. and i can allready see this

JASS:
function cast_lightning_storm takes unit caster, boolean b returns nothing
    call lightning_storm_height(caster, b)
if (b == true) then
    call lightnings(caster)
    set b = false
    else
endif

no endfucntion, no calls on the else, no idea why you set b to false on the end.

other then that, you did not return a value, so theres nothing to return..
if you put endfunction, it will probably solve that.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
JASS:
function cast_lightning_storm takes unit caster returns nothing
    local real height = 500.0
    local boolean b = UnitAddAbility(caster, 'Amrf')
    call SetUnitFlyHeight(caster, height, 100.0)
    if GetUnitFlyHeight(caster) < height then
        call RemoveUnit(caster)
    elseif b then
        call UnitRemoveAbility(caster, 'Amrf' )
    endif
endfunction
 
Level 11
Joined
Sep 12, 2008
Messages
657
basicly, to avoid bj's you remove the "BJ" part,
most of the calls will work using that.

bribe's way will probably replace ALL your functions with 1.
makes it alot more efficent.

and btw, BJS are bad because they call another function,
so it consumes more CPU.

while non BJS are natives, that just take something, and return something else instantly.
you should really get jass new gen pack... i've learned vjass/jass easly with it.

anachron's signature link:
http://www.hiveworkshop.com/forums/tutorial-submission-283/how-download-install-confige-jngp-160547/

good luck.
 
Level 11
Joined
Sep 12, 2008
Messages
657
oh.. so why dont you look at the function list,
why dont you use library's etc?

this is your code in a library: ( before bribe's imporvement )

JASS:
library Lightnints // initializer YourInitCodeIfYouGot1 requires Required librarys if you use any.

// if you use initializer/requires, just remove the comments, as you probably saw i added. and then write library name, seperate names with comas ( , )

private function LightningStormHeight takes unit caster, boolean b returns nothing
    call UnitAddAbility(caster, 'Arav')
    call UnitRemoveAbility(caster, 'Arav')
    call SetUnitFlyHeight(caster, 500, 100)
        if not GetUnitFlyHeight(caster) >= 500 then
            set b = true
            call CastLightningStorm(b) // the editor says that this i wrong!
        else
            set b = false
        endif
endfunction

private function RemoveLightning takes unit caster returns nothing
    call RemoveUnit(caster)
endfunction

function CastLightningStorm takes unit caster, boolean b returns nothing
    local boolean b
    call LightningStormHeight(caster, b)
            if (b == true) then
                    call RemoveLightning(caster)
                    set b = false
            endif
endfunction

endlibrary

this is a very bad example.. cuz this is a rather easy code..
i've fixed BJS for you to see btw.

theres also struct way, but im actually working on my code atm.. so cant show you it atm.

note that i did this without we.. so it might bug a little bit.

oh yeah, and if you didnt know, you can also put it in a seperate trigger,
instead of map header.
 
Level 5
Joined
Oct 9, 2008
Messages
112
I dont know what a libray is... i never learned vjass or jass i try to learn it by doing but evrything is wrong. what i do... Heres the code with Comment please help..! :>
JASS:
function lightning_storm_height takes unit caster returns nothing
    local real height = 500.00
    local real rate = 100.00
    call UnitAddAbility(caster,'Arav')
    call SetUnitFlyHeight(caster, height, rate)
    call UnitRemoveAbility(caster, 'Arav')
    call lightnings() // Why it always says "undeclared function lightnings" WHY? xD
endfunction

function lightnings takes unit caster returns nothing
    call RemoveUnit(caster)
endfunction

function cast_lightning_storm takes unit caster returns nothing
    call lightning_storm_height(caster)
endfunction

SOLVED becuz i started to read the best jass tutorial ever seen! :>
http://www.hiveworkshop.com/forums/...als-280/beginning-jass-tutorial-series-30765/
 
Last edited:
Level 11
Joined
Sep 12, 2008
Messages
657
hmm.. are you sure you have last jasshelper? (0.A.2.B)?
if not, download it in the link i gave you for the download of jngp.

how do you check? press the "About" button in jasshelper.
and look for version: "" inside those "" it says version number.

btw, never put boolean b with no setup,
it sometimes errors and stops the code from going on.

other then that, i got no clue.

and dont do ( not ( just do not GetUnitFlyHeight.. blah blah

edit: i copied it, and you allready use boolean b.
its the takes unit caster, boolean b.

takes X/Y/Z are locals, you can change them aswell.
 
Level 5
Joined
Oct 9, 2008
Messages
112
Okay Guys, why i the guys (caster) does not get any damage? and how can i make the UnitDamageTargetBJ(UDTBJ) to UnitDamageTarget(UDT), if i want to make UDTBJ i dont have any problems but if i make UDT the syntax check says that i dont have enough arguments to pass... :> Please help me!

JASS:
function lightnings takes unit caster, real damage returns nothing
    call UnitDamageTargetBJ(caster, caster, damage, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL)
endfunction

function lightning_storm_height takes unit caster returns nothing
    local real height = 500.00
    local real rate = 100.00
    call UnitAddAbility(caster,'Arav')
    call SetUnitFlyHeight(caster, height, rate)
    call UnitRemoveAbility(caster, 'Arav')
endfunction

function ls_damage takes integer level returns real
    local real damage = 150 * level
    return damage
endfunction

function ls_ini takes unit caster returns nothing
    local real damage
    call ls_damage(GetUnitAbilityLevelSwapped('A000', caster))
    call lightning_storm_height(caster)
    call lightnings(caster, damage)
endfunction
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
When you're replacing a BJ with the actual function, you can't just change the name to the non-BJ one. You need to pay attention to how the BJ called the native, the function you're trying to inline.

To inline UnitDamageTargetBJ, look at how the function calls the native:
JASS:
function UnitDamageTargetBJ takes unit whichUnit, unit target, real amount, attacktype whichAttack, damagetype whichDamage returns boolean
    return UnitDamageTarget(whichUnit, target, amount, true, false, whichAttack, whichDamage, WEAPON_TYPE_WHOKNOWS)
endfunction
Basically the inlined version is UnitDamageTarget. As you can see, it takes more parameters than the BJ one.

To inline successfully, it might help to understand the native. You should try looking up the native to see what each parameter might do.
JASS:
native UnitDamageTarget takes unit whichUnit, widget target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean

The inlined version of your code should look something like this:
JASS:
call UnitDamageTarget(caster, caster, damage,false, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)

Try practicing inlining with the GetUnitAbilityLevelSwapped in your code. It should be fairly easy to do.
JASS:
function GetUnitAbilityLevelSwapped takes integer abilcode, unit whichUnit returns integer
    return GetUnitAbilityLevel(whichUnit, abilcode)
endfunction
 
Level 5
Joined
Oct 9, 2008
Messages
112
When you're replacing a BJ with the actual function, you can't just change the name to the non-BJ one. You need to pay attention to how the BJ called the native, the function you're trying to inline.

To inline UnitDamageTargetBJ, look at how the function calls the native:
JASS:
function UnitDamageTargetBJ takes unit whichUnit, unit target, real amount, attacktype whichAttack, damagetype whichDamage returns boolean
    return UnitDamageTarget(whichUnit, target, amount, true, false, whichAttack, whichDamage, WEAPON_TYPE_WHOKNOWS)
endfunction
Basically the inlined version is UnitDamageTarget. As you can see, it takes more parameters than the BJ one.

To inline successfully, it might help to understand the native. You should try looking up the native to see what each parameter might do.
JASS:
native UnitDamageTarget takes unit whichUnit, widget target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean
The inlined version of your code should look something like this:
JASS:
call UnitDamageTarget(caster, caster, damage,false, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
Try practicing inlining with the GetUnitAbilityLevelSwapped in your code. It should be fairly easy to do.
JASS:
function GetUnitAbilityLevelSwapped takes integer abilcode, unit whichUnit returns integer
    return GetUnitAbilityLevel(whichUnit, abilcode)
endfunction


Yeah my jasshelper show me how the function should looks like, but the boolean attack and boolean range still confusing me...
 
Level 11
Joined
Sep 12, 2008
Messages
657
this is how:

JASS:
call UnitDamageTarget(caster, caster, damage ,true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)

tell me if something else bugs.

edit: goddam it, im slow =[
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
Yeah my jasshelper show me how the function should looks like, but the boolean attack and boolean range still confusing me...
I'm not entirely sure what they do, but I think they determine how the AI reacts to the damage.
attack determines whether the damage should be thought of as an attack or spell.
range determines whether the damage should be thought of as ranged damage or melee damage.

There might be more to it than that.
 
Status
Not open for further replies.
Top