• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Learning And Unlearning Spells by Buying them

Status
Not open for further replies.
Level 2
Joined
Jul 26, 2011
Messages
12
Hello.
I've got a request about a spell system.

First of all I want a Hero to have 5 spells as most(these spells most be unit abilities) - since I'm using Hero Abilities for Attributes; str, agi and int.

Basically you buy spells - "learn" - to gain a spell and "unlearn" to get rid of a spell in order to buy a new one.
-Some spells need Level requirements.

I want the spells to cost x Lumber - which is gained every time a hero is leveling up

These abilities must be bounded to certain Heroes - for instance; Holy Light can only be learned buy a Cleric and Taunt by a Defender.


This is what I'm using;

  • Spell Critical
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Elementalist
      • (Item-type of (Item being manipulated)) Equal to [|cffffcc00Learn|r] |cff7777aaSpell Critical|r |cff00FF00Elementalist|r
    • Actions
      • Unit - Add Spell Critical (Elementalist) to (Triggering unit)
      • Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: [|cffffcc00Learned|...
      • Trigger - Turn off (This trigger)
      • Wait 0.02 seconds
      • Trigger - Turn on Spell Critical 2 <gen>
  • Spell Critical 2
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Elementalist
      • (Item-type of (Item being manipulated)) Equal to [|cffffcc00Learn|r] |cff7777aaSpell Critical|r |cff00FF00Elementalist|r
    • Actions
      • Unit - Set level of Spell Critical (Elementalist) for (Triggering unit) to 2
      • Trigger - Turn off (This trigger)
      • Wait 0.02 seconds
      • Trigger - Turn on Spell Critical 3 <gen>
  • Unlearn Spell Critical
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to |cffff0000Unlearn|r |cff7777aaSpell Critical|r |cff00FF00Elementalist|r
      • (Unit-type of (Triggering unit)) Equal to Elementalist
    • Actions
      • Unit - Remove Spell Critical (Elementalist) from (Triggering unit)
      • Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: |cffff0000Unlearned...
      • Player - Add 1 to (Owner of (Triggering unit)) Current lumber
      • Special Effect - Create a special effect attached to the origin of (Triggering unit) using Abilities\Spells\Undead\DarkRitual\DarkRitualTarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • Wait 0.02 seconds
      • Trigger - Turn on Spell Critical <gen>

I'm pretty much sure there are a lot better systems than this unfortunately I couldn't find them even though I searched for quit some time.

Just need help to make this system a bit more "fresh" less delay smarter way to make this would be appreciated.

Best regards!
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
Try out these triggers (assuming the maximum level of your abilities is 5):

  • Buys Spell
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Your_Item
      • (Unit-type of (Triggering unit)) Equal to Your_Unit
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Your_Ability for (Triggering unit)) Less than 1
        • Then - Actions
          • Unit - Add Your_Ability to (Triggering unit)
          • -------- [your effects] --------
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Your_Ability for (Triggering unit)) Equal to 5
            • Then - Actions
              • Player - Add 1 to (Owner of (Triggering unit)) Current lumber
            • Else - Actions
              • Unit - Set level of Your_Ability for (Triggering unit) to ((Level of Your_Ability for (Triggering unit)) + 1)
              • -------- [your effects] --------
      • Hero - Drop (Item being manipulated) from (Triggering unit)
      • Item - Remove (Last dropped item)
  • Sells Spell
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Your_Item
      • (Unit-type of (Triggering unit)) Equal to Your_Unit
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Your_Ability for (Triggering unit)) Greater than or equal to 1
        • Then - Actions
          • Player - Add (Level of Your_Ability for (Triggering unit)) to (Owner of (Triggering unit)) Current lumber
          • Unit - Remove Your_Ability from (Triggering unit)
          • -------- [your effects] --------
        • Else - Actions
      • Hero - Drop (Item being manipulated) from (Triggering unit)
      • Item - Remove (Last dropped item)
Let me know how it goes!

- Mr_Bean
 
Last edited:
Level 8
Joined
Apr 23, 2010
Messages
312
You will need to make dummy item's to make these work, I would recommend using tomes. Check the image I have attached, it shows what the dummy item should look like.

Here is the trigger for basic abilities, this will work for multiple level's. Depending on how many level's of the ability there are, just change "3" to how many level's of the ability there are.
  • Holy Light
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Holy Light
    • Actions
      • Set skill[(Player number of (Owner of (Triggering unit)))] = Holy Light
      • Wait 0.20 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of skill[(Player number of (Owner of (Triggering unit)))] for (Triggering unit)) Less than 1
        • Then - Actions
          • Unit - Add skill[(Player number of (Owner of (Triggering unit)))] to (Triggering unit)
          • Game - Display to (Player group((Owner of (Triggering unit)))) for 10.00 seconds the text: You have learned "H...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of skill[(Player number of (Owner of (Triggering unit)))] for (Triggering unit)) Less than 3
            • Then - Actions
              • Unit - Increase level of skill[(Player number of (Owner of (Triggering unit)))] for (Triggering unit)
            • Else - Actions
              • Game - Display to (Player group((Owner of (Triggering unit)))) for 5.00 seconds the text: This spell is unava...
              • Player - Add 1 to (Owner of (Triggering unit)) Current lumber
Please note that I used lumber to buy the abilities, you can change that to whatever you ant or even get rid of it.

Here is the trigger for ultimates (level 6 abilities).
  • Phoenix
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Phoenix
    • Actions
      • Set skill[(Player number of (Owner of (Triggering unit)))] = Phoenix
      • Wait 0.20 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of skill[(Player number of (Owner of (Triggering unit)))] for (Triggering unit)) Less than 1
        • Then - Actions
          • Unit - Add skill[(Player number of (Owner of (Triggering unit)))] to (Triggering unit)
          • Game - Display to (Player group((Owner of (Triggering unit)))) for 10.00 seconds the text: You have learned "P...
        • Else - Actions
          • Game - Display to (Player group((Owner of (Triggering unit)))) for 5.00 seconds the text: This spell is unava...
          • Player - Add 5 to (Owner of (Triggering unit)) Current lumber
If you have any questions feel free to ask.
 

Attachments

  • Stats.jpg
    Stats.jpg
    82.2 KB · Views: 121
Level 8
Joined
Apr 23, 2010
Messages
312
@ Mr_Bean987, Setting the ability to a variable makes it easier to configure, rather than going through every line and changing it to pheonix (if you copy + pasted the code) you can just change the variable ability.

Your right, there is no reason for that wait. I made this a while back.

@Disembowelment, remove the wait's in the trigger and it will be fine!

Oh, and add this
  • Custom script: call DestroyForce(udg_tempforce1)
to the bottom of the trigger.

Final result should look like this
  • Holy Light
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Holy Light
      • (Unit-type of (Triggering unit)) Equal to "Your Unit"
    • Actions
      • Set tempforce1 = (Player group(Owner of (Triggering unit)))
      • Set skill[(Player number of (Owner of (Triggering unit)))] = Holy Light
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of skill[(Player number of (Owner of (Triggering unit)))] for (Triggering unit)) Less than 1
        • Then - Actions
          • Unit - Add skill[(Player number of (Owner of (Triggering unit)))] to (Triggering unit)
          • Game - Display to tempforce1 for 10.00 seconds the text: You have learned "H...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of skill[(Player number of (Owner of (Triggering unit)))] for (Triggering unit)) Less than 3
            • Then - Actions
              • Unit - Increase level of skill[(Player number of (Owner of (Triggering unit)))] for (Triggering unit)
            • Else - Actions
              • Game - Display to tempforce1 for 5.00 seconds the text: This spell is unava...
              • Player - Add 1 to (Owner of (Triggering unit)) Current lumber
  • Custom script: call DestroyForce(udg_tempforce1)
This can be applied for any ability, even custom abilities! You will just need to change "Holy Light" to proper ability and either change the game message from "you have learned "Holy Light" to You have learned (name of your ability) or remove the game messages, remove the custom script and remove tempforce variable.

Variables
tempforce1 = Player Group
skill = Ability Array
 
Level 2
Joined
Jul 26, 2011
Messages
12
@ Mr_Bean987, Setting the ability to a variable makes it easier to configure, rather than going through every line and changing it to pheonix (if you copy + pasted the code) you can just change the variable ability.

Your right, there is no reason for that wait. I made this a while back.

@Disembowelment, remove the wait's in the trigger and it will be fine!

Oh, and add this
  • Custom script: call DestroyForce(udg_tempforce1)
to the bottom of the trigger.

Final result should look like this
  • Holy Light
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Holy Light
      • (Unit-type of (Triggering unit)) Equal to "Your Unit"
    • Actions
      • Set tempforce1 = (Player group(Owner of (Triggering unit)))
      • Set skill[(Player number of (Owner of (Triggering unit)))] = Holy Light
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of skill[(Player number of (Owner of (Triggering unit)))] for (Triggering unit)) Less than 1
        • Then - Actions
          • Unit - Add skill[(Player number of (Owner of (Triggering unit)))] to (Triggering unit)
          • Game - Display to tempforce1 for 10.00 seconds the text: You have learned "H...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of skill[(Player number of (Owner of (Triggering unit)))] for (Triggering unit)) Less than 3
            • Then - Actions
              • Unit - Increase level of skill[(Player number of (Owner of (Triggering unit)))] for (Triggering unit)
            • Else - Actions
              • Game - Display to tempforce1 for 5.00 seconds the text: This spell is unava...
              • Player - Add 1 to (Owner of (Triggering unit)) Current lumber
  • Custom script: call DestroyForce(udg_tempforce1)
This can be applied for any ability, even custom abilities! You will just need to change "Holy Light" to proper ability and either change the game message from "you have learned "Holy Light" to You have learned (name of your ability) or remove the game messages, remove the custom script and remove tempforce variable.

Variables
tempforce1 = Player Group
skill = Ability Array

This trigger works awesome till I realized why I used my own triggers with cop/paste.

The simple reason for that is You can't level certain Item Abilities like "Mana Pool Item".
Sad.. I was starting to enjoy this useful trigger.
 
Level 8
Joined
Apr 23, 2010
Messages
312
@Disembowelment, Are you saying your using multiple item's for each level of the ability? I'm not really understanding what your saying >.<

Hey by the way, this forum is for "World Editor Help" not triggers, so please next time post your trigger questions in the "Triggers & Scripts" section.

"Ask general questions about World Editor features and use in this forum. If you need help fixing a trigger, please post it in Triggers & Scripts. Please review the forum rules before posting."
 
Last edited:
Level 2
Joined
Jul 26, 2011
Messages
12
Yes I'm using multiple items for certain Abilities like mana pool and mana regen - since you can't level these item abilities manually - as in;

  • Unit - Set level of Mana Pool (300) for (Triggering unit) to 2
It won't allow it somehow :/

+rep to your trigger though and since I'm new to this forum I make mistakes - sorry about that I'll try re-read rules.
 
Status
Not open for further replies.
Top