• 🏆 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!

Hero skill selection

Status
Not open for further replies.
Level 3
Joined
Oct 5, 2016
Messages
53
Hi, so I found this trigger:

  • MKing
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • ((Owner of (Triggering unit)) controller) Equal to Computer
    • Actions
      • For each (Integer A) from 1 to (Unspent skill points of (Triggering unit)), do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Triggering unit)) Equal to Mountain King
            • Then - Actions
              • Hero - Learn skill for (Triggering unit): Human Mountain King - Bash
              • Hero - Learn skill for (Triggering unit): Human Mountain King - Bash
            • Else - Actions
But there is one problem. Hero won't learn a skill at spawn, so there is always 1 skill point missing. Any way I can fix this? I've been trying to change events, but didn't succeed
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,019
Did you try catching when a hero first enters the map with the 'unit enters playable map area' event? If it doesn't work for that maybe the hero doesn't have an unspent skill point immediately, upon being spawned (would be weird if this is the case) so you could try adding in a Wait action to briefly delay trying to level up Bash.
 
Level 3
Joined
Oct 5, 2016
Messages
53
Haven't even had a clue that game would ask for some time to calculate points, thanks for an advice. By the way, I want to ask about one more thing. How to correctly configure revive system for melee map? I'm trying to order altar to revive dead heroes on unit-dead event, but can't order altar to do something since it's not built yet.
 
Level 3
Joined
Oct 5, 2016
Messages
53
So this is my reviving trigger but it won't work if ai doesn't have enough gold. What's wrong with that?
  • Hero Reviving
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Owner of (Triggering unit)) controller) Equal to Computer
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Wait 10.00 seconds
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Wait until (((Picked player) Current gold) Greater than or equal to (Custom value of (Revivable Hero))), checking every 1.00 seconds
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) Current gold) Greater than or equal to (Custom value of (Revivable Hero))
            • Then - Actions
              • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
                • Loop - Actions
                  • Unit - Order (Picked unit) to Revive Hero (Triggering unit)
            • Else - Actions
 
Level 13
Joined
May 10, 2009
Messages
868
Try to do something like storing a dead hero in a group, then checking every 2 seconds (or 1) if the owner of that hero has enough money to revive them. Also, create an array variable (unit) and store the computer's altar when the game starts. Your trigger could be something like this:

  • Detect Computer Death
    • Events
      • Unit - A unit Becomes revivable
    • Conditions
      • ((Owner of (Triggering unit)) controller) Equal to Computer
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • -------- Enable Revive Computer Hero trigger if group is empty --------
      • Custom script: if FirstOfGroup(udg_DeadUnits_Group) == null then
      • Trigger - Turn on Revive Computer Hero <gen>
      • Custom script: endif
      • -------- Add hero to the group --------
      • Unit Group - Add (Triggering unit) to DeadUnits_Group
  • Revive Computer Hero
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in DeadUnits_Group and do (Actions)
        • Loop - Actions
          • Set tmp_unit = (Picked unit)
          • Set tmp_player = (Owner of tmp_unit)
          • -------- Check player's gold and if Altar exists --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Computer_Altar[(Player number of tmp_player)] is dead) Equal to False
              • (tmp_player Current gold) Greater than or equal to (Custom value of tmp_unit)
            • Then - Actions
              • -------- Attempting to revive a hero. --------
              • Unit - Order Computer_Altar[(Player number of tmp_player)] to Revive Hero tmp_unit
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (tmp_unit is dead) Equal to False
                • Then - Actions
                  • -------- The hero is alive, remove it from this group. --------
                  • Unit Group - Remove tmp_unit from DeadUnits_Group
                  • -------- Check if the group is empty, if yes, then turn this trigger off. --------
                  • Custom script: if FirstOfGroup(udg_DeadUnits_Group) == null then
                  • Trigger - Turn off (This trigger)
                  • Custom script: endif
                • Else - Actions
            • Else - Actions

This is a very easy way of reviving computer heroes with Altar. The first trigger will only add a hero when they be revivable. You can use hashtable or an indexing method too, but I think this way is quite sufficient.
 
Level 13
Joined
May 10, 2009
Messages
868
I've attached a map to this post, and it has the same example that I told you about.

EDIT: Of course, I was assuming that those altars are pre-placed in your map.

If you're making a melee map, then you can detected when an altar is constructed.

  • Building Altar
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • ((Owner of (Triggering unit)) controller) Equal to Computer
      • Or - Any (Conditions) are true
        • Conditions
          • -------- Add here all the possible Altars that exist in your map --------
          • (Unit-type of (Triggering unit)) Equal to Altar of Kings
          • (Unit-type of (Triggering unit)) Equal to Altar of Storms
          • (Unit-type of (Triggering unit)) Equal to Altar of Darkness
          • (Unit-type of (Triggering unit)) Equal to Altar of Elders
    • Actions
      • Set Computer_Altar[(Player number of (Triggering player))] = (Triggering unit)

EDIT 2: I've added a few more things, so the revive trigger will keep looking for a new altar in case the first one be destroyed. Delete the last IF / THEN / ELSE (that's inside Revive Computer Hero trigger) in case you want to be using "Build Altar" trigger (it would be redundant having both at the same time).
 

Attachments

  • Revivev2.w3x
    21.9 KB · Views: 48
Last edited:
Status
Not open for further replies.
Top