wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Tutorials > Trigger (GUI)/ AI editor Tutorials
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 04-03-2004, 01:56 PM   #1
Rao Dao Zao
www.raodaozao.net
 
Rao Dao Zao's Avatar


MDL & Resource Moderator
 
Join Date: Aug 2003
Posts: 2,511

Submissions (27)

Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)

Approved Map: When the Freedom Slips Away

Send a message via MSN to Rao Dao Zao
Default A Unique Weapons System

FIGHT FIRE WITH FIRE - An Unique Weapons System
Tutorial and system researched by Rao Dao Zao

Have you ever wanted to let a hero have only one weapon? Well, here's your chance! This tutorial should give you all you need to get started.
What you need:
- Basic knowledge of the Trigger Editor
- Basic knowledge of the Item Editor
- Warcraft III and The Frozen Throne
- Some imagination.
Let's get ready to *rock*...

1. Start The Fire

I won't go into too much detail. I'm sure there are other tutorials on item creation.
We will need weapons. Create two swords, or rather, two items that give attack damage bonuses, with sword icons. Set both their item classes to "permenant". (You can see where this is going? A sword is a "permenant" item. If your RPG has too many permenant items, you could use something else, but for this tutorial we'll make it so. Ingame, you can't see the item class anyway.)

2. Setting Up Your Heroes

Open up the Trigger Editor. We need a variable; "HeroHasWeapon" boolean array (For many heroes. I'll get to that later.) Make it an array of, say, 12 values, for now.
Now, place a few heroes on a blank map, for this tutorial, we'll place an Arthas, a Jaina and an Antonidas, and return to the trigger editor.

Create a new trigger, call it "Hero Setup". Add event: map initialization.
Now, add an action. Scroll down the "unit" section, until you reach "set unit custom value".
Make the "unit" our Arthas, and set his value to 1. Copy this, and change the unit to Jaina, and the value to 2, and paste again and set the unit to Antonidas, than set the value to, 3.

The trigger should now read:

Events
- Map Initialization
Conditions
Actions
- Unit - Set the custom value of Arthas 0000 <gen> to 1
- Unit - Set the custom value of Jaina 0001 <gen> to 2
- Unit - Set the custom value of Antonidas 0002 <gen> to 3

Now, each hero has a custom value. This is required for the next section.

3. Picking Up And Discarding The Weapon


Another new trigger is required. Call it "Hero Finds Weapon". This time, the event should be (A Player-Owned Unit Event):
"A unit owned by Player 1 (Red) Acquires an item" (Making sure that Red is the User's colour)

Now a condition (an item-class comparison):
"(Item-class of (Item being manipulated)) Equal to Permanent"

You see? The trigger will only fire if the unit picks up a "permenant" item, or for us, a "weapon".
Now some actions. Add an "If/Then/Else, Multiple Functions" action.
This is the real gritty stuff. Under this new IF setup, add the condition: (A boolean comparison):

"HeroHasWeapon[(Custom value of (Hero Manipulating Item))] Equal to False"

This is where the Custom Value comes in. The trigger has a Boolean Array for this, and so as many heroes as you like can be governed by these conditions, but do remember to set the custom values, or the whole lot will come crashing down. (In the variable editor, make sure the array is big enough. I don't know if there is an upper limit.)
Basically, this tells the computer if a Hero has a weapon. Each hero has its own custom value, so some heroes may have weapons while others do not, and they will all fit into the array. For example, Hero(1) may have a weapon, while Hero(12) may not, and so each is represented by the value in the array: HeroHasWeapon[1] = True, HeroHasWeapon[12] = false.

Now, under the "Then" section, add an action:

"Set HeroHasWeapon[(Custom value of (Hero Manipulating Item))] = True"
(Because the specific hero now has a weapon.)
"Skip remaining actions"
(So that the trigger ignores the next part - what happens if the hero already has a weapon.)

And there you go. The hero acquires a "weapon", and the computer knows. We need, however, to make provision for when the hero, being the cheating swine that he/she is, tries to pick up two weapons.
So, another "If/Then/Else, Multiple Functions" is required.
Under conditions, this time it's [personal. Boom boom.]:

"HeroHasWeapon[(Custom value of (Triggering unit))] Equal to True"
(Because the hero has a weapon.)

Now actions.

"Hero - Drop (Item being manipulated) from (Hero Manipulating Item)"
(Get rid of that second weapon!)

And for user-friendliness, a message:

"Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: The Hero already has a weapon!"

This will give the message only to the player that's using the Hero - useful in a multiplayer situation.
That's us. We're not finished, but to recap - The trigger should look something like this:

Events
- Unit - A unit owned by Player 1 (Red) Acquires an item
Conditions
- (Item-class of (Item being manipulated)) Equal to Permanent
Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
- HeroHasWeapon[(Custom value of (Triggering unit))] Equal to False
Then - Actions
- Set HeroHasWeapon[(Custom value of (Triggering unit))] = True
- Skip remaining actions
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
- HeroHasWeapon[(Custom value of (Triggering unit))] Equal to True
Then - Actions
- Hero - Drop (Item being manipulated) from (Triggering unit)
- Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: The Hero already ha...
Else - Actions

OK. But, we still need another trigger. What if the hero drops his/her weapon, and doesn't pick it up again? The computer knows that "the Hero still has a weapon," because HeroHasWeapon (our boolean array) is still "true". So, we need another, simpler trigger, to tell the computer the Hero has dropped his/her/its weapon.

Create it. Call it "Hero drops weapon".

Event:
"Unit - A unit owned by Player 1 (Red) Loses an item"

Condition:
"(Item-class of (Item being manipulated)) Equal to Permanent"

Action:
"Set HeroHasWeapon[(Custom value of (Hero Manipulating Item))] = False"

Easy. But this system, as we have it, will not work. When the hero picks up an item, yeah, fine. But, when he/she picks up another weapon, it gets dropped, right? So, the hero "has no weapon", the boolean value for this hero becomes false. Oh dear! The Hero is free to pick up the next weapon, and will have two. So, we need to return to our first trigger, and add a few lines.

Go to the second IF setup.
Above the "Drop Item" bit, add:

"Trigger - Turn off Hero Drops Weapon <gen>"

Now, below the message, add:

"Wait 0.01 seconds"
"Trigger - Turn on Hero Drops Weapon <gen>"

Why the wait? Well, I'm not sure that you need it, but I keep it just to make sure that the trigger has been switched off, the item is dropped, then the trigger is switched on again, in the right order. We don't want horrid things like the trigger being switched on as the item is dropped, in case we return to the problem before this trigger.
This will mean that as the second weapon is dropped, the second trigger does not fire - the variable remains "True", the Hero still has his/her first weapon.

4. Testing, Testing, 123...

Well, there you go. Place your two weapons, in fact, place several! Watch as Arthas tries to pick up two swords, and gets rebuked by the computer. Heh, they don't call him Arth-sole for nothing. It works, see? If it doesn't, well, you haven't been listening, because it works for me!

5. A Purer Weapon

At the moment, we have heroes, and their attacks do damage even when they have no weapon! So, go into the Unit Editor, and under the "Combat" section of our heroes, change the "Base Damage" to 0, and the "Damage Number Of Dice" and "Damage Sides per Die" to 1. This will make each attack do only one damage. Setting any one of the Dice settings to 0 will make the attack disappear altogether. So, on your weapon's description, you'll need to say the amount of damage it does plus one, or minus one from the value (for example: a sword that gives +49 will do 50 damage). Also, Heroes gain bonuses from their Primary Attribute, so in the main editor go to Advanced->Gameplay Constants. Scroll down to the "Hero Attributes" section, and make "Attack Bonus per Primary Att. Point" 0. Now, the hero will always do 1 damage, and thus must have a sword to get anywhere in a fight. Also, watch out for ranged Heros - make sure range is set to 100 (melee), we don't want people bashing each other from miles off, do we?

6. This is Where You Need the Imagination...

This system is very simple. So, you can add all the complexity you like. One thing I've tried is: get some item models from a Warcraft III website, then set the item to create this weapon effect on the holder's hand. So it looks like the Hero even has the weapon! Very nice. Then, you could do the same with a shield, armour, gauntlets, boots... Soon you'd have a Baldur's Gate-style RPG inventroy system! But it shouldn't end there. If you were a melee fanatic, I'm sure you could rig up something with variables, give every unit an inventory, and watch as every man needs a sword... Woah! There's a lot you could do, that's why I specified "imagination" as one of the things you need. You can't map or mod without it. That's why I'm so unsuccessful. Anyhoo, I hope this has fired you up. Happy mapping!

Rao Dao Zao

PS, if you find any bugs that need taking care of, or the tutorial doesn't make sense at some point (and that's a common fault with this model), or you hate my bad jokes, just e-mail theroberdozer@hotmail.com
__________________
Rao Dao Zao is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 04-05-2004, 05:25 AM   #2
Lu Baihu
User
 
Join Date: Jan 2004
Posts: 192

Lu Baihu has little to show at this moment (0)

Default

Great stuff! Unfortunately, I still need help (see PM), and if you've got one for how to lock certain kinds of items (ie weapons) to a certain slot (Slot 1) ...
Lu Baihu is offline   Reply With Quote
Old 04-05-2004, 08:21 PM   #3
Light One
User
 
Join Date: Mar 2004
Posts: 2

Light One has little to show at this moment (0)

Default

As a sidenote if you hold shift while double-clicking on the Base Damage you can set it to -1. This effectively changes the damage to 0 (I checked that), so you don't have to take it into account while creating weapons. Not big deal anyway ;P
And beside that, great tutorial, it learned me quite a bit about triggers, not only about weapon editing.
Light One is offline   Reply With Quote
Old 04-29-2004, 01:16 AM   #4
ThyFlame
User
 
Join Date: Jan 2004
Posts: 831

Submissions (1)

ThyFlame is on a distinguished road (10)

Default

This is... er... overly complex.

Just count how many "weapon"s he has when an item is acquired. If the count is > 1, drop the item being manipulated. That's all you need.
ThyFlame is offline   Reply With Quote
Old 04-29-2004, 09:20 PM   #5
JTG
User
 
Join Date: Apr 2003
Posts: 78

Submissions (1)

JTG has little to show at this moment (0)

Default

One think That I'd like to add is that you can create a type-check arguement to the function call list.
for example
[code]
[size=2][color=cyan]Weapons: Ranged
[/color] [color=lime]Ranged: Individual Itemtypes[/color][/size]
[size=2][/size]
[size=2][color=gray][size=2][color=gray]function[/color] [color=cyan]IsShortBow[/color] takes [color=deepskyblue]item[/color] whichitem [color=gray]returns[/color] [color=deepskyblue]boolean[/color]
[color=deepskyblue]return[/color] ( GetItemTypeId(whichitem) == 'wB00' ) or ( GetItemTypeId(whichitem) == 'wB01' ) or ( GetItemTypeId(whichitem) == 'wB02' )
[color=gray]endfunction[/color]
[/size]
[/color][/size][size=2][color=gray]function[/color] [color=cyan]IsLongBow[/color] takes [color=deepskyblue]item[/color] whichitem [color=gray]returns[/color] [color=deepskyblue]boolean[/color]
[color=deepskyblue]return[/color] ( GetItemTypeId(whichitem) == 'wB10' ) or ( GetItemTypeId(whichitem) == 'wB11' ) or ( GetItemTypeId(whichitem) == 'wB12' )
[color=gray]endfunction[/color]
[/size][/code]
Followed by a more broad call:
[size=2][code][/code][/size][code]
[size=2][color=cyan]Weapons: Ranged
[/color] [color=lime]Ranged: Generic Itemtypes[/color][/size]
[size=2][/size]
[size=2][color=gray]function[/color] [color=cyan]IsBow[/color] takes [color=deepskyblue]item[/color] whichitem [color=gray]returns[/color] [color=deepskyblue]boolean[/color]
[color=deepskyblue]return[/color] IsShortBow(whichitem) or IsLongBow(whichitem)
[color=gray]endfunction[/color]
[/size][/code]
Then the most generic call:
[size=2][code][/code][/size][code]
[size=2][color=cyan]Weapons
[/color][/size]
[size=2][color=gray][/color][/size]
[size=2][color=gray][size=2][color=gray]function[/color] [color=cyan]IsRanged[/color] takes [color=deepskyblue]item[/color] whichitem [color=gray]returns[/color] [color=deepskyblue]boolean[/color]
[color=deepskyblue]return[/color] IsBow(whichitem)[/size]
[size=2][color=gray]endfunction[/color]
[/size]
[/color][/size][size=2][/size][size=2][color=gray]function[/color] [color=cyan]IsMelee[/color] takes [color=deepskyblue]item[/color] whichitem [color=gray]returns[/color] [color=deepskyblue]boolean[/color]
[color=deepskyblue]return[/color] IsShortSword(whichitem)[/size]
[size=2][color=gray]endfunction[/color][/size]
[size=2][color=#808080][/color]
[/size][size=2][color=gray]function[/color] [color=cyan]IsWeapon[/color] takes [color=deepskyblue]item[/color] whichitem [color=gray]returns[/color] [color=deepskyblue]boolean[/color]
[color=deepskyblue]return[/color] IsRanged(whichitem) or IsMelee(whichitem)[/size]
[size=2][color=gray]endfunction[/color]
[/size][/code]

The only problem is that you have to make ALL the lists in that manner (which can get pretty extensive).
Once you have the lists made you can make a restriction function that only lets you put it in a certian slot, or by moving the item when you pick it up and not letting the user put it into a different slot (when they do, it just moves it back to where it was unless you where to move it to the ground.)

Anywayz, that's my two-cents.
JTG is offline   Reply With Quote
Old 05-25-2004, 09:33 PM   #6
Foxfire88
User
 
Join Date: Mar 2004
Posts: 11

Foxfire88 has little to show at this moment (0)

Default

Ok you made this WAY too confusing. I just made a system that should do the exact same thing, but with only one trigger. I'm not sure if it works, since I haven't tested it but the trigger is :

Event : A unit acquires an item.

Conditions : Item-class of (item being manipulated) equal to permenant
(Item carried by (Hero manipulating item) in slot 1) Not equal to (Item being manipulated)
(Item carried by (Hero manipulating item) in slot 2) Not equal to (Item being manipulated)
(Item carried by (Hero manipulating item) in slot 3) Not equal to (Item being manipulated)
(Item carried by (Hero manipulating item) in slot 4) Not equal to (Item being manipulated)
(Item carried by (Hero manipulating item) in slot 5) Not equal to (Item being manipulated)
(Item carried by (Hero manipulating item) in slot 6) Not equal to (Item being manipulated)

Action : Remove (item being manipulated)
Game - Display to (All players matching ((Owner of (Hero manipulating item)) Equal to (Owner of (Hero manipulating item)))) the text: Sorry! You can only have one of each item of that type at a time.

This is just the basic trigger, you could add variables to make it so you can't have more than one of a type of item ect.
Foxfire88 is offline   Reply With Quote
Old 05-26-2004, 08:21 PM   #7
JTG
User
 
Join Date: Apr 2003
Posts: 78

Submissions (1)

JTG has little to show at this moment (0)

Default

At the present manner you have suggested the trigger would fail. If you are carrying one of that item already then it wouldn't fire. The method I stated perviously is more of a "specified list" algorithm. It works much like a class tree.
JTG is offline   Reply With Quote
Old 06-08-2004, 04:29 PM   #8
IronGauntlet
User
 
Join Date: Sep 2003
Posts: 89

IronGauntlet has little to show at this moment (0)

Default

if I was going to make a multiplayer rpg where each player had only 1 hero, instead of using the (custom value of(triggering unit) could you use the (player number of(triggering players)?
IronGauntlet is offline   Reply With Quote
Old 06-08-2004, 06:21 PM   #9
Rao Dao Zao
www.raodaozao.net
 
Rao Dao Zao's Avatar


MDL & Resource Moderator
 
Join Date: Aug 2003
Posts: 2,511

Submissions (27)

Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)

Approved Map: When the Freedom Slips Away

Send a message via MSN to Rao Dao Zao
Default

Quote:
Originally Posted by IronGauntlet
if I was going to make a multiplayer rpg where each player had only 1 hero, instead of using the (custom value of(triggering unit) could you use the (player number of(triggering players)?

I think you probably could... The important thing is that every hero has a unique number of some kind. I just found "Custom Values" convenient.

A little extra that might help some people - In both triggers, in the main conditions section, you can add an integer comparison:
(Custom Value of (Hero Manipulating Item)) Not Equal To 0
This would mean any units with 0 value would be completely exempt from the system - good for pack animals or stashes.
__________________
Rao Dao Zao is offline   Reply With Quote
Old 06-10-2004, 09:32 PM   #10
JTG
User
 
Join Date: Apr 2003
Posts: 78

Submissions (1)

JTG has little to show at this moment (0)

Default

Great fix, Robe.
Yes, you could IronGauntlet. Create a Unit-Array (size 12) and set udg_Heros[1] = (Player 1 Hero) etc. Then it would work just fine.
JTG is offline   Reply With Quote
Old 07-12-2004, 08:20 PM   #11
Saxe
User
 
Join Date: Jun 2004
Posts: 56

Saxe has little to show at this moment (4)

Default

Cant you just use a generic unit event, so you dont have to create a trigger for every player?
Saxe is offline   Reply With Quote
Old 07-13-2004, 06:48 PM   #12
Rao Dao Zao
www.raodaozao.net
 
Rao Dao Zao's Avatar


MDL & Resource Moderator
 
Join Date: Aug 2003
Posts: 2,511

Submissions (27)

Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)

Approved Map: When the Freedom Slips Away

Send a message via MSN to Rao Dao Zao
Default

Quote:
Originally Posted by Saxe
Cant you just use a generic unit event, so you dont have to create a trigger for every player?

Yes, you probably could. I wrote this initially for singleplayer, so it would be more efficient for the trigger to happen for player 1 only. But, I don't think it really matters.
__________________
Rao Dao Zao is offline   Reply With Quote
Old 07-17-2004, 05:03 AM   #13
ak47
User
 
Join Date: Nov 2003
Posts: 163

ak47 has little to show at this moment (0)

Default

Quote:
Originally Posted by Robe
Yes, you probably could. I wrote this initially for singleplayer, so it would be more efficient for the trigger to happen for player 1 only. But, I don't think it really matters.

i'm using this trigger for multiplayer and I have a question.

For the dropping item... How can I make a certain group of items drop when welding a certain item.

For instance... I have 7 weapons to have. If i held any 1 of the 7 weapons, I would drop the weapon. The problem with "permenent" in your trigger is that I also have other permenent items that are not weapons such as "Quest Items" or like a permenent item that does nothing like keys. It would drop the key and vise versa.

So would I have to make several of the same triggers for each item to prevent this or is there a quick and easy way to do this?!?
ak47 is offline   Reply With Quote
Old 07-17-2004, 06:07 PM   #14
Rao Dao Zao
www.raodaozao.net
 
Rao Dao Zao's Avatar


MDL & Resource Moderator
 
Join Date: Aug 2003
Posts: 2,511

Submissions (27)

Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)Rao Dao Zao has a brilliant future (822)

Approved Map: When the Freedom Slips Away

Send a message via MSN to Rao Dao Zao
Default

Quote:
Originally Posted by ak47
i'm using this trigger for multiplayer and I have a question.

For the dropping item... How can I make a certain group of items drop when welding a certain item.

For instance... I have 7 weapons to have. If i held any 1 of the 7 weapons, I would drop the weapon. The problem with "permenent" in your trigger is that I also have other permenent items that are not weapons such as "Quest Items" or like a permenent item that does nothing like keys. It would drop the key and vise versa.

So would I have to make several of the same triggers for each item to prevent this or is there a quick and easy way to do this?!?
Sometimes, I make "artifact" the "weapon" rather than "permenant," because there are only 6 default "artifacts" to shift out the way. You have to remember that the item classification system doesn't seem to have any effect in-game, so it doesn't matter what class an item is.

To make a different set of items also drop, I think you could have two events in the "pick up item" trigger - one for "permenant" items, and one for, let's say "artifacts." I don't know if this would work, but it would mean that both types were "weapons" and both affected the player, but were different... You'd need to experiment a bit.
__________________
Rao Dao Zao is offline   Reply With Quote
Old 07-17-2004, 09:12 PM   #15
ak47
User
 
Join Date: Nov 2003
Posts: 163

ak47 has little to show at this moment (0)

Default

Quote:
Originally Posted by Robe
Sometimes, I make "artifact" the "weapon" rather than "permenant," because there are only 6 default "artifacts" to shift out the way. You have to remember that the item classification system doesn't seem to have any effect in-game, so it doesn't matter what class an item is.

To make a different set of items also drop, I think you could have two events in the "pick up item" trigger - one for "permenant" items, and one for, let's say "artifacts." I don't know if this would work, but it would mean that both types were "weapons" and both affected the player, but were different... You'd need to experiment a bit.

i'll go try it, thx
ak47 is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 12:12 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services