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

[Solved] Chance to Miss at Night!

Status
Not open for further replies.
Level 20
Joined
Jul 14, 2011
Messages
3,213
Hi !

I want to make all player units to have a 25% chance to miss IF they aren't within 400 Radius of a Light Source (Light Source may be a Hero with an item with 'Glowing' ability, or a Preplaced torch / fire / lamp)

I'm not sure about how to do it. I did this:


  • Night effects Turn On
    • Events
      • Game - The in-game time of day becomes Equal to 18.00
    • Conditions
    • Actions
      • Countdown Timer - Start NightCurseTimer as a Repeating timer that will expire in 3.00 seconds


  • Night effects Turn Off
    • Events
      • Game - The in-game time of day becomes Equal to 6.00
    • Conditions
    • Actions
      • Countdown Timer - Pause NightCurseTimer


  • Night Blind
    • Events
      • Time - NightCurseTimer expires
    • Conditions
    • Actions
      • Set UnitsToBlind = (Units in (Playable map area) matching (((Owner of ([I DON'T KNOW WHAT UNIT)) controller) Equal to User))
      • Set IntUnitsToBlind = (Number of units in UnitsToBlind)
      • For each (Integer A) from 1 to IntUnitsToBlind, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Dummy Chance to Miss at Night for (NEUTRAL HOSTILE, I GUESS) at (Position of [I DON'T KNOW WHAT UNIT]) facing Default building facing degrees
          • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
          • Unit - Order (Last created unit) to Undead Banshee - Curse [I DON'T KNOW WHAT UNIT]


- I also have to exclude the units within a lightsource, but I don't know how to do it.
- The Dummy has no model and has locust, as a Dummy is supposed to be :p
- Curse has a 3.2 seg duration, and a 0.25 Chance to Miss. 9999 range to cast.
- I know I have to set the Temp_Point of the unit and remove it later, but I DON'T KNOW WHAT UNIT xD and I don't know how to set the variable either to include the position of each unit.
 
So
In the Loop :

  • Set RandomUnitToBlind (a unit) = Random unit from UnitsToBlind
  • Remove RandomUnitToBlind from UnitsToBlind
  • If then else - Do multiples Actions :
  • If :
  • Or - any conditions are true :
  • Don't know which conditions you need to use for the lightsource detection. So.
  • Then - Do actions :
  • Unit - Create 1 Dummy Chance to Miss at Night for (NEUTRAL HOSTILE) at (Position of [RandomUnitToBlind]) facing Default building facing degrees
  • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
  • Unit - Order (Last created unit) to Undead Banshee - Curse [RandomUnitToBlind]
  • Else - Do actions :
 
Last edited:
Level 20
Joined
Jul 14, 2011
Messages
3,213
Great. The Dummy is being created at the position of the unit, but keeps creating at every point the unit has been...
(I'm creating the units for Player Red to see them).

EDIT: Exclusion added (Unit has Night Vision Buff = False) / Removed If/Then/Else since wasn't necessary.

  • Night Blind
    • Events
      • Time - NightCurseTimer expires
    • Conditions
    • Actions
      • Set UnitsToBlind = (Units in (Playable map area) matching ((((Owner of (Matching unit)) controller) Equal to User) and (((Matching unit) has buff Night vision ) Equal to False)))
      • Set IntUnitsToBlind = (Number of units in UnitsToBlind)
      • For each (Integer A) from 1 to IntUnitsToBlind, do (Actions)
        • Loop - Actions
          • Set RandomUnitToBlind = (Random unit from UnitsToBlind)
          • Set PosRandomUnitToBlind = (Position of RandomUnitToBlind)
          • Unit Group - Remove RandomUnitToBlind from UnitsToBlind
          • Unit - Create 1 Dummy Chance to Miss at Night for Player 1 (Red) at PosRandomUnitToBlind facing Default building facing degrees
          • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
          • Unit - Order (Last created unit) to Undead Banshee - Curse RandomUnitToBlind
      • Custom script: call RemoveLocation(udg_PosRandomUnitToBlind)
      • Custom script: call DestroyGroup(udg_UnitsToBlind)
 
Last edited:
Level 10
Joined
Jun 6, 2007
Messages
392
Why don't you use
  • Unit Group - Pick every unit in unit group and do actions
That way you won't need to pick random unit to blind, and you won't need the number of units either. You should also remove the point inside the loop, now it only removes the location of last unit.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
You're right. Still creates dummies where the unit has been...

EDIT: LOL! xD The units that were being created were being included into the group because they were owned by Player 1. Changed to Neutral Hostile and no more Dummy overspawn :D
  • Night Blind
    • Events
      • Time - NightCurseTimer expires
    • Conditions
    • Actions
      • Set UnitsToBlind = (Units in (Playable map area) matching ((((Owner of (Matching unit)) controller) Equal to User) and (((Matching unit) has buff Night vision ) Equal to False)))
      • Unit Group - Pick every unit in UnitsToBlind and do (Actions)
        • Loop - Actions
          • Set PosRandomUnitToBlind = (Position of (Picked unit))
          • Unit - Create 1 Dummy Chance to Miss at Night for Player 1 (Red) at PosRandomUnitToBlind facing Default building facing degrees
          • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
          • Unit - Order (Last created unit) to Undead Banshee - Curse (Picked unit)
      • Custom script: call RemoveLocation(udg_PosRandomUnitToBlind)
      • Custom script: call DestroyGroup(udg_UnitsToBlind)
 
Level 10
Joined
Jun 6, 2007
Messages
392
You still remove location outside the loop.
  • Night Blind
  • Events
    • Time - NightCurseTimer expires
  • Conditions
  • Actions
    • Set UnitsToBlind = (Units in (Playable map area) matching ((((Owner of (Matching unit)) controller) Equal to User) and (((Matching unit) has buff Night vision ) Equal to False)))
    • Unit Group - Pick every unit in UnitsToBlind and do (Actions)
      • Loop - Actions
        • Set PosRandomUnitToBlind = (Position of (Picked unit))
        • Unit - Create 1 Dummy Chance to Miss at Night for Player 1 (Red) at PosRandomUnitToBlind facing Default building facing degrees
        • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
        • Unit - Order (Last created unit) to Undead Banshee - Curse (Picked unit)
        • Custom script: call RemoveLocation(udg_PosRandomUnitToBlind)
    • Custom script: call DestroyGroup(udg_UnitsToBlind)
 
Level 5
Joined
Aug 16, 2010
Messages
97
Hi. Take a look at this. I guess it's what you need.
(By the way, if you want to have the lightBuff on units other than the torch, I can make another trigger for you. For now it only adds the buff who are around the torch carrier.)
 

Attachments

  • Night Curse.w3x
    10.2 KB · Views: 43
Level 20
Joined
Jul 14, 2011
Messages
3,213
Oh! Thanks to you all, but right now it's working great. Just like I want it to be.I fixed the location Erkki2 said.

Thanks for the map Dr.Killer! I'm ecluding the units that doesn't have Night Vision buff (Wich is the buff the Torch applies) and custom torchs placed in the map are indeed units with locust and the same glow aura.

I have an Ability to add the Torch model.
Another ability to add the glow.
Another ability to add the aura.

Not, if it's too dark, the units have 25% chance to miss and are 10% slower. =) and have a dark cloud on their heads.

The only bad thing is that the aura last for too long after the unit has left the 'Glow'. About 2 seconds. =/ So far i can live with that, but it annoyes me xD
 
Status
Not open for further replies.
Top