[Trigger] Why does my hero not learn this spell?

Level 4
Joined
Mar 21, 2014
Messages
79
Hi everyone,

I wrote a script in order to learn a hero a new ability.
What it should do:

If the dialog button is clicked (where the player chooses his ability),
the new ability should be learned by the hero. He has to be able to improve this ability up to level 4, when leveling.
Problems: If I use "Modify unspent Skill of Hero: Add+1" and "Learn Skill" (as seen in the code),
the hero does not learn any ability.

If I use "Add Ability", the hero learns the spell, but can't improve it by leveling.

Here is my code:

[trigger="spell"]Quest3x3
Events
Dialog - A dialog button is clicked for Spell
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Clicked dialog button) Equal to SpellButton[6]
Then - Actions
Selection - Select Held for Player 2 (Blue)
Trigger - Turn on Quest3x2 <gen>
Else - Actions
Trigger - Turn off (This trigger)
Trigger - Turn off Quest3x2 <gen>
Hero - Modify unspent skill points of Held: Add 1 points
Set HeroSpellStartLevel = (Hero level of Held)
Selection - Select Held for Player 2 (Blue)
Special Effect - Destroy Ausrufezeichen[3]
Unit - Remove BCK from the game
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Clicked dialog button) Equal to SpellButton[1]
Then - Actions
Hero - Learn skill for Held: Critical Strike
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Clicked dialog button) Equal to SpellButton[2]
Then - Actions
Hero - Learn skill for Held: Healing Wave (Hero)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Clicked dialog button) Equal to SpellButton[3]
Then - Actions
Hero - Learn skill for Held: Chain Lightning (Hero)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Clicked dialog button) Equal to SpellButton[4]
Then - Actions
Hero - Learn skill for Held: Frost Armor (Hero)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Clicked dialog button) Equal to SpellButton[5]
Then - Actions
Hero - Learn skill for Held: Immolation (Hero)
Else - Actions
Do nothing
[/trigger]
 
Level 9
Joined
Apr 19, 2011
Messages
447
Does your hero have all those spells? I mean, did you put them in the "Object Editor - Hero Abilities" field? Assuming you have set up the dialog correctly, I don't see why this wouldn't work, apart from the hero nor having the spells. As far as I know, a hero can't learn a spell if he doesn't have it in the Object Editor.

Kind Regards
 
Level 4
Joined
Mar 21, 2014
Messages
79
Does your hero have all those spells? I mean, did you put them in the "Object Editor - Hero Abilities" field? Assuming you have set up the dialog correctly, I don't see why this wouldn't work, apart from the hero nor having the spells. As far as I know, a hero can't learn a spell if he doesn't have it in the Object Editor.

Kind Regards


Well no I don't. But my question is: If I do so, would my hero be able to skill all 5 spells in the whole map? I have 5 Spells. Each hero has already (over map 1, 2 and now we are in map 3 of this campaign) his own skills (mostly) on highest level. Thus, a new spell may be chosen. But only one!
Do all my heroes need to know all 5 spells?
Isn't it then possible to skill all 5 spells during the whole map?


Kind Regards
 
Level 4
Joined
Mar 21, 2014
Messages
79
I think what you said is not the right way to solve my problem!

Because: If I would add to every of my hero all those 5 abilites in the object editor, my "loaded hero from map 2" would automatically learn all those 5 abilities when map 3 is loaded. but all my 5 spells are made in a way, that they can't be skilled all at once (research and use buttons have all the same position).

So...

"Unit: Add Ability" was working properly: The hero learned the spell the players choosed. But the thing was, that the hero couldn't improve the spell.

Now "Hero: Add +1 Skill Point" + "Hero: Learn Skill" is not working, but maybe...

I will try:
- "Hero: Add +1 Skill Point"
- "Unit: Add Ability" to hero
- "Learn Skill" for hero

and I tell you (later, maybe tomorrow) what happens...
 
Level 9
Joined
Apr 19, 2011
Messages
447
I'm not sure I understand what you want to do exactly... However, you say that "Add Ability" works properly, but you can't make the hero level up the spell... Well, actually you can make him level up, have you tried using "Set Ability Level"? I would be like this:
- If the hero hasn't still learned the ability, use "Add Ability".
- If the hero already has the ability and you want to improve its level, use "Set Ability Level".

If this doesn't help you, please elaborate a bit more on what you want to do (your explanation seems a bit confusing for me), and I'll see what can I do.

Kind Regards
 
Level 4
Joined
Mar 21, 2014
Messages
79
I'm not sure I understand what you want to do exactly... However, you say that "Add Ability" works properly, but you can't make the hero level up the spell... Well, actually you can make him level up, have you tried using "Set Ability Level"? I would be like this:
- If the hero hasn't still learned the ability, use "Add Ability".
- If the hero already has the ability and you want to improve its level, use "Set Ability Level".

If this doesn't help you, please elaborate a bit more on what you want to do (your explanation seems a bit confusing for me), and I'll see what can I do.

Kind Regards


Yeah I think I'll do what you are saying. I just use Set Ability Level.




Sorry if it's confusing. but the thing is this:
The camapign (3 maps) uses 6 different heroes. At beginning every hero has his own spells. So for example a Mage has "Firestorm", "Frostnova", "Stats-Bonus" and "Summon Earth Golem". The first 3 mentioned spells have 4 levels, the last one has just 2 levels. Thus, if you reach lvl 14 you have spent your last skill point for one of these spells.

Now you go to map 3 in my campaign. There is a guy, who will teach you a new spell. You may choose ONE out of 5 different spells. (This new spell has 4 levels). If you learnt this spell with lvl 14, you should be on highest skill lvl with 18. But if you learn this spell with lvl 18, you should be on highest skill lvl with 22 etc...

In the object editor, each hero has in all 3 maps all the same values. In all 3 maps has a hero the same "damage plus", and "Basic Defense" and "Starting Int, Agi, Str" etc etc. ...... THUS it would change my "concept" if every hero has in map 3 in the object editor 5 additional spells.... in the object editor should every hero have just his spells from the beginning.

Hope it's clear now...
 
Level 4
Joined
Mar 21, 2014
Messages
79
Solved!

The problem is solved with this code:


[trigger="Quest3x2"]
Quest3x2
Events
Unit - A unit Is issued an order targeting an object
Conditions
(Ordered unit) Equal to Held
(Target unit of issued order) Equal to Gar'thok 0265 <gen>
Actions
Set Questhelper[0] = (Ordered unit)
Set Questhelper[1] = (Target unit of issued order)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Region centered at (Position of (Target unit of issued order)) with size (420.00, 420.00)) contains (Ordered unit)) Equal to True
Then - Actions
Trigger - Turn off (This trigger)
Trigger - Turn off QuestHelper <gen>
Unit - Make Gar'thok 0265 <gen> face Held over 0.20 seconds
Unit - Make Held face Gar'thok 0265 <gen> over 0.25 seconds
Wait 0.01 seconds
Dialog - Clear Spell
Dialog - Change the title of Spell to Zauber erlernen
Dialog - Create a dialog button for Spell labelled Critical Strike
Set SpellButton[1] = (Last created dialog Button)
Dialog - Create a dialog button for Spell labelled Healing Wave
Set SpellButton[2] = (Last created dialog Button)
Dialog - Create a dialog button for Spell labelled Chain Lightning
Set SpellButton[3] = (Last created dialog Button)
Dialog - Create a dialog button for Spell labelled Frost-Armor
Set SpellButton[4] = (Last created dialog Button)
Dialog - Create a dialog button for Spell labelled Immolation
Set SpellButton[5] = (Last created dialog Button)
Dialog - Create a dialog button for Spell labelled Cancel
Set SpellButton[6] = (Last created dialog Button)
Dialog - Show Spell for Player 2 (Blue)
Else - Actions
Trigger - Turn on QuestHelper <gen>

[/trigger]



[trigger="Quest3x3"]
Quest3x3
Events
Dialog - A dialog button is clicked for Spell
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Clicked dialog button) Equal to SpellButton[6]
Then - Actions
Selection - Select Held for Player 2 (Blue)
Trigger - Turn on Quest3x2 <gen>
Else - Actions
Trigger - Turn off (This trigger)
Trigger - Turn off Quest3x2 <gen>
Set HeroSpellStartLevel = (Hero level of Held)
Selection - Select Held for Player 2 (Blue)
Special Effect - Destroy Ausrufezeichen[3]
Game - Display to (All players) the text: Your spell will be ...
Unit - Remove BCK from the game
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Clicked dialog button) Equal to SpellButton[1]
Then - Actions
Unit - Add Critical Strike to Held
Set SpellInteger[0] = 1
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Clicked dialog button) Equal to SpellButton[2]
Then - Actions
Unit - Add Healing Wave (Hero) to Held
Set SpellInteger[0] = 2
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Clicked dialog button) Equal to SpellButton[3]
Then - Actions
Unit - Add Chain Lightning (Hero) to Held
Set SpellInteger[0] = 3
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Clicked dialog button) Equal to SpellButton[4]
Then - Actions
Unit - Add Frost Armor (Hero) to Held
Set SpellInteger[0] = 4
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Clicked dialog button) Equal to SpellButton[5]
Then - Actions
Unit - Add Immolation (Hero) to Held
Set SpellInteger[0] = 5
Else - Actions
Do nothing

[/trigger]



[trigger="SkillPoints"]
SkillPoints
Events
Unit - A unit Gains a level
Conditions
(Leveling Hero) Equal to Held
(Quest3x3 <gen> is on) Equal to False
Actions
Wait 0.01 seconds
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Hero level of Held) Equal to 30
Then - Actions
Trigger - Run SkillingHighest <gen> (checking conditions)
Else - Actions
Trigger - Run Skilling <gen> (checking conditions)

[/trigger]



[trigger="Skilling"]
Skilling
Events
Conditions
Actions
Wait 0.01 seconds
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Hero level of Held) Equal to (HeroSpellStartLevel + 2)
Then - Actions
Set SpellInteger[1] = 2
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SpellInteger[0] Equal to 1
Then - Actions
Unit - Set level of Critical Strike for Held to SpellInteger[1]
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SpellInteger[0] Equal to 2
Then - Actions
Unit - Set level of Healing Wave (Hero) for Held to SpellInteger[1]
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SpellInteger[0] Equal to 3
Then - Actions
Unit - Set level of Chain Lightning (Hero) for Held to SpellInteger[1]
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SpellInteger[0] Equal to 4
Then - Actions
Unit - Set level of Frost Armor (Hero) for Held to SpellInteger[1]
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SpellInteger[0] Equal to 5
Then - Actions
Unit - Set level of Immolation (Hero) for Held to SpellInteger[1]
Else - Actions
Do nothing
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Hero level of Held) Equal to (HeroSpellStartLevel + 4)
Then - Actions
Set SpellInteger[1] = 3
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SpellInteger[0] Equal to 1
Then - Actions
Unit - Set level of Critical Strike for Held to SpellInteger[1]
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SpellInteger[0] Equal to 2
Then - Actions
Unit - Set level of Healing Wave (Hero) for Held to SpellInteger[1]
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SpellInteger[0] Equal to 3
Then - Actions
Unit - Set level of Chain Lightning (Hero) for Held to SpellInteger[1]
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SpellInteger[0] Equal to 4
Then - Actions
Unit - Set level of Frost Armor (Hero) for Held to SpellInteger[1]
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SpellInteger[0] Equal to 5
Then - Actions
Unit - Set level of Immolation (Hero) for Held to SpellInteger[1]
Else - Actions
Do nothing
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Hero level of Held) Equal to (HeroSpellStartLevel + 6)
Then - Actions
Trigger - Run SkillingHighest <gen> (checking conditions)
Else - Actions
Do nothing

[/trigger]



[trigger="SkillingHighest"]
SkillingHighest
Events
Conditions
Actions
Wait 0.01 seconds
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SpellInteger[0] Equal to 1
Then - Actions
Unit - Set level of Critical Strike for Held to 4
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SpellInteger[0] Equal to 2
Then - Actions
Unit - Set level of Healing Wave (Hero) for Held to 4
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SpellInteger[0] Equal to 3
Then - Actions
Unit - Set level of Chain Lightning (Hero) for Held to 4
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SpellInteger[0] Equal to 4
Then - Actions
Unit - Set level of Frost Armor (Hero) for Held to 4
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SpellInteger[0] Equal to 5
Then - Actions
Unit - Set level of Immolation (Hero) for Held to 4
Else - Actions
Do nothing

[/trigger]
 
Top