• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

No More Than Two Heroes

Status
Not open for further replies.
Level 3
Joined
Oct 27, 2009
Messages
36
Okay, I'm making a ranger for my map, and I want him to be able to charm a pet. I'll have neutral heroes walking around and everything. Unfortunately, I have run across a problem. How can I make it so that the Ranger can only have two heroes? And if you tell me to delete one, I do not want the Ranger to be deleted. As there are many pets that roam around the map, I want the Ranger to be able to charm another one if he wants to, and the last one to be deleted. I need either a trigger to instaneously do it or some sort of system where the Ranger can give up the previous pet and get another one.
 
Level 13
Joined
Feb 8, 2009
Messages
1,193
How about you could give up the pet as a command like kill the rangers pet and so having anther pet and just put a trigger were that player can only have 2 heros.
 
Level 5
Joined
Nov 6, 2009
Messages
185
Well, assuming that the player owns the ranger and the 2 heroes (3 units) and that the ability being cast is something like charm.

  • Trigger
    • Events
      • Unit - A unit starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Ability
    • Actions
      • If ((Number of units in (Units owned by Player 1 (Red))) Equal to 3) then do (Unit - Kill (Ownership-changed unit)) else do (Do nothing)
 
Level 3
Joined
Oct 27, 2009
Messages
36
Good idea, but I need the ranger to be able to switch their pets. Your trigger above would kill the unit that was just charmed, but I need the first one to be charmed to die.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Maybe with hashtables:

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Hash_Pets = (Last created hashtable)
  • Untitled Trigger 015
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Holy Light
    • Actions
      • -------- -------------------- --------
      • -------- Loads the two last charmed pets to variables --------
      • -------- -------------------- --------
      • Set Temp_Unit_1 = (Load (Key pet_new) of (Key (Triggering unit)) in Hash_Pets)
      • Set Temp_Unit_2 = (Load (Key pet_old) of (Key (Triggering unit)) in Hash_Pets)
      • -------- -------------------- --------
      • -------- Kills the "older" pet --------
      • -------- -------------------- --------
      • Unit - Kill Temp_Unit_2
      • -------- -------------------- --------
      • -------- Saves the previous newer pet as the older pet, saved the new pet as newer pet --------
      • -------- -------------------- --------
      • Hashtable - Save Handle OfTemp_Unit_1 as (Key pet_old) of (Key (Triggering unit)) in Hash_Pets
      • Hashtable - Save Handle Of(Target unit of ability being cast) as (Key pet_new) of (Key (Triggering unit)) in Hash_Pets
 
Level 6
Joined
Nov 7, 2007
Messages
39
  • Switch
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Animate Dead
    • Actions
      • Set num1 = (Player number of (Owner of (Triggering unit)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • heros[(2 x num1)] Equal to No unit
        • Then - Actions
          • Set num1 = (2 x num1)
        • Else - Actions
          • Set num1 = ((Player number of (Owner of (Triggering unit))) + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • heros[(2 x num1)] Equal to No unit
            • Then - Actions
              • Set num1 = (2 x num1)
            • Else - Actions
              • Set num1 = (Player number of (Owner of (Triggering unit)))
      • Unit - Remove heros[num1] from the game
      • Set heros[num1] = (Target unit of ability being cast)
In var editor you need:
-unit array[24] heros
-integer num1
 
Status
Not open for further replies.
Top