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

How to create a trigger like this ?

Status
Not open for further replies.
Level 3
Joined
Dec 3, 2011
Messages
23
Event
Unit-Unit X's mana becomes greater than 100
Action
Create 1 Unit for player 1 at position of unit X
Kill unit X
 
Level 6
Joined
Nov 24, 2012
Messages
198
Like this??
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Matching unit) has buff Egg ) Equal to True)) and do (Actions)
        • Loop - Actions
          • Set Eggs = (Picked unit)
          • Set mana = (Mana of Eggs)
          • Set Pos = (Position of Eggs)
          • Unit Group - Add Eggs to EggGroup
          • Trigger - Turn on mana <gen>
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • mana Equal to 100.00
        • Then - Actions
          • Trigger - Turn off mana <gen>
          • Unit - Create (Number of units in EggGroup) Spider for Player 1 (Red) at Pos facing Default building facing degrees
          • Unit - Remove Eggs from the game
        • Else - Actions
  • mana
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set mana = (mana + 20.00)
 
Level 6
Joined
Jan 29, 2010
Messages
213
Like this??
  • Unit - Create (Number of units in EggGroup) Spider for Player 1 (Red) at Pos facing Default building facing degrees
  • Unit - Remove Eggs from the game

Better use "replace unit" action. It will do both actions removes unit and creates unit at the same time and uses less space.


___________________________________________________________________________________________
When unit type "egg" reached 100 mana. create unit type "spider" at position of "egg". Kills unit type "egg".


What do u think about adding "custom ability" to unit which would use 100mana.
When u reaches 100mana you just press that ability by your self and trigger activates.
It may only require 1ability with some lvl's for all units and triggers, like:
EGG - Custom ability (lvl1 - needs 100mana.)
Spider - Custom ability (lvl2 - needs 200mana.)
and so on...
than trigger would be like this:
  • EVENT
    • Unit starts the effect of the ability.
  • Condition
    • (Ability being cast) equal to "Your ability"
  • Actions
    • If then else
      • Conditions
        • Unit (Unit type of (casting unit)) equal to "your unit"
      • Than Actions
        • Unit - Unit replace casting unit with "your unit2"
      • Else Actions
    • If then else
      • Conditions
        • Unit (Unit type of (casting unit)) equal to "your unit2"
      • Than Actions
        • Unit - Unit replace casting unit with "your unit3"
      • Else Actions
 
Last edited:
Level 10
Joined
Dec 15, 2012
Messages
650
I think you want like this? @.@
- Event -
Time - Every 0.01 seconds

- Conditions -

- Actions -
Unit Group - Pick every units in (Playable map area) matching
---Condition 1 - (Mana of (Picked unit)) equal to 100
---Condition 2 - (Unit-Type of Picked unit) equal to Egg
+Loop - Actions+
Replace (Picked unit) with a Spider using the new unit's max life and mana

And then if you want to set the Egg's mana every second, use this trigger
- Events -
Time - Every 1.00 seconds

- Conditions -

- Actions -
Unit Group - Pick every units in (Playable map area) matching
---Condition 1 - (Mana of (Picked unit)) not equal to 100
---Condition 2 - (Unit-Type of Picked unit) equal to Egg
+Loop Actions+
Set (Picked unit)'s mana to ((mana of (Picked unit) + 1))
 
Level 6
Joined
Jan 29, 2010
Messages
213
I think killing egg would be more apropriate. For eye candy matters :) (I assume egg is some of the spider eggs war3 has)

You are right replacing or removing egg would look bad, I agree with u. Dieing egg would make spawning spider animation. :)



  • Time - Every 0.01 seconds
  • Time - Every 1.00 seconds

PLS Time every sec. makes map go laggy. Triggers start leaking. It may ruin the map.
There's other ways to do this without "time every sec.".
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
Y
PLS Time every sec. makes map go laggy. Triggers start leaking. It may ruin the map.
There's other ways to do this without "time every sec.".
Agree

0.01 is used for stuff which need realy I mean REALY smooth movement as locked camera. Btw noone will recomend using a 0.01 because it slows the performance. Old computers will suicide.

Normaly for loops is used 0.03 but thats if you need some smooth movemens as knocking a unit back, jumping,dashing,camera locks.

Derp. In your case I would recomend using 0.5 to 1 sek loop depending on the mana regen. (If you havent noticed mana isn't replenished evry second)

I would recomend storing eggs in a unit group. And checking the units in that group instead all units on map. Performance issues again. I don't know how much units you'd have on the map but to check them all at once evry x sek...
Will post triggers when I get home.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Here is how I would do it with the periodic looping method mentioned above.

  • Untitled Trigger 084
    • Events
      • Map initialization
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to egg
    • Actions
      • Custom script: if GetTriggerEventId() == EVENT_GAME_ENTER_REGION
      • Unit Group - Add (Triggering unit) to group
      • Custom script: else
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((((Matching unit) is alive) Equal to True) and ((Unit-type of (Matching unit)) Equal to egg))) and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to group
      • Custom script: endif
  • Untitled Trigger 083
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of (Picked unit)) Greater than or equal to 100.00
            • Then - Actions
              • Set point = (Position of (Picked unit))
              • Unit - Kill (Picked unit)
              • Unit - Create 1 spider for (Owner of (Picked unit)) at point facing (Random angle) degrees
              • Custom script: call RemoveLocation(udg_point)
              • Unit Group - Remove (Picked unit) from group
            • Else - Actions


The autocast ability on the unit itself might work also.
 
Status
Not open for further replies.
Top