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!
A Unique Weapons System
Moderator: Cheaters
-
- Forum Addict
- Posts: 451
- Joined: November 21st, 2008, 9:36 am
- Title: Coleen!