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

[JASS] Function prototypes?

Status
Not open for further replies.
Level 4
Joined
Jul 1, 2008
Messages
46
I am writing a couple functions for combat in my map that are to be executed when a unit is attacked.

1) Do I put these functions in the the top most trigger that says 'Custom Script here'?

2) When I run the syntax checker it says that function b is not found, when function a calls it. Would I need to put function a before b in the code? Or is there a way to let the script know that there will actually be a function b, when a calls it.

3) Bonus question, i'm new to JASS so I was wondering if there's a few other ways to detect if a unit is attacked rather than the way the GUI does it. I am not looking to detect damage, just when someone tries to attack the unit
 
Level 1
Joined
Sep 1, 2006
Messages
5
1) Yes, if you want to use them in multiple Triggers. Otherwise just put them inside the trigger.
2) Yes, you have to put it before the other one.
3) As far as I know there is no other way, except for replacing the BJs with natives. But what's wrong with "the way GUI does it" anyway?
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
1) vJass allows neat things called libraries which allow you to place the code anywhere in your map.

2) A called function must be above a called function. There is a way to do this otherwise with ExecuteFunc, TriggerExecute and TriggerEvaluate. If you use vJass, you can use keywords, .execute and .evalute. Really helpful.

3) Bah, TriggerRegisterUnitEvent and PlayerUnitEvent too, I believe.
 
Level 4
Joined
Jul 1, 2008
Messages
46
3) As far as I know there is no other way, except for replacing the BJs with natives. But what's wrong with "the way GUI does it" anyway?

Thanks for the responses.

I had heard mention of an exploit where people could stop the attack before the damage was applied. I don't know how legit it was but I just wanted to see if there was a safer way, I wasn't sure. I'll probably still end up using it.
 
Level 1
Joined
Sep 1, 2006
Messages
5
I had heard mention of an exploit where people could stop the attack before the damage was applied.

That is because there is time between the start of the attack and when it is damaged. If that's the problem simply detect when it is damaged instead of when it is attacked (which is even possible in GUI). The event for that is "EVENT_UNIT_DAMAGED"
 
Status
Not open for further replies.
Top