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

[Trigger] Little Problem...

Status
Not open for further replies.
Level 3
Joined
Dec 17, 2007
Messages
28
I'm having a problem with my juxtapose trigger.
I've tried to create a illusion when unit is hit.
When unit is attacked there is 20% chance that attacking unit will create his illusion.
I've used "unit is attacked" event but image creates even before unit is hit so I can order attacking unit to stop and illusion will be created even without dealing damage!!!!
I should use "takes damage" event but wich unit should I use for it?
 
Level 3
Joined
Dec 18, 2007
Messages
43
. . .
JASS:
function create_trigger takes unit u returns nothing
   local integer i = udg_Int + 1
   set udg_Int = i
   set udg_Trig[i] = CreateTrigger(  )
   call TriggerRegisterUnitEvent( udg_Trig[i], u, EVENT_UNIT_DAMAGED )
   call TriggerAddAction( udg_Trig[i], function *your trigger function* )
endfunction

  • Illusion
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Ability being cast) Equal to Illusion
    • Actions
      • Custom script: call create_trigger(GetTriggerUnit())
Vars: Int - integer
Trig - trigger(array)
 
Level 3
Joined
Dec 18, 2007
Messages
43
For example:
Trigger name is MyTrigger
Convert it into text and see:

JASS:
function Trig_MyTrigger_Actions takes nothing returns nothing
Copy whole function and paste it before my Jass code (In Custom Script Code) then rename Trig_MyTrigger_Actions with (for example) MyTrigger. Then replace *your trigger function* with MyTrigger.
 
Last edited:
Level 3
Joined
Dec 17, 2007
Messages
28
Example

  • juxtapose example
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Set HitChance = (Random integer number between 1 and 5)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HitChance Equal to 5
        • Then - Actions
          • Set point = (Position of (Attacking unit))
          • Unit - Create 1 Peasant for (Owner of (Attacking unit)) at point facing Default building facing degrees
          • Hero - Create Wand of Illusion and give it to (Last created unit)
          • Hero - Order (Last created unit) to use (Item carried by (Last created unit) of type Wand of Illusion) on (Attacking unit)
          • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
          • Custom script: call RemoveLocation( udg_point )
        • Else - Actions
If this helps...:wsad:
Don't worry peasant is actaully dummy unit,invulnerable with item slots and mana...
 
Level 3
Joined
Dec 17, 2007
Messages
28
Lol,I'm sorry but I dont like JASS because many people don't either and I'm making a map. Beacause I hate map protectors I will let it opened so others can learn(LOL,right)...
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
"A unit is attacked" event occurs when the attacking unit startes the attack animation.

For this you will need one trigger to define with a variable who is the attacker, and a second trigger that will run on the event "Unit_Variable takes damage".

This is a example for what you need

  • Starting Attack
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Set Attacked_Unit = (Triggering unit)
      • Set Attacking_Unit = (Attacking unit)
  • Taking Damage
    • Events
    • Conditions
    • Actions
      • Set Point = (Position of Attacking_Unit)
      • Set Ineteger = (Random integer number between 1 and 5)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Ineteger Equal to 5
        • Then - Actions
          • Unit - Create 1 Footman for (Owner of Attacking_Unit) at Point facing Default building facing degrees
        • Else - Actions
      • Custom script: call RemoveLocation(udg_Point)
  • Event
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Trigger - Add to Taking Damage <gen> the event (Unit - Attacked_Unit Takes damage)

You would most likely put a condition(s) in "Starting Attack".
 
Status
Not open for further replies.
Top