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

Flashlight Lighting System

Status
Not open for further replies.
Level 7
Joined
Jun 8, 2010
Messages
283
Basically a unit has flashlight ability. When clicked on, a light will be created on the overhead of the unit. When clicked on once again, that very same light will be destroyed for that corresponding player's unit.

The following trigger does not destroy the light though:
  • flashlight universal customeee
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Flashlight
    • Actions
      • Custom script: local unit u = GetTriggerUnit()
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • flashlight[(Player number of (Owner of (Casting unit)))] Equal to False
        • Then - Actions
          • Custom script: call AddSpecialEffectTarget ("war3mapImported\\LIght_Flashlight_22.MDX", u, "overhead")
          • Custom script: set udg_flashlight_fx[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] = AddSpecialEffectTarget ("war3mapImported\\LIght_Flashlight_22.MDX", GetTriggerUnit(), "overhead")
          • Set flashlight[(Player number of (Owner of (Casting unit)))] = True
        • Else - Actions
          • Custom script: call DestroyEffect(udg_flashlight_fx[GetConvertedPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))])
          • Set flashlight[(Player number of (Owner of (Casting unit)))] = False
Any ideas why exactly?
 
Level 7
Joined
Jun 8, 2010
Messages
283
So separate this one trigger into two triggers? And okay ill change the event to "Unit Starts the Effect of an Ability".

The trigger is actually more complex than it looks, theres multiple triggers for each weapon item. The spell is just a modified simple instant-click Channel spell. Completely triggered. I have an omnilight model which is used for the spell. When the unit clicks on the spell, the triggers would Run and create a omnilight above the unit casting. This would also set the Flashlight(for the player number of the casting unit) and set this to True. The variable Flashlight is just to check the conditions whether to destroy or create the omnilight above the unit for the player since each player has their own stored variable.

flashlight(1) = player Red
flashlight(2) = Player Blue
etc...

The goal of the spell is to just illuminate the playing field of the unit and physically provide a lighting atmosphere.

As for the complex part... the unit has a variety of weapon items they can use. When used they will change into a different unit (giving different stats and damage etc), so replacing the unit using Chaos Abilities. When the unit is morphed with Chaos creating SFX above the unit can only be possible with custom triggers, as told to me by Pharoh and Berb.
 
Like I said in your pm, it should be like this:
  • flashlight universal customeee
  • Events
    • Unit - A unit starts the effect an ability
  • Conditions
    • (Ability being cast) Equal to Flashlight
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • flashlight[(Player number of (Owner of (Triggering unit)))] Equal to False
      • Then - Actions
        • Custom script: set udg_flashlight_fx[(GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit())) - 1)] = AddSpecialEffectTarget ("war3mapImported\\LIght_Flashlight_22.MDX", GetTriggerUnit(), "overhead")
        • Set flashlight[(Player number of (Owner of (Triggering unit)))] = True
      • Else - Actions
        • Custom script: call DestroyEffect(udg_flashlight_fx[(GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit())) - 1)])
        • Set flashlight[(Player number of (Owner of (Triggering unit)))] = False
 
Level 7
Joined
Jun 8, 2010
Messages
283
Ah I see, didnt know that I learned something lol :D

Now the flashlight works properly but theres so many problems on switching with weapons. When I click it with the Flashlight omnilight not on the overhead of the unit, it is created when its not supposed to unless Flashlight is equal to False. Also when unequipping the weapon, the unit switches to Melee Chaos then quickly switches back to the Shotgun AA12 unit. So basically I cannot unequip and remove the AA12 shotgun from my character. Also the omnilight is not destroyed after clicking multiple times.
 
Last edited:
Level 7
Joined
Jun 8, 2010
Messages
283
It seems I had the first trigger flipped around, it was an easy fix as I switched the True and False statements around resulting in:
  • flashlight universal customeee
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Flashlight
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • flashlight[(Player number of (Owner of (Casting unit)))] Equal to True
        • Then - Actions
          • Custom script: set udg_flashlight_fx[(GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit())) - 1)] = AddSpecialEffectTarget ("war3mapImported\\LIght_Flashlight_22.MDX", GetTriggerUnit(), "overhead")
          • Set flashlight[(Player number of (Owner of (Triggering unit)))] = False
        • Else - Actions
          • Custom script: call DestroyEffect(udg_flashlight_fx[(GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit())) - 1)])
          • Set flashlight[(Player number of (Owner of (Triggering unit)))] = True
Now here comes the complex part of the other trigger. I have changed it a bit and updated it here and there. So basically the problem is that the unit is stuck with the weapon and cannot revert back to the melee unit. Could someone explain to me exactly what is causing the unit to morph into melee but a second later itll morph back into the shotgun unit, so im stuck on shotgun :|

So to simplify the issue:
Unit casts light, var = true
omnilight is created on overhead
Unit uses shotgun item
unit morphs into shotgun item
light destroyed from old unit and attaches to new morphed unit
***Everything works perfectly up to here. Anyways continuing one...***
Unit uses light, var = false
omnilight is destroyed from overhead
Unit uses shotgun item
Unit morphs into Melee
**Less than One Second Later**
Unit morphs back into aa12 strangely and does not morph back properly to the melee unit


The trigger is comprised of 4 conditional actions.
Condition 1: If unit is equipped with AA12 Shotgun and flashlight = FALSE, then omnilight will be created above the morphed chaos unit
Condition 2: If unit is eqiupped with AA12 Shotgun and flashlight = TRUE, then destroy existing omnilight*
Condition 3: If unit is a Melee Unit and flashlight = FALSE, then omnilight will be created above the morphed chaos unit
Condition 4: If unit is a Melee Unit and flashlight = TRUE, then destroy existing omnilight *

*Omnilight would be created then destroyed in order to set that existing omnilight for the corresponding unit's owner

  • chaos aa12 BETA
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Unit-type of (Hero manipulating item)) Not equal to Zombie (Hooked Flesh)
      • (Item-type of (Item being manipulated)) Equal to AA12 Tactical Shotgun
    • Actions
      • Custom script: local unit u = GetTriggerUnit()
      • -------- Melee: Action = Flashlight On, Else Action = Flashlight Off --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Hero manipulating item)) Equal to TUCU Marine (AA-12)
          • flashlight[(Player number of (Owner of (Casting unit)))] Equal to False
        • Then - Actions
          • Hero - Drop the item from slot 1 of (Hero manipulating item)
          • Set temp_itemdrop = (Last dropped item)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Hero manipulating item) has (Item carried by (Hero manipulating item) in slot 1)) Equal to False
            • Then - Actions
              • Unit - Order (Hero manipulating item) to move (Item being manipulated) to inventory slot 1
              • -------- sets item used to slot 1 --------
            • Else - Actions
          • Hero - Give temp_itemdrop to (Hero manipulating item)
          • Item - Make temp_itemdrop Droppable
          • Item - Set charges remaining in (Item being manipulated) to ((Charges remaining in (Item being manipulated)) + 1)
          • Custom script: call UnitAddAbility (u, 'S004')
          • Custom script: loop
          • Custom script: exitwhen GetUnitTypeId(u) == 'H003'
          • Custom script: call TriggerSleepAction (0.27)
          • Custom script: endloop
          • Custom script: set udg_flashlight_fx[(GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit())) - 1)] = AddSpecialEffectTarget ("war3mapImported\\LIght_Flashlight_22.MDX", GetTriggerUnit(), "overhead")
        • Else - Actions
          • Hero - Drop the item from slot 1 of (Hero manipulating item)
          • Set temp_itemdrop = (Last dropped item)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Hero manipulating item) has (Item carried by (Hero manipulating item) in slot 1)) Equal to False
            • Then - Actions
              • Unit - Order (Hero manipulating item) to move (Item being manipulated) to inventory slot 1
              • -------- ^^^ Automatically set item to nearest availible slot --------
            • Else - Actions
          • Hero - Give temp_itemdrop to (Hero manipulating item)
          • Item - Make temp_itemdrop Undroppable
          • Item - Set charges remaining in (Item being manipulated) to ((Charges remaining in (Item being manipulated)) + 1)
          • Custom script: call UnitAddAbility (u, 'S004')
          • Custom script: loop
          • Custom script: exitwhen GetUnitTypeId(u) == 'H003'
          • Custom script: call TriggerSleepAction (0.27)
          • Custom script: endloop
          • Custom script: call DestroyEffect(udg_flashlight_fx[(GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit())) - 1)])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Hero manipulating item)) Equal to TUCU Marine Melee
          • flashlight[(Player number of (Owner of (Casting unit)))] Equal to False
        • Then - Actions
          • Hero - Drop the item from slot 1 of (Hero manipulating item)
          • Set temp_itemdrop = (Last dropped item)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Hero manipulating item) has (Item carried by (Hero manipulating item) in slot 1)) Equal to False
            • Then - Actions
              • Unit - Order (Hero manipulating item) to move (Item being manipulated) to inventory slot 1
              • -------- sets item used to slot 1 --------
            • Else - Actions
          • Hero - Give temp_itemdrop to (Hero manipulating item)
          • Item - Make temp_itemdrop Droppable
          • Item - Set charges remaining in (Item being manipulated) to ((Charges remaining in (Item being manipulated)) + 1)
          • Custom script: call UnitAddAbility (u, 'S005')
          • Custom script: loop
          • Custom script: exitwhen GetUnitTypeId(u) == 'H007'
          • Custom script: call TriggerSleepAction (0.27)
          • Custom script: endloop
          • Custom script: set udg_flashlight_fx[(GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit())) - 1)] = AddSpecialEffectTarget ("war3mapImported\\LIght_Flashlight_22.MDX", GetTriggerUnit(), "overhead")
        • Else - Actions
          • Hero - Drop the item from slot 1 of (Hero manipulating item)
          • Set temp_itemdrop = (Last dropped item)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Hero manipulating item) has (Item carried by (Hero manipulating item) in slot 1)) Equal to False
            • Then - Actions
              • Unit - Order (Hero manipulating item) to move (Item being manipulated) to inventory slot 1
              • -------- ^^^ Automatically set item to nearest availible slot --------
            • Else - Actions
          • Hero - Give temp_itemdrop to (Hero manipulating item)
          • Item - Make temp_itemdrop Undroppable
          • Item - Set charges remaining in (Item being manipulated) to ((Charges remaining in (Item being manipulated)) + 1)
          • Custom script: call UnitAddAbility (u, 'S005')
          • Custom script: loop
          • Custom script: exitwhen GetUnitTypeId(u) == 'H007'
          • Custom script: call TriggerSleepAction (0.27)
          • Custom script: endloop
          • Custom script: call DestroyEffect(udg_flashlight_fx[(GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit())) - 1)])
      • Custom script: set u = null
 
Last edited:
Level 7
Joined
Jun 8, 2010
Messages
283
Bump and I have updated the triggers. I removed the loop conditions as it was too slow for it double created and destroyed the light models which was necessary. I also separated the 2 combined conditionals into 4 separate conditional triggers.

  • chaos aa12 BETA 5
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Unit-type of (Hero manipulating item)) Not equal to Zombie (Hooked Flesh)
      • (Item-type of (Item being manipulated)) Equal to AA12 Tactical Shotgun
    • Actions
      • Custom script: local unit u = GetTriggerUnit()
      • -------- Melee: Action = Flashlight On, Else Action = Flashlight Off --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Hero manipulating item)) Equal to TUCU Marine (AA-12)
          • flashlight[(Player number of (Owner of (Hero manipulating item)))] Equal to False
        • Then - Actions
          • Hero - Drop the item from slot 1 of (Hero manipulating item)
          • Set temp_itemdrop = (Last dropped item)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Hero manipulating item) has (Item carried by (Hero manipulating item) in slot 1)) Equal to False
            • Then - Actions
              • Unit - Order (Hero manipulating item) to move (Item being manipulated) to inventory slot 1
              • -------- sets item used to slot 1 --------
            • Else - Actions
          • Hero - Give temp_itemdrop to (Hero manipulating item)
          • Item - Make temp_itemdrop Droppable
          • Item - Set charges remaining in (Item being manipulated) to ((Charges remaining in (Item being manipulated)) + 1)
          • Custom script: call DestroyEffect(udg_flashlight_fx[(GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit())) - 1)])
          • Custom script: call UnitAddAbility (u, 'S004')
          • Custom script: set udg_flashlight_fx[(GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit())) - 1)] = AddSpecialEffectTarget ("war3mapImported\\LIght_Flashlight_22.MDX", GetTriggerUnit(), "overhead")
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Hero manipulating item)) Equal to TUCU Marine (AA-12)
          • flashlight[(Player number of (Owner of (Hero manipulating item)))] Equal to True
        • Then - Actions
          • Hero - Drop the item from slot 1 of (Hero manipulating item)
        • Else - Actions
          • Set temp_itemdrop = (Last dropped item)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Hero manipulating item) has (Item carried by (Hero manipulating item) in slot 1)) Equal to False
            • Then - Actions
              • Unit - Order (Hero manipulating item) to move (Item being manipulated) to inventory slot 1
              • -------- ^^^ Automatically set item to nearest availible slot --------
            • Else - Actions
          • Hero - Give temp_itemdrop to (Hero manipulating item)
          • Item - Make temp_itemdrop Undroppable
          • Item - Set charges remaining in (Item being manipulated) to ((Charges remaining in (Item being manipulated)) + 1)
          • Custom script: call UnitAddAbility (u, 'S004')
          • Custom script: call DestroyEffect(udg_flashlight_fx[(GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit())) - 1)])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Hero manipulating item)) Equal to TUCU Marine Melee
          • flashlight[(Player number of (Owner of (Hero manipulating item)))] Equal to False
        • Then - Actions
          • Hero - Drop the item from slot 1 of (Hero manipulating item)
          • Set temp_itemdrop = (Last dropped item)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Hero manipulating item) has (Item carried by (Hero manipulating item) in slot 1)) Equal to False
            • Then - Actions
              • Unit - Order (Hero manipulating item) to move (Item being manipulated) to inventory slot 1
              • -------- sets item used to slot 1 --------
            • Else - Actions
          • Hero - Give temp_itemdrop to (Hero manipulating item)
          • Item - Make temp_itemdrop Droppable
          • Item - Set charges remaining in (Item being manipulated) to ((Charges remaining in (Item being manipulated)) + 1)
          • Custom script: call UnitAddAbility (u, 'S005')
          • Custom script: set udg_flashlight_fx[(GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit())) - 1)] = AddSpecialEffectTarget ("war3mapImported\\LIght_Flashlight_22.MDX", GetTriggerUnit(), "overhead")
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Hero manipulating item)) Equal to TUCU Marine Melee
          • flashlight[(Player number of (Owner of (Hero manipulating item)))] Equal to True
        • Then - Actions
          • Hero - Drop the item from slot 1 of (Hero manipulating item)
        • Else - Actions
          • Set temp_itemdrop = (Last dropped item)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Hero manipulating item) has (Item carried by (Hero manipulating item) in slot 1)) Equal to False
            • Then - Actions
              • Unit - Order (Hero manipulating item) to move (Item being manipulated) to inventory slot 1
              • -------- ^^^ Automatically set item to nearest availible slot --------
            • Else - Actions
          • Hero - Give temp_itemdrop to (Hero manipulating item)
          • Item - Make temp_itemdrop Undroppable
          • Item - Set charges remaining in (Item being manipulated) to ((Charges remaining in (Item being manipulated)) + 1)
          • Custom script: call UnitAddAbility (u, 'S005')
          • Custom script: call DestroyEffect(udg_flashlight_fx[(GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit())) - 1)])
      • Custom script: set u = null
 
Last edited:
Status
Not open for further replies.
Top