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

Variables help needed

Status
Not open for further replies.
Level 3
Joined
Jan 22, 2011
Messages
35
I need help in fiquring the variable crap out in war3 editor i cnt seem to understand it...
For example if i make a quest for the hero to kill trolls and each troll has to drop an item so how i do tht
make it simple plz
 
Last edited:
Level 7
Joined
Jun 15, 2010
Messages
218
if u make the follow quest:
"Kill 10 trolls"
Then make a variable and set it to interger and give it a name like "trollquest". Thats all.
Then u make a trigger

Event - unit dies
condition - dying unit is equal to Troll(select the troll)
actions - set variable: set "trollquest" to "trollquest + 1 (u need to use artimatic for this)



then make a trigger
Event - unit dies
condition - dying unit is equal to Troll(select the troll)
actions - If then else, multiple functions:
If(condition) - Interger, trollsquest is equal to 9
then do (actions) - complete quest or whatever u want to do.

The variable is not linked to anyting by himself. In this case its just a number that u use to know how many trolls are kiled.
its quite easy. only it looks hard
 
Level 3
Joined
Mar 15, 2010
Messages
37
Quest in progress
  • Trollquest
  • Events
    • Unit - unit dies
  • Conditions
    • (Unit type of (dying unit)) equal to Troll
  • Actions
    • Set Variable - set variable: (set trollquest to (trollquest + 1))
Quest Complete
  • Trollquest complete
  • Events
    • Unit - unit dies
  • Conditions
    • (Unit type of (dying unit)) equal to Troll
  • Actions
    • If (All conditions are true) Then do (Then actions) Else do (Else actions)
      • If - Conditions
        • Trollquest equal to 9
      • Then - Actions
        • ----- Here you put all done things, message that quest complete, turn return trigger on, turn this and quest in progress to off etc -----
      • Else - Actions
        • Do Nothing
- This is to easier understand from Chasin's quide. but hope it helps.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Chasin, you should remove the "Do Nothing" action because that Action practically... does nothing.
Why do put "Trollquest equal to 9" ?
I think he wants it, 10 ?
You should set it 0 at initial quest (if this quest is repeatable):
  • Set TrollQuest = 0
If it can't be repeated, just let it be
Because it will not be repeated so you don't have to reset the value to 0
ALL starting Integer/Real will start with 0/0.00 values

Check my test map, it uses the same principles
(The quest in the map cannot be repeat, but to on the safe side, just set it to 0 at initial trigger)
 

Attachments

  • NPC Quest.w3x
    14.7 KB · Views: 51
Level 3
Joined
Mar 15, 2010
Messages
37
Well, you know.. you have 9 kills, Then you kill 1 more and that trigger works, 10 kills?
well that do nothing is there just showing that no need to put anything to there.
 
Level 3
Joined
Mar 15, 2010
Messages
37
Sarimdesert, dont post so many times, use "Edit" button, posting many times is against the rules. and I dont know is there some button to remove threat, maby admins can do that, but why do u have to remove this?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,207
There are 2 sorts of variables you can use in warcraft 3.
Global which are able to be used by any function (stored in memory at a specific address).
Locals which only exist within their creating function (stored in the heap).

Locals are faster than globals due to their reduced scope.

In GUI triggering, you can not access locals because it is shit.

All variables can be arrays. Arrays purly are a collection of sequential memory locations permiting you to retreive a value using an index (sort of representing which slot it is in so using a constant index would be the same as declaring a brand new variable). Arrays in WC3 are an implimentation of an arraylist structure with a maximum bound of 8192 indicies so no size definition is required. Obviously you can not access indicies out of the array allocated spave so only 0 - 8191 are valid indicies.

Globals can be constant, this makes the value it contains unmutable (you can not change it). You can logically only give constants a value when they are declared. As such constant arrays are impossible. This is another feature not available to GUI users. Do not confuse this with constant functions, which were deemed as eye candy (serve no use).

The general purpose of variables is to store data so that they can be fed to instructions later on.

An example is a counter system for waves. Every wave adds 1 to a counter. When the counter reaches 10 the spawns upgrade (spawn type can also be another variable). At 100, you could spawn a final boss and terminate the trigger. Logically you would be using a conditional test on the variable to vary the executed code depending on its value (program flow control).
 
Status
Not open for further replies.
Top