- Joined
- Jun 12, 2007
- Messages
- 1,261
What are we going to make?
To put it simple I'm going to explain how to make a profession inside a wc3 map using variables and items.
In this tutorial I will give you an example for the profession: smithing.
It's not very easy but if you read this [How-To] good you'll be able to make your professions in no time.
Also, this is MPI not MUI, this means that only one unit per player can use it at a time.
You can use this in for example; RPG maps or LoaP maps, be creative!
This will need a lot of triggering and take a lot of time so be prepared.
You might also see that most parts have been hidden, this is to reduce the size and give a better view of this tutorial.
_______________________________________
Creating the Basic Profession
Basic Knowledge
You need to know how to edit objects like making spells and items.
You need to know the basics about using variables with an array.
And of course you need to know about making triggers.
Also, this map has been fixed of leaks, if you do not understand the custom scripts and don't know what leaks are visits this link.
Difficulty: Normal [6/10]
You need to know the basics about using variables with an array.
And of course you need to know about making triggers.
Also, this map has been fixed of leaks, if you do not understand the custom scripts and don't know what leaks are visits this link.
Difficulty: Normal [6/10]
What do we need?
1) You need a variable for the hero that Red has. (Unit Variable)
- I will name it PlayerHero, it needs to be an array because we want it to work for multiple players.
- This variable will store a unit for us (the hero you will use in your map) so we can use it later inside the actual profession trigger.
2) You need a variable that keeps track of the professions current level. (Integer Variable)
- I will name it Smithing and it must be an array of course.
- You have to put the starting value to 1.
- This will keep track of the current level of a players profession, we need this because some items are very hard to make and need a higher level.
- It will be part of a formula that will increase the chance that it succeeds.
3) A variable to store a real, this real variable needs to be an array as well.
- I will name it ProfessionRoll as the name of this real variable.
- The random number this variable will store is to create a chance to fail or succeed.
4) You need a dummy spell to start the whole thing, I based it of channel.
- Set the cool down at 15 sec! Of course it takes some time before the guy can start again but this is so the triggers wont collide.
- I removed all art but you can keep/change it if you want.
- You need to make it visible at "Data - Options".
- It should target nothing you can edit this at "Data - Target Type - Instant (No Target)".
- It should not disable other abilities at "Data - Disable Other Abilities - False"
5) Alot of dummy items, I devided them into two categories: tool items and material items.
- For smithing I make a dummy item that's called; 'Tools: Hammer'.
- A tool item will never disapear, it can be used multiple times to create stuf.
- A material item will be used as the ingredients for the item (a shield or something) you want the profession to make.
- When 'PlayerHero' has this item in slot 1 and has the required material items in the proper slots and has the required level and hits the spell: action. The material items will vanish and the item he wants to make with this profession will appear. (The tool will stay aswell.)
For this tutorial I want you to make these dummy items:
- Tools: Hammer
- Iron Ore
- Wood
(You can also decide it for yourself who what and where, this is just an example.)
- I will name it PlayerHero, it needs to be an array because we want it to work for multiple players.
- This variable will store a unit for us (the hero you will use in your map) so we can use it later inside the actual profession trigger.
2) You need a variable that keeps track of the professions current level. (Integer Variable)
- I will name it Smithing and it must be an array of course.
- You have to put the starting value to 1.
- This will keep track of the current level of a players profession, we need this because some items are very hard to make and need a higher level.
- It will be part of a formula that will increase the chance that it succeeds.
3) A variable to store a real, this real variable needs to be an array as well.
- I will name it ProfessionRoll as the name of this real variable.
- The random number this variable will store is to create a chance to fail or succeed.
4) You need a dummy spell to start the whole thing, I based it of channel.
- Set the cool down at 15 sec! Of course it takes some time before the guy can start again but this is so the triggers wont collide.
- I removed all art but you can keep/change it if you want.
- You need to make it visible at "Data - Options".
- It should target nothing you can edit this at "Data - Target Type - Instant (No Target)".
- It should not disable other abilities at "Data - Disable Other Abilities - False"
5) Alot of dummy items, I devided them into two categories: tool items and material items.
- For smithing I make a dummy item that's called; 'Tools: Hammer'.
- A tool item will never disapear, it can be used multiple times to create stuf.
- A material item will be used as the ingredients for the item (a shield or something) you want the profession to make.
- When 'PlayerHero' has this item in slot 1 and has the required material items in the proper slots and has the required level and hits the spell: action. The material items will vanish and the item he wants to make with this profession will appear. (The tool will stay aswell.)
For this tutorial I want you to make these dummy items:
- Tools: Hammer
- Iron Ore
- Wood
(You can also decide it for yourself who what and where, this is just an example.)
The Triggers
To start with we need a trigger to put that PlayerHero variable assigned to the hero of the proper player.
You can do this when that hero is trained for the first time as an example.
(Take note, only one hero per player!)
That one is easy, is it not?
Let's move to the second trigger, this is a very big trigger but once you made it you can base all other profession triggers of it by editing some values, I will explain this later.
This is a beast! Take a look first, lets tame it after you took a good look.
This one will make a Torn Shield.
Once you understand how it works it's pretty easy, lets tame this beast!
You can do this when that hero is trained for the first time as an example.
(Take note, only one hero per player!)
-
PlayerHero
-
Events
- Unit - A unit Finishes training a unit
-
Conditions
- ((Trained unit) is A Hero) Equal to True
-
Actions
- Set PlayerHero[(Player number of (Owner of (Trained unit)))] = (Trained unit)
-
Events
Let's move to the second trigger, this is a very big trigger but once you made it you can base all other profession triggers of it by editing some values, I will explain this later.
This is a beast! Take a look first, lets tame it after you took a good look.
This one will make a Torn Shield.
-
Torn Shield
-
Events
- Unit - A unit Begins casting an ability
-
Conditions
- (Ability being cast) Equal to Action
-
Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Item-type of (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 1)) Equal to Tools: Hammer
- (Item-type of (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 2)) Equal to Iron Ore
- (Item-type of (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 3)) Equal to Wood
-
Then - Actions
- Set ProfessionRoll[(Player number of (Owner of (Casting unit)))] = (Random real number between 0.00 and 100.00)
- Set PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
- Floating Text - Create floating text that reads You try to create a... at PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
- Floating Text - Change (Last created floating text): Disable permanence
- Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
- Floating Text - Change the fading age of (Last created floating text) to 0.00 seconds
- Floating Text - Set the velocity of (Last created floating text) to 15.00 towards 90.00 degrees
- Custom script: call RemoveLocation(udg_PlayerHeroPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
- Wait 5.00 seconds
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ProfessionRoll[(Player number of (Owner of (Casting unit)))] Less than or equal to (60.00 + (Real(Smithing[(Player number of (Owner of (Casting unit)))])))
- Smithing[(Player number of (Owner of (Casting unit)))] Greater than or equal to 1
-
Then - Actions
- Item - Remove (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 2)
- Item - Remove (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 3)
- Hero - Create Torn Shield and give it to PlayerHero[(Player number of (Owner of (Casting unit)))]
- Set Smithing[(Player number of (Owner of (Casting unit)))] = (Smithing[(Player number of (Owner of (Casting unit)))] + 1)
- Set PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
- Floating Text - Create floating text that reads Succes! at PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] with Z offset 0.00, using font size 10.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
- Floating Text - Change (Last created floating text): Disable permanence
- Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
- Floating Text - Change the fading age of (Last created floating text) to 0.00 seconds
- Floating Text - Set the velocity of (Last created floating text) to 15.00 towards 90.00 degrees
- Custom script: call RemoveLocation(udg_PlayerHeroPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
-
Else - Actions
- Item - Remove (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 2)
- Item - Remove (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 3)
- Set PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
- Floating Text - Create floating text that reads Failed... at PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
- Floating Text - Change (Last created floating text): Disable permanence
- Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
- Floating Text - Change the fading age of (Last created floating text) to 0.00 seconds
- Floating Text - Set the velocity of (Last created floating text) to 15.00 towards 90.00 degrees
- Custom script: call RemoveLocation(udg_PlayerHeroPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
-
If - Conditions
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Events
Taming the Trigger
Here I will explain to you what each part of the trigger does and what u need to edit for different recipes.
Lets start with event and condition first, this part is still easy!
So basically, a unit casts the ability; action.
This will start the trigger! Now lets check the condition of the first If/Then/Else action!
First thing you will notice is the array, I use [(Player number of (Owner of (Casting unit)))] as the array, this will fill in the number of the owner of the hero that casts the spell.
So if the casting unit belongs to player1red it will fill in a 1.
I will use this array for all variables so keep that in mind.
This part will check if the hero that casts the spell has the proper items in their proper slots!
You need to be sure that each recipe you make for the profession has a different order of items!
Now when does not have the proper items, nothing will happen!
You can add more items by adding slots.
This part: 'slot 1)) Equal to Tools: Hammer' will say what slot needs to contain what item.
Lets check the then action of this if/then/else action! (This if/then/else action does not have a else action!)
So first you see that ProfessionRoll will store a random real between 0.00 and 100.00 this is in order to create a chance to either succeed or fail later in this trigger.
I am aware that u don't need to store this however I'm more comfortable with it.
Second it will create a floating text above the hero that uses the spell telling him what he is trying to do, in this case it will tell him that he is trying to make a torn shield.
U can edit the text it will show depending on what item you are trying to make in the trigger.
The other floating text actions will determine how long it stay, when it will fade away, and how the velocity goes, I suggest using the values mentioned in the trigger.
The 5 second wait is there because it takes some time to create the item.
Now there is a second If/Then/Else action, lets take a look at its conditions.
This will check for 2 small yet very important things.
The first thing will be the chance that it has succeeded, you know we ordered the 'If/Then/Else Action I; Then Action' to create a random real number between 0.00 and 100.00? Well here we use it!
If the random real number it created is below 60 + the level of his profession it will succeed.
This means that the higher it's level is the higher the chance is it will succeed!
You can edit the 60 in this trigger to create lower or higher chances for the recipe.
The second thing it will check is the level of the profession. In this case if it's level is above 1 (and that's the default level) it will succeed. If his profession level is to low it will fail by default.
Lets move on to the then action of this action.
Everything you see here will happen when the player that uses the profession has the required profession level for it, and has succeeded with the chance we created earlier.
Oke, first it will remove the material items, you have to check what items you want to remove so take a good look at the condition of the first If/Then/Else action.
After that it will create the item the player wanted to make at his hero, we know there will be space because we remove the material items. Take note I use the variable PlayerHero to create the item at.
After this we increase the level of the profession by one. You can edit the level it will increase with, but for lower recipes I recommend sticking to 1.
It will also show a useful floating text at the unit of the player telling him is succeeded.
This part is basically the same as the first floating text, the only thing that's different its the color and the text it will show.
Lets move to the last part of this trigger, it's very easy.
It's basically the same like the then action but with a few changes.
- It will not create a item.
- It will not increase the level of the profession.
- The text message has a different color and says that it failed.
Now we have tamed this beast of a trigger! But we are not done yet!
We want players to check on their current profession levels so they know if they can create the item or not but this is very easy.
Lets start with event and condition first, this part is still easy!
-
Torn Shield
-
Events
- Unit - A unit Begins casting an ability
-
Conditions
- (Ability being cast) Equal to Action
-
Events
This will start the trigger! Now lets check the condition of the first If/Then/Else action!
-
Torn Shield
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Item-type of (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 1)) Equal to Tools: Hammer
- (Item-type of (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 2)) Equal to Iron Ore
- (Item-type of (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 3)) Equal to Wood
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
So if the casting unit belongs to player1red it will fill in a 1.
I will use this array for all variables so keep that in mind.
This part will check if the hero that casts the spell has the proper items in their proper slots!
You need to be sure that each recipe you make for the profession has a different order of items!
Now when does not have the proper items, nothing will happen!
You can add more items by adding slots.
This part: 'slot 1)) Equal to Tools: Hammer' will say what slot needs to contain what item.
Lets check the then action of this if/then/else action! (This if/then/else action does not have a else action!)
-
Torn Shield
-
Then - Actions
- Set ProfessionRoll[(Player number of (Owner of (Casting unit)))] = (Random real number between 0.00 and 100.00)
- Set PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
- Floating Text - Create floating text that reads You try to create a... at PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
- Floating Text - Change (Last created floating text): Disable permanence
- Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
- Floating Text - Change the fading age of (Last created floating text) to 0.00 seconds
- Floating Text - Set the velocity of (Last created floating text) to 15.00 towards 90.00 degrees
- Custom script: call RemoveLocation(udg_PlayerHeroPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
- Wait 5.00 seconds
-
Then - Actions
I am aware that u don't need to store this however I'm more comfortable with it.
Second it will create a floating text above the hero that uses the spell telling him what he is trying to do, in this case it will tell him that he is trying to make a torn shield.
U can edit the text it will show depending on what item you are trying to make in the trigger.
The other floating text actions will determine how long it stay, when it will fade away, and how the velocity goes, I suggest using the values mentioned in the trigger.
The 5 second wait is there because it takes some time to create the item.
Now there is a second If/Then/Else action, lets take a look at its conditions.
-
Torn Shield
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ProfessionRoll[(Player number of (Owner of (Casting unit)))] Less than or equal to (60.00 + (Real(Smithing[(Player number of (Owner of (Casting unit)))])))
- Smithing[(Player number of (Owner of (Casting unit)))] Greater than or equal to 1
The first thing will be the chance that it has succeeded, you know we ordered the 'If/Then/Else Action I; Then Action' to create a random real number between 0.00 and 100.00? Well here we use it!
If the random real number it created is below 60 + the level of his profession it will succeed.
This means that the higher it's level is the higher the chance is it will succeed!
You can edit the 60 in this trigger to create lower or higher chances for the recipe.
The second thing it will check is the level of the profession. In this case if it's level is above 1 (and that's the default level) it will succeed. If his profession level is to low it will fail by default.
Example: You want the recipe: Golden Sword to have a initial 20% chance to succeed and the minimal smithing level you need for it is 50 you will need the following values:
Why -30.00? This is simple, you take the % chance you want it to succeed, that will be 20.
You reduce it with the minimal level you need for it to create, that will be 50.
Now to check what value it needs: 20.00 - 50.00 = -30.00 get it?
-
Torn Shield
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ProfessionRoll[(Player number of (Owner of (Casting unit)))] Less than or equal to (-30.00 + (Real(Smithing[(Player number of (Owner of (Casting unit)))])))
- Smithing[(Player number of (Owner of (Casting unit)))] Greater than or equal to 50
You reduce it with the minimal level you need for it to create, that will be 50.
Now to check what value it needs: 20.00 - 50.00 = -30.00 get it?
Lets move on to the then action of this action.
Everything you see here will happen when the player that uses the profession has the required profession level for it, and has succeeded with the chance we created earlier.
-
Then - Actions
- Item - Remove (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 2)
- Item - Remove (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 3)
- Hero - Create Torn Shield and give it to PlayerHero[(Player number of (Owner of (Casting unit)))]
- Set Smithing[(Player number of (Owner of (Casting unit)))] = (Smithing[(Player number of (Owner of (Casting unit)))] + 1)
- Set PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
- Floating Text - Create floating text that reads Succes! at PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] with Z offset 0.00, using font size 10.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
- Floating Text - Change (Last created floating text): Disable permanence
- Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
- Floating Text - Change the fading age of (Last created floating text) to 0.00 seconds
- Floating Text - Set the velocity of (Last created floating text) to 15.00 towards 90.00 degrees
- Custom script: call RemoveLocation(udg_PlayerHeroPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
-
Torn Shield
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Item-type of (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 1)) Equal to Tools: Hammer
- (Item-type of (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 2)) Equal to Iron Ore
- (Item-type of (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 3)) Equal to Wood
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
After this we increase the level of the profession by one. You can edit the level it will increase with, but for lower recipes I recommend sticking to 1.
It will also show a useful floating text at the unit of the player telling him is succeeded.
This part is basically the same as the first floating text, the only thing that's different its the color and the text it will show.
Lets move to the last part of this trigger, it's very easy.
-
Torn Shield
-
Else - Actions
- Item - Remove (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 2)
- Item - Remove (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 3)
- Set PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
- Floating Text - Create floating text that reads Failed... at PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
- Floating Text - Change (Last created floating text): Disable permanence
- Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
- Floating Text - Change the fading age of (Last created floating text) to 0.00 seconds
- Floating Text - Set the velocity of (Last created floating text) to 15.00 towards 90.00 degrees
- Custom script: call RemoveLocation(udg_PlayerHeroPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
- Else - Actions
-
Else - Actions
- It will not create a item.
- It will not increase the level of the profession.
- The text message has a different color and says that it failed.
Now we have tamed this beast of a trigger! But we are not done yet!
We want players to check on their current profession levels so they know if they can create the item or not but this is very easy.
Level Check Command
Of course we also need to tell the people how high their current profession levels are.
We do this with this simple trigger:
-
Showing Levels
-
Events
- Player - Player 1 (Red) types a chat message containing -profession as An exact match
- Player - Player 2 (Blue) types a chat message containing -profession as An exact match
- Player - Player 3 (Teal) types a chat message containing -profession as An exact match
- Player - Player 4 (Purple) types a chat message containing -profession as An exact match
- Player - Player 5 (Yellow) types a chat message containing -profession as An exact match
- Player - Player 6 (Orange) types a chat message containing -profession as An exact match
- Player - Player 7 (Green) types a chat message containing -profession as An exact match
- Player - Player 8 (Pink) types a chat message containing -profession as An exact match
- Conditions
-
Actions
- Game - Display to (Player group((Triggering player))) the text: (Smithing Level: + (String(Smithing[(Player number of (Triggering player))])))
-
Events
You can also just add more lines, just change the integer and text of the message for example:
- Display to (Player group((Triggering player))) the text: (Alchemy Level: + (String(Alchemy[(Player number of (Triggering player))])))
_______________________________________
Limitations (Optional)
This will show you some things you can do with this trigger, for example adding limits.
This part however is not included in the first sample map, there is however a copy attached that has it with limits.
Basics
You don't want people to have all professions?
Well they can decide and purchase them for themselves.
We only need to adjust the profession triggers a bit, I suggest you read the first part if you want to learn about the trigger I'm using.
To start we will need to decide how people will be able to take a profession. Lets do it by buying an item!
I'll call this item: Learn Smithing
This is just a dummy item that does nothing but start a trigger we will make.
You will have to create one for each profession you'll have.
We also need some variables.
First make a boolean for each profession (and add an array ofcourse).
As an example we will use ProfessionSmithing, it's false by default.
We need this boolean to see if the player has learned the profession.
Now we make a integer variable as an array aswell.
I'm calling it: LearnedProfessions, we will use this to see how many profession the player has learned. Lets make it so that the player can only learn 2 professions for now.
Remember to set it at 0. (Default.)
Well they can decide and purchase them for themselves.
We only need to adjust the profession triggers a bit, I suggest you read the first part if you want to learn about the trigger I'm using.
To start we will need to decide how people will be able to take a profession. Lets do it by buying an item!
I'll call this item: Learn Smithing
This is just a dummy item that does nothing but start a trigger we will make.
You will have to create one for each profession you'll have.
We also need some variables.
First make a boolean for each profession (and add an array ofcourse).
As an example we will use ProfessionSmithing, it's false by default.
We need this boolean to see if the player has learned the profession.
Now we make a integer variable as an array aswell.
I'm calling it: LearnedProfessions, we will use this to see how many profession the player has learned. Lets make it so that the player can only learn 2 professions for now.
Remember to set it at 0. (Default.)
Trigger: Learning a Profession
Now we have done the basics we will need to create a trigger that will activate when u learn a profession!
This will need a small but very important trigger. Lets take a look at it.
Looks complicated huh? Well it's not that hard.
Lets start by cutting this trigger in small bits.
I can already tell you this: "Take a good look at the conditions!"
Basicly when a unit gains the item that will learn the profession the trigger will be started.
Now if the player has not learned 2 professions and has not learned the profession Smithing he will gain that profession by setting the boolean ProfessionSmithing to true for the owner of the buying unit.
It will also add 1 point to the amount of professions that the player has learned. When this reaches 2 he will not be able to learn more professions.
It will also create a nice floating tekst telling that he has learned a profession.
But what if this is not true? Lets look at the 3th part.
Oke, this is pretty easy, isn't it?
This will happen when he has already learned the profession Smithing.
It will only remove the dummy item, and will tell the player that he has already learned this profession.
But what if the player already has 2 professions?
That's no to hard, he will just get a different message that he can't learn more professions.
This will need a small but very important trigger. Lets take a look at it.
-
Buying Smithing
-
Events
- Unit - A unit Acquires an item
-
Conditions
- (Item-type of (Item being manipulated)) Equal to Learn Smithing
-
Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- LearnedProfessions[(Player number of (Owner of (Triggering unit)))] Less than 2
- ProfessionSmithing[(Player number of (Owner of (Triggering unit)))] Equal to False
-
Then - Actions
- Item - Remove (Item being manipulated)
- Set LearnedProfessions[(Player number of (Owner of (Triggering unit)))] = (LearnedProfessions[(Player number of (Owner of (Triggering unit)))] + 1)
- Set ProfessionSmithing[(Player number of (Owner of (Triggering unit)))] = True
- Set PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
- Floating Text - Create floating text that reads You have learned th... at PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
- Floating Text - Change (Last created floating text): Disable permanence
- Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
- Floating Text - Change the fading age of (Last created floating text) to 0.00 seconds
- Floating Text - Set the velocity of (Last created floating text) to 15.00 towards 90.00 degrees
- Custom script: call RemoveLocation(udg_PlayerHeroPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- LearnedProfessions[(Player number of (Owner of (Triggering unit)))] Less than 2
- ProfessionSmithing[(Player number of (Owner of (Triggering unit)))] Equal to True
-
Then - Actions
- Item - Remove (Item being manipulated)
- Set PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
- Floating Text - Create floating text that reads You have already le... at PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
- Floating Text - Change (Last created floating text): Disable permanence
- Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
- Floating Text - Change the fading age of (Last created floating text) to 0.00 seconds
- Floating Text - Set the velocity of (Last created floating text) to 15.00 towards 90.00 degrees
- Custom script: call RemoveLocation(udg_PlayerHeroPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- LearnedProfessions[(Player number of (Owner of (Triggering unit)))] Equal to 2
-
Then - Actions
- Item - Remove (Item being manipulated)
- Set PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
- Floating Text - Create floating text that reads You have reached th... at PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
- Floating Text - Change (Last created floating text): Disable permanence
- Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
- Floating Text - Change the fading age of (Last created floating text) to 0.00 seconds
- Floating Text - Set the velocity of (Last created floating text) to 15.00 towards 90.00 degrees
- Custom script: call RemoveLocation(udg_PlayerHeroPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Events
Lets start by cutting this trigger in small bits.
I can already tell you this: "Take a good look at the conditions!"
-
Buying Profession
-
Events
- Unit - A unit Acquires an item
-
Conditions
- (Item-type of (Item being manipulated)) Equal to Learn Smithing
-
Events
-
Buying Profession
-
Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- LearnedProfessions[(Player number of (Owner of (Triggering unit)))] Less than 2
- ProfessionSmithing[(Player number of (Owner of (Triggering unit)))] Equal to False
-
Then - Actions
- Item - Remove (Item being manipulated)
- Set LearnedProfessions[(Player number of (Owner of (Triggering unit)))] = (LearnedProfessions[(Player number of (Owner of (Triggering unit)))] + 1)
- Set ProfessionSmithing[(Player number of (Owner of (Triggering unit)))] = True
- Set PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
- Floating Text - Create floating text that reads You have learned th... at PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
- Floating Text - Change (Last created floating text): Disable permanence
- Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
- Floating Text - Change the fading age of (Last created floating text) to 0.00 seconds
- Floating Text - Set the velocity of (Last created floating text) to 15.00 towards 90.00 degrees
- Custom script: call RemoveLocation(udg_PlayerHeroPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Actions
It will also add 1 point to the amount of professions that the player has learned. When this reaches 2 he will not be able to learn more professions.
It will also create a nice floating tekst telling that he has learned a profession.
But what if this is not true? Lets look at the 3th part.
- Buying Profession
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- LearnedProfessions[(Player number of (Owner of (Triggering unit)))] Less than 2
- ProfessionSmithing[(Player number of (Owner of (Triggering unit)))] Equal to True
-
Then - Actions
- Item - Remove (Item being manipulated)
- Set PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
- Floating Text - Create floating text that reads You have already le... at PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
- Floating Text - Change (Last created floating text): Disable permanence
- Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
- Floating Text - Change the fading age of (Last created floating text) to 0.00 seconds
- Floating Text - Set the velocity of (Last created floating text) to 15.00 towards 90.00 degrees
- Custom script: call RemoveLocation(udg_PlayerHeroPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
This will happen when he has already learned the profession Smithing.
It will only remove the dummy item, and will tell the player that he has already learned this profession.
But what if the player already has 2 professions?
-
Buying Profession
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- LearnedProfessions[(Player number of (Owner of (Triggering unit)))] Equal to 2
-
Then - Actions
- Item - Remove (Item being manipulated)
- Set PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
- Floating Text - Create floating text that reads You have reached th... at PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
- Floating Text - Change (Last created floating text): Disable permanence
- Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
- Floating Text - Change the fading age of (Last created floating text) to 0.00 seconds
- Floating Text - Set the velocity of (Last created floating text) to 15.00 towards 90.00 degrees
- Custom script: call RemoveLocation(udg_PlayerHeroPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Else - Actions
Trigger: Editing the Profession Trigger
Now that we have done this we need to add an if/then/else at the start of the profession trigger we made earlier in this tutorial.
That condition for the if/then/else is:
With these limits people will have to choose before picking what they want.
If they don;t have the profession, nothing will happen. Just like in the real world.
TIP: Do not add a text at the last else saying that nothing happens, there might be an other profession it has learned.
In that case it will show a floating text that nothing happens and that he is doing something, kinda stupid huh?
Be creative with these triggers! I'm sure they can be useful to you.
That condition for the if/then/else is:
- ProfessionSmithing[(Player number of (Owner of (Triggering unit)))] Equal to True
-
Torn Shield w Limits
-
Events
- Unit - A unit Begins casting an ability
-
Conditions
- (Ability being cast) Equal to Action
-
Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ProfessionSmithing[(Player number of (Owner of (Triggering unit)))] Equal to True
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Item-type of (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 1)) Equal to Tools: Hammer
- (Item-type of (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 2)) Equal to Iron Ore
- (Item-type of (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 3)) Equal to Wood
-
Then - Actions
- Set ProfessionRoll[(Player number of (Owner of (Casting unit)))] = (Random real number between 0.00 and 100.00)
- Set PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
- Floating Text - Create floating text that reads You try to create a... at PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
- Floating Text - Change (Last created floating text): Disable permanence
- Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
- Floating Text - Change the fading age of (Last created floating text) to 0.00 seconds
- Floating Text - Set the velocity of (Last created floating text) to 15.00 towards 90.00 degrees
- Custom script: call RemoveLocation(udg_PlayerHeroPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
- Wait 5.00 seconds
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ProfessionRoll[(Player number of (Owner of (Casting unit)))] Less than or equal to (60.00 + (Real(Smithing[(Player number of (Owner of (Casting unit)))])))
- Smithing[(Player number of (Owner of (Casting unit)))] Greater than or equal to 1
-
Then - Actions
- Item - Remove (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 2)
- Item - Remove (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 3)
- Hero - Create Torn Shield and give it to PlayerHero[(Player number of (Owner of (Casting unit)))]
- Set Smithing[(Player number of (Owner of (Casting unit)))] = (Smithing[(Player number of (Owner of (Casting unit)))] + 1)
- Set PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
- Floating Text - Create floating text that reads Succes! at PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] with Z offset 0.00, using font size 10.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
- Floating Text - Change (Last created floating text): Disable permanence
- Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
- Floating Text - Change the fading age of (Last created floating text) to 0.00 seconds
- Floating Text - Set the velocity of (Last created floating text) to 15.00 towards 90.00 degrees
- Custom script: call RemoveLocation(udg_PlayerHeroPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
-
Else - Actions
- Item - Remove (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 2)
- Item - Remove (Item carried by PlayerHero[(Player number of (Owner of (Casting unit)))] in slot 3)
- Set PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
- Floating Text - Create floating text that reads Failed... at PlayerHeroPoint[(Player number of (Owner of (Triggering unit)))] with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
- Floating Text - Change (Last created floating text): Disable permanence
- Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
- Floating Text - Change the fading age of (Last created floating text) to 0.00 seconds
- Floating Text - Set the velocity of (Last created floating text) to 15.00 towards 90.00 degrees
- Custom script: call RemoveLocation(udg_PlayerHeroPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
-
If - Conditions
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Events
With these limits people will have to choose before picking what they want.
If they don;t have the profession, nothing will happen. Just like in the real world.
TIP: Do not add a text at the last else saying that nothing happens, there might be an other profession it has learned.
In that case it will show a floating text that nothing happens and that he is doing something, kinda stupid huh?
Be creative with these triggers! I'm sure they can be useful to you.
_______________________________________
Extra Notes
I hope you learned something useful from this tutorial.
If you have something to ask about this feel free to send me a PM or mail me at [email protected].
There is also a map attachment with these triggers to check it out!
Good luck with your maps!
Attachments
Last edited: