• 🏆 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!

Help with learning triggers

Status
Not open for further replies.
@Magtheridon - its like this:
JASS:
function JOIN_US takes unit GUIer returns nothing
    call IssueImmediateOrder(GUIer,"smart")
    call TriggerSleepAction (ENOUGH_TIME_FOR_A_GUIER_TO_UNDERSTAND_HOW_GUI_IS_INEFFICIENT)
    if DidNotQuit then
        call BJDebugMsg("A GUIer has went to the JASS side ^^")
        call set NUMBER_OF_JASSERS = NUMBER_OF_JASSERS + 1
        call UnitGroupPraiseUnit(JASSERS, GUIer)
    else
        call JOIN_US(GUIer)
    endif
endfunction

/*
  anyway, lets not force him, he will soon realize that he needs to learn jass anyway... 
  then he will say "I should have listened to them"
*/
 
Last edited:
@Adiktuz: ^^ lol (infinite loop)
@rysnt11: :D You're going to LOVE vJASS ^^
@Ketsuno Anson: Sorry :/
If you have any questions, just ask ^^

Btw, if you want to start with GUI, I suggest you go with hashtables instead of indexing
since indexing can be a tad .. confusing/troublesome. (Even "I" don't know how to
create a good indexing system.) That's why I went straight to vJASS ^^

With GUI, you need to make your spells MUI
That means that more than 1 unit can cast the spell at once.
In JASS, you don't even have to worry about it because your scripts are going to
be MUI anyways :p

Try reading those tutorials on hashtables :)
They're VERY useful and when you want to learn JASS, they'll be VERY important
for your comprehension of how utilities like TimerUtils or Table work. That's when
you'll be able to move to vJASS ^^

Here's a small exercise I prepared for you:

-Write a spell in GUI that uses hashtables. This spell creates a ball of fire that will deal
100 damage to all units within an 800 range for 5 seconds.

Think you can pull it off? Try it ^^
 
Here's a few thing you should know in general:

JASS:
function Actions takes nothing returns nothing
    // here are your actions
endfunction

function Conditions takes nothing returns boolean
    return true
endfunction

function Init takes nothing returns nothing
    set gg_trg_SomeTrig = CreateTrigger()
    call TriggerAddAction(gg_trg_SomeTrig,function Actions)
    call TriggerAddCondition(gg_trg_SomeTrig,function Conditions)
endfunction

That my friend is the General Format for a "trigger" in JASS
Later on, I'll teach you a MUCH more efficient format.


believe me, go learn jass directly coz it's 200% more efficient...

Just to be exact:
According to my results after going through a few tests:

Speed:
GUI: 100% (Assume it's the norm)
JASS: 244% (It's 2.44 times as fast as GUI)
vJASS: 217% (The real purpose of vjass is to make coding easier, but the excess arrays produced by structs make it a bit slower than JASS)

EDIT:

If you have JNGP, you can learn JASS in under 3 days ^^
 
Level 17
Joined
Jan 21, 2010
Messages
2,111
Umm...
I haven't got my new modem, so, i can online from the pc,i'm online all the day with my hp...
Edit:
JASS:
scope simpledamagespell initializer init
private function SimpleDamage takes nothing returns boolean
//here we check if the casted spell corresponds to the spells that we want
//this code works for
//i didn't use a local for the unit since i think two calls is tolerable
if GetSpellAbilityId()=='A000' 
then 
call UnitDamageTarget (GetTriggerUnit (), GetSpellTargetUnit (), 100* (GetUnitAbilityLevel (GetTriggerUnit(), 'A000')), false, false,ATTACK_TYPE_CHAOS, DAMAGE_TYPE_DIVINE, null) 
endif
//here we deal damage to target
//we need this line since the function should return a boolean
return false
endfunction
//this is the function tun at map init
private function init takes nothing returns nothing
//here we create a trigger
local trigger t=CreateTrigger ()
local integer i=0
loop
exitwhen i>15
//we register the event unit -  A Unit starts the eedect of an ability
//For al player
call TriggerRegisterPlayerUnitEvent (t, Player(1), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set i=i+1
endloop
//we merge the actions into the condition becase its faster than actions
call TriggerAddCondition (t, Condition(function SimpleDamage))
set t=null
endfunction
endscope

That's what i write in my newgen...
 
Last edited:
Level 9
Joined
May 14, 2011
Messages
524
@Adiktuz: ^^ lol (infinite loop)
@rysnt11: :D You're going to LOVE vJASS ^^
@Ketsuno Anson: Sorry :/
If you have any questions, just ask ^^

Btw, if you want to start with GUI, I suggest you go with hashtables instead of indexing
since indexing can be a tad .. confusing/troublesome. (Even "I" don't know how to
create a good indexing system.) That's why I went straight to vJASS ^^

With GUI, you need to make your spells MUI
That means that more than 1 unit can cast the spell at once.
In JASS, you don't even have to worry about it because your scripts are going to
be MUI anyways :p

Try reading those tutorials on hashtables :)
They're VERY useful and when you want to learn JASS, they'll be VERY important
for your comprehension of how utilities like TimerUtils or Table work. That's when
you'll be able to move to vJASS ^^

Here's a small exercise I prepared for you:

-Write a spell in GUI that uses hashtables. This spell creates a ball of fire that will deal
100 damage to all units within an 800 range for 5 seconds.

Think you can pull it off? Try it ^^
I need someone to help me with the spell i posted...i alr change the dummy thing but still dont work
 
Status
Not open for further replies.
Top