Chance on hit via trigger

Zurtrogx

Active Member
Reaction score
24
Flamethrower

Problem status: SOLVED

______________________________________________________________


I am making a custom spell called Flamethrower.
The unit has a 50% chance on each hit to use its flamethrower.
When flamethrower is used, the unit recieved a critical multiplier and splash damage, but only for that one hit.
To do this, I have to use a trigger.

This is what I've got:
Code:
Flamethrower cast
    Events
        Unit - A unit Is attacked
    Conditions
        (Unit-type of (Attacking unit)) Equal to Mechanical Master
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Random integer number between 1 and 100) Less than or equal to 50
            Then - Actions
                Unit - Add Flamethrower (Hidden Abilities)  to (Attacking unit)
                Unit - Set level of Flamethrower (Cleaving Attack)  for (Attacking unit) to (Level of Flamethrower  for (Attacking unit))
                Unit - Set level of Flamethrower (Critical Strike)  for (Attacking unit) to (Level of Flamethrower  for (Attacking unit))
                Player - Disable Flamethrower (Hidden Abilities)  for (Owner of (Attacking unit))
            Else - Actions
                Unit - Remove Flamethrower (Hidden Abilities)  from (Attacking unit)

The only problem is, it doesn't have a 50% chance to activate. It only works 25% of the time.

Why is this happening?
 

Malkier

New Member
Reaction score
2
dunno why you're getting the problem, but since its a 50% chance, you could just as easily have a random number between 1 and 2 and if it is 1 you do the stuff...
 

Zurtrogx

Active Member
Reaction score
24
Is there any event that occurs before "A unit is attacked"?
Because, if there is, I could probably use that and it will most likely work.

On that note, when does "A unit is attacked" activate?
Is it when the unit takes damage? Or when an attack is issued? Or what?

Also, sometimes only the critical works, and sometimes only the splash works.
Why would this be happening?
 

Expelliarmus

Where to change the sig?
Reaction score
48
Is there any event that occurs before "A unit is attacked"?
Because, if there is, I could probably use that and it will most likely work.
Code:
Events
        Unit - A unit Is issued an order targeting an object
    Conditions
        (Issued order) Equal to (Order(attack))
-- I could probably use that and it will most likely work
I don't think so...

On that note, when does "A unit is attacked" activate?
Is it when the unit takes damage? Or when an attack is issued? Or what?
*EDIT* Read post #6
 

Accname

2D-Graphics enthusiast
Reaction score
1,465
not when its issued its when the unit is starting to attack the enemy, it triggers when a melee unit for example runs towards the enemy and strikes out or when a ranged units shots the missle towards the enemy
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top