Before reading: everything I say will be in GUI.
Using JNGP is not preferred if you only use GUI anyway, and all options above require JNGP (so that wouldn't be the best idea if you're not accustomed with JASS, let alone vJass).
There are different ways you can 'talk' to an NPC.
One is to right-click it, another is to select it (both when near the NPC). You can also just activate it when you're in range of the NPC.
My example will use the 'right-click when in range', simply because you do not have to deselect your hero that way.
The event will be:
-
Events
-
Unit - A unit Is issued an order targeting an object
"targetting an object" can basically be translated to "right-click" when we're talking about neutral units.
We have to be in range of the NPC as well (can't talk to an NPC that is kilometers away).
For this, you have to use points (in GUI at least), so we cannot place it in the "Conditions" section (otherwise we create leaks, and we do not want leaks!).
So this is how you do it:
-
Actions
-
Set tempLoc1 = (Position of (Triggering unit))
-
Set tempLoc2 = (Position of (Target unit of issued order))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Distance between tempLoc1 and tempLoc2) Less than or equal to 400.00
-
Then - Actions
-
-------- We're within range --------
-
Else - Actions
-
Custom script: call RemoveLocation(udg_tempLoc1)
-
Custom script: call RemoveLocation(udg_tempLoc1)
You can change the "400.00" if you want.
The custom scripts are to remove leaks. In case you didn't know this yet: please, for your own sake, learn about memory leaks. It's vital for the performance of your map.
Where the comment currently is, we need to display our quest.
Usually, it sends a game message as well, such as:
Quest Discovered: Create a Quest
You must find out how to create your own quest.
This is a simple game message, I won't show how you do that.
But the quest itself is something most people get lazy on.
There is something called "quest requirements". Most people just skip that and use the quest description to say what people have to do, but not me
A standard way to create quests is:
-
Quest - Create a Optional quest titled Create a Quest with the description You must find..., using icon path {Path}
-
Set quest1 = (Last created quest)
-
Quest - Create a quest requirement for quest1 with the description Follow this guide
-
Set quest1Req1 = (Last created quest requirement)
-
Quest - Create a quest requirement for quest1 with the description Create your own quest
-
Set quest1Req2 = (Last created quest requirement)
-
Set quest1Activated = True
Let's go over it, shall we?
The first thing you do is, obviously, create the quest itself.
Important: set the quest path to something that fits the quest! I've seen so many games where the creator just didn't bother changing the quest path, which is really annoying.
Saving the quest into a variable allows you to mark the quest as completed/failed (also pretty important I assume).
Then you create the quest requirements. These will show up above the quest description.
Again: saving these requirements into variables allows you to mark them as completed/failed.
The last action is something I didn't mention yet: if we already have the quest, we don't want to get it again (unless it failed).
We store "true" in a variable, so whenever this variable is "true", the trigger will not activate (this could be inside the "Conditions"-section of the trigger).
Next thing on the list is getting creeps to drop the required items.
-
Drop Items
-
Events
-
Conditions
-
Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
quest1Activated Equal to True
-
(Unit-type of (Triggering unit)) Equal to Fearsome Wolf
-
(Random percentage) Less than or equal to {Drop chance (percentage)}
-
Then - Actions
-
Set tempLoc1 = (Position of (Triggering unit))
-
Item - Create Wolf Tooth at tempLoc1
-
Custom script: call RemoveLocation(udg_tempLoc1)
-
Else - Actions
I usually use tomes as items. These dissapear when picked up, so they don't take up any inventory space.
This is good when using the standard warcraft 3 inventory, as 6 slots just aren't enough for gear, potions and quest items.
Why didn't I put the conditions of the ITE (If-Then-Else) in the "Conditions"-section of the trigger? So you can use this trigger for all your quests.
When picking up an item (tome), we use the event:
-
Events
-
Unit - A unit Uses an item
-
Unit - A unit Acquires an item
The actions are something like this:
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Item-type of (Item being manipulated)) Equal to Wolf Tooth
-
quest1ItemCount Less than quest1ItemsRequired
-
quest1Activated Equal to True
-
Then - Actions
-
Set quest1ItemCount = (quest1ItemCount + 1)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
quest1ItemCount Greater than or equal to quest1ItemsRequired
-
Then - Actions
-
-------- All wolf teeth have been found, complete the quest requirement --------
-
-------- Optional: add a special effect (question mark) above the NPC's head --------
-
Quest - Mark quest1Req1 as Completed
-
Else - Actions
-
-------- Show update-message --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Complete Quest <gen> is on) Equal to False
-
Then - Actions
-
Trigger - Turn on Complete Quest <gen>
-
Else - Actions
-
Set LoopIntQ = 100
-
Else - Actions
The update-message could be:
Quest Updated: Wolf Quest
Wolf Teeth found: 2 / 10
Anyhow, a little recap on the trigger:
Conditions:
1) Item type must be correct (obviously)
2) We may not have more than the maximum amount of quest items (avoids things like "Wolf Teeth found: 11/10").
2) The quest must still be active.
We increase the amount of items we have found and then check whether we've found them all, or should keep on hunting.
Now we need to complete our trigger. We do this the same way we started it: right-clicking the NPC.
The event is the same as the first trigger, but the conditions of the ITE are slightly different:
-
Actions
-
Set tempLoc1 = (Position of (Triggering unit))
-
Set tempLoc2 = (Position of (Target unit of issued order))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Distance between tempLoc1 and tempLoc2) Less than or equal to 400.00
-
quest1Activated Equal to True
-
quest1Completed Equal to False
-
quest1ItemCount Greater than or equal to quest1ItemsRequired
-
Then - Actions
-
-------- Give rewards --------
-
Set quest1Completed = True
-
Quest - Mark quest1Req2 as Completed
-
Quest - Mark quest1 as Completed
-
Else - Actions
-
Custom script: call RemoveLocation(udg_tempLoc1)
-
Custom script: call RemoveLocation(udg_tempLoc1)
The quest still has to be active, but may not be completed yet.
I usually put "Return to {NPC}" as the second quest requirement, so that's why we only mark it as completed here.
We have to complete the quest itself as well.
Rewards are quest-specific.
And that's the basics
I may add a system of my own if you ask so (I also made a quest system, in GUI though, a long time ago).