• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Rooftrellen Stealth Spell

Status
Not open for further replies.
Level 5
Joined
Nov 29, 2007
Messages
106
Hello everyone
can someone tell me step by step with variables and triggers how to do skill based on Treant Protector dota spell ? here is how it works:

Changes a target friendly unit's appearance so that it blends in with the forest. It becomes invisible to enemy eyes, but it must remain near a tree, or the Guise is lost.

So you can be invisible only if you are near trees, but if you go away from trees the invisible is lost.

I have got only 2 types of trees Summer Lordearon trees and Summer Lordearon corrupted trees (Undeads)
 
Level 5
Joined
Nov 29, 2007
Messages
106
It's only use able on Heroes (only allied heroes) and it's spell with 4 levels :
Range: 500
Mana Cost: 90 / 80 / 70 / 60
Cooldown: 3.0 Seconds
Activation
Applies Camouflage to target for 15 / 30 / 45 / 60 seconds.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
I've made a test map
Enjoy ;D
I used Regions instead of checking on Destructibles
It could also be used, the same method as it is

EDIT:
Added allied Hero and Unit to check on the allowed target spell of the ability
Spell is added up to level 4

I hope this is what you want ^^
 

Attachments

  • Nature's Guise.w3x
    14.7 KB · Views: 93
Level 28
Joined
Jan 26, 2007
Messages
4,789
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Region 000 <gen> contains Targeted) Equal to True
    • Then - Actions
      • Do nothing
    • Else - Actions
      • Unit - Add Roar to Targeted
      • Unit - Order Targeted to Night Elf Druid Of The Claw - Roar
      • Unit - Remove Roar from Targeted
      • Trigger - Turn off (This trigger)
Remove the "Do Nothing" here.
Do Nothing is absolutely useless, as it issues the game to do nothing, which drains some of your memory for... well, nothing.

Additionally, you must create a region for every point where the unit must remain blended, which isn't the most efficienct method if there are a lot of them.

Well, it's good enough I guess (just remove the do nothing!)
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
The "Do nothing" is for functions like "if-then-else, single function". You must put action to both "then action" and "else action", so sometimes the "Do nothing" is needed
No it isn't!
Why would it ever be needed? Why would you need to have an action that does NOTHING?
That's ridiculous...

It calls this function:
JASS:
function DoNothing takes nothing returns nothing
endfunction

So basically, IT DOES NOT DO ANYTHING.

And if you don't place any action there, guess what it does? Indeed: nothing!
But the difference between DoNothing and [no action] is that [no action] does NOT call a function, and thus does not require any memory!

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Region 000 <gen> contains Targeted) Equal to True
    • Then - Actions
    • Else - Actions
      • Unit - Add Roar to Targeted
      • Unit - Order Targeted to Night Elf Druid Of The Claw - Roar
      • Unit - Remove Roar from Targeted
      • Trigger - Turn off (This trigger)
This is the better trigger!


Let's talk in JASS now, as GUI is automatically converted to JASS.

This is what a Do Nothing would look like:
JASS:
if condition == true then
    call DoNothing()
else
    // actions
endif

This is how it looks like without Do Nothing:
JASS:
if condition == false then
    // actions
endif

You can guess what's the most efficient.

Edit: Septimus explained it somewhat like this:

  • Let's say you are doing nothing at the moment.
  • I call you over to my home.
  • I call you over to do nothing.

Futile, a waste of effort to do nothing.
 
Level 7
Joined
Dec 24, 2009
Messages
257
You don't get me, do you?
That (Do Nothing) is needed to fill such line:
  • If (((Triggering unit) is a structure) Equal to True) then (Do Nothing) else (Kill (Triggering unit))
But, sure, if it stands alone it's useless
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
You don't get me, do you?
That (Do Nothing) is needed to fill such line:
  • If (((Triggering unit) is a structure) Equal to True) then (Do Nothing) else (Kill (Triggering unit))
But, sure, if it stands alone it's useless
Never use those single-triggers!

Whether it's a unit group, if/then/else or loop, ALWAYS use "... multiple actions".
Those single lines are a horror, and not only because of the extremely useless "do nothing".
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
Never use those single-triggers!

Whether it's a unit group, if/then/else or loop, ALWAYS use "... multiple actions".
Those single lines are a horror, and not only because of the extremely useless "do nothing".

no
you can use a comment instead
and it saves a few lines
I prefer these single lines if i have something like
if a then set x = 0 else comment
if b then set x = 1337 else comment
if c then set x = 42 else comment
if d then set x = 666 else comment
4 lines instead of 16

also conditions like true = true will compile to shorther stuff
  • SomeTrigger
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • True Equal to True
        • Then - Actions
          • -------- 123 --------
        • Else - Actions
          • -------- asdf --------
JASS:
function Trig_SomeTrigger_Func001C takes nothing returns boolean
    if ( not ( true == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_SomeTrigger_Actions takes nothing returns nothing
    if ( Trig_SomeTrigger_Func001C() ) then
        // 123
    else
        // asdf
    endif
endfunction

//===========================================================================
function InitTrig_SomeTrigger takes nothing returns nothing
    set gg_trg_SomeTrigger = CreateTrigger(  )
    call TriggerAddAction( gg_trg_SomeTrigger, function Trig_SomeTrigger_Actions )
endfunction
  • SomeTrigger
    • Events
    • Conditions
    • Actions
      • If (True Equal to True) then do (-------- 123 --------) else do (-------- asdf --------)
JASS:
function Trig_SomeTrigger_Func001001 takes nothing returns boolean
    return ( true == true )
endfunction

function Trig_SomeTrigger_Actions takes nothing returns nothing
    if ( Trig_SomeTrigger_Func001001() ) then
        // 123
    else
        // asdf
    endif
endfunction

//===========================================================================
function InitTrig_SomeTrigger takes nothing returns nothing
    set gg_trg_SomeTrigger = CreateTrigger(  )
    call TriggerAddAction( gg_trg_SomeTrigger, function Trig_SomeTrigger_Actions )
endfunction

edit:
back to topic
the attached map contains a modified version of the spell which works with more than 5 trees and an unlimited number of units
 

Attachments

  • Nature's Guise.w3x
    17.8 KB · Views: 76
Last edited:
Level 28
Joined
Jan 26, 2007
Messages
4,789
D4RK, those single lines are useless in the sense that it is very rare to see an ITE with only 1 then-/else action and 1 condition.
And I find the multi-action far more readable than those single lines, and if you want to redo the trigger and you have to add a few things, you need to delete the single ITE and replace it with a multi-action and redo everything you had done before - I've had that problem quite a few times.

"if true = true" is silly, isn't it?
It will always return true and thus always trigger the "then"-actions. You might as well code it in jass with "return true".
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
D4RK, those single lines are useless in the sense that it is very rare to see an ITE with only 1 then-/else action and 1 condition.
And I find the multi-action far more readable than those single lines, and if you want to redo the trigger and you have to add a few things, you need to delete the single ITE and replace it with a multi-action and redo everything you had done before - I've had that problem quite a few times.
might happen
thinking before coding might prevent this from happening though

ap0calypse;1697635" said:
if true = true" is silly, isn't it?
It will always return true and thus always trigger the "then"-actions. You might as well code it in jass with "return true".

obviously it's an example
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
might happen
thinking before coding might prevent this from happening though
It's not the thinking before coding that did it for me, it's when I want to add new features to a map.
Of course, you can try to think of all features your map is going to have before creating it, but you'll always think of new stuff in the process.

obviously it's an example
Excuse me, I read "conditions like true = true will compile to shorther stuff" as "condition true = true will compile to shorther stuff".
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Do Nothing means... DOES NOTHING !!! Right?
Well, if it does NOTHING, WHY would it takes space? (leaks)
Because itself is a FUNCTION ?
It doesn't leak, a leak is something else :p

Do Nothing calls a function to do nothing, thus it is slower then just no action at all (and also takes up some file size xD).
So yeah, the last part is correct.
 
Status
Not open for further replies.
Top