• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Units Refuse to be Replaced

Status
Not open for further replies.
Level 2
Joined
Aug 17, 2005
Messages
22
  • Growth
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Transfer Mana
    • Actions
      • If ((Unit-type of (Target unit of ability being cast)) Equal to Piglet) then do (Unit - Replace (Target unit of ability being cast) with a Pig using The old unit's relative life and mana) else do (Do nothing)
      • If ((Unit-type of (Target unit of ability being cast)) Equal to Calf) then do (Unit - Replace (Target unit of ability being cast) with a Cow using The old unit's relative life and mana) else do (Do nothing)
      • Unit - Remove (Casting unit) from the game

I'm making a farming map with a friend, and we have a dummy mana caster transfer mana to the baby animals. When the transfer mana spell ends, the animals are supposed to be replaced by their older counterparts.

The problem is, the baby animals are not replaced, and I cannot figure out what is wrong with my trigger. The casting unit is removed with the last line, so everything works except replacing the animals. Thank you for your help.
 
Level 2
Joined
Aug 17, 2005
Messages
22
Well, I've tried using a remove/create thing before, but it didn't work. Here's how I did it.

  • Growth
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Transfer Mana
    • Actions
      • Set Temp_Location = (Position of (Target unit of ability being cast))
      • Set Temp_Real = (Facing of (Target unit of ability being cast))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Target unit of ability being cast)) Equal to Calf
        • Then - Actions
          • Unit - Remove (Target unit of ability being cast) from the game
          • Unit - Create 1 Cow for (Owner of (Target unit of ability being cast)) at Temp_Location facing Temp_Real degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Target unit of ability being cast)) Equal to Piglet
        • Then - Actions
          • Unit - Remove (Target unit of ability being cast) from the game
          • Unit - Create 1 Pig for (Owner of (Target unit of ability being cast)) at Temp_Location facing Temp_Real degrees
        • Else - Actions
      • Unit - Remove (Casting unit) from the game
I think the problem has to be trouble recognizing the target of the ability being cast, since it sees the casting unit properly. The strange thing is I have a trigger on another map (in almost the exact same conditions) work fine with it, here's that trigger.

  • Untitled Trigger 002
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Siphon Mana
    • Actions
      • Unit - Kill (Target unit of ability being cast)
      • Unit - Kill (Casting unit)
The ability is based off of siphon mana, and I'm using it so I can tell when the unit has full mana, since siphon mana ends when target has full mana. The mana is the baby animal's growth meter.

EDIT - Actually, the second trigger does not work. I had another trigger that killed the unit. I need to know how to detect the target of an ending channeled spell.
 
Last edited:
Level 2
Joined
Aug 17, 2005
Messages
22
I was afraid of that. The problem is, I could have over a hundred baby animals of each type on the map at once. How would I go about doing this? I have no JASS experience, and JASS seems the easiest way out, using local variables.
 
Level 2
Joined
Aug 17, 2005
Messages
22
Well, yes, that would cause problems, since it takes 25 seconds for pigs and 50 seconds for cows to mature, the variable would be overwritten. I think I mght just switch it around to be based off of when the ability is cast and wait, then use an event response - target unit of ability being cast. In fact I might go further, and just have the animal cast a dummy spell to base a trigger off of.

EDIT- Thanks for your help. I got it to work using berserk, I don't know why I didn't think of doing that from the beginning. It is so much easier and more efficient this way.
 
Last edited:
Status
Not open for further replies.
Top