• 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.

Im learning jass

Status
Not open for further replies.
Level 3
Joined
Oct 21, 2008
Messages
18
OKEY OKEY, i dont want to give up, some JASS cant defeat me. <--- these words help me a lot to continue

so, i m confused as any other beginner at/in JASS.

First off, WHAT IS NATIVE ???

And another thing, i dont understand how to find if target unit is Undeath/or other race

Im trying to remake holy bolt dealing damage to / or healing (depending at intelligence of hero) target unit. (i hoped it's simple enough to be done)

My start was creating trigger with condition which determines what is the ID of used spell. (just copying the beginning of tutorial)
Then making my own Locals, (integer - for damage, unit - caster, unit - enemy) .............and, then i started to think about how to find if unit is Undeath/or another race, If its mechanical/non......so i did Locals, unittype tralalalaa.............lala, and that's the point where i stopped.

Should i use If/Then/Else(?) where im gonna do something like this

If Unittype "U" == tralala (i have no clue what to put instead of TRALALA)

call Some cool damage function
Else
call Some extra-cool healing function





HMMM? thanks for help, im sure this is hundred repeated question, but i havent found proper answer, all tutorials (or just those i went through) are just about setting integers and unit groups, movings units, and anything else i dont need

- im sure i did at least 378 grammatical mistakes and spelling is a word i dont know, but be sure that learnig JASS is not a good activity at 5:35 AM
 
Level 11
Joined
Apr 6, 2008
Messages
760
i cant explain exactly what a native is, but i try.

a native dont call a function.

lets say for eg. UnitDamageTargetBJ

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

it calls a native UnitDamageTarget

and if we check that its

JASS:
native UnitDamageTarget takes unit whichUnit, widget target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean

as u can see if calls no function, so the diffrence is if u use a BJ rather than a native u will call a function that calls that native (not in all cases)

And yes u should do a if/then/else

eg.

JASS:
function Action takes nothing returns nothing
      local unit Caster = GetTriggerUnit()
      local unit Target = GetSpellTargetUnit()
      
      //check if it is a undead or a enemy unit (else it will heal non-undead enemys
      if IsUnitType(Target,UNIT_TYPE_UNDEAD) or IsUnitEnemy(Target,GetOwningPlayer(Caster)) then
           call UnitDamageTarget(Caster,Target,100.,false,false,null,null,null
      else
           call SetWidgetLife(Target,GetWidgetLife(Target)+100))
      endif
      
      set Caster = null
      set Target = null
endfunction

function Condition takes nothing returns boolean
     return GetSpellAbilityId()=='A000'
endfunction

function init takes nothing returns nothing
    local trigger trig = CreateTrigger()

    call TriggerRegisterAnyUnitEventBJ(trig,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(trig,Condition(function Condition))
    call TriggerAddAction(trig,function Action)
    
    set trig = null
endfunction


well that is the best i can do on this little time, i suck at explaining :(
 
Level 9
Joined
Apr 3, 2008
Messages
700
....and, then i started to think about how to find if unit is Undeath/or another race, If its mechanical/non......so i did Locals, unittype tralalalaa....

You can set spell targets in objects editor.
You don't need if/then/else.
You don't need to call another function, it will make the trigger slower.
You can make a trigger on GUI, then convert it to Jass and look what functions do you need.
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
A native function is a function that can directly be translated into whatever the underlying structure is. In warcraft 3's case, that's probably c or c++.
A non-native function is a function that contains a functionbody composed of other native / non-native functions.
You can see a native function as an "atomic" function: you can't possibly split it up, because it's directly translatable in e.g. c++. Custom functions (non-natives) aren't atomic because they're a sequence of other function calls.

Whenever a function is called, it has to be placed on the run-time stack, and each additional function call corresponds with a small loss of efficiency. That's why, for example, you should never write:
GetConvertedPlayerId(player)
but instead should write
GetPlayerId(player) + 1

That doesn't mean you're not allowed to use BJ functions (some prove useful, e.g. CountUnitsInGroup(group)), nor does it mean that you have to write messy code all in one function. Often it'll be good to split up a large problem in different smaller functions. Not because it's more efficient (it isn't) but because it's easier to modify and debug. Tracking down where a bug occurs in your code simply is easier when you have small functions and you can trace which function the bug occurs at...

as u can see if calls no function, so the diffrence is if u use a BJ rather than a native u will call a function that calls that native (not in all cases)
Correction: In nearly all cases, BJ's call natives. When they don't, they call other BJ's (and thus are even less efficient)

2) To find the race of a unit, you use:
constant native GetUnitRace takes unit whichUnit returns race

You have following races in warcraft 3:
constant race RACE_DEMON
constant race RACE_HUMAN
constant race RACE_NIGHTELF
constant race RACE_ORC
constant race RACE_OTHER
constant race RACE_UNDEAD

the function IsUnitType(Target,UNIT_TYPE_UNDEAD) will only return true when the unit TYPE of the unit is undead (it's a unit classification which can be: mechanical, undead, worker, town hall, etc.)
 
Status
Not open for further replies.
Top