• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[JASS] Function prototypes?

Status
Not open for further replies.
Level 5
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
 
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?
 
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.
 
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.
 
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.
Back
Top