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

Very Simple Torch System

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
This is a very simple torch system. I'm worried it might even be too simple :S but anyway it creates a circle of light infront of the caster that moves with the caster. You can turn the torch on and off at will. Any suggestions to pimp it up will be accepted :D.

Credits:
Belgarath - Light Model

Triggers
  • On and Off
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Turn Torch On
    • Actions
      • -------- Checks If the Torch is On or off --------
      • Set T_isOn = (Load (Key boolean) of (Key (Triggering unit)) from T_Hashtable)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • T_isOn Equal to False
        • Then - Actions
          • -------- Sets Angle and Location --------
          • Set T_Angle = (Facing of (Triggering unit))
          • Set T_Loc = (Position of (Triggering unit))
          • Set T_Loc2 = (T_Loc offset by 500.00 towards T_Angle degrees)
          • -------- Creates Light --------
          • Unit - Create 1 Torch Light for (Owner of (Triggering unit)) at T_Loc2 facing T_Angle degrees
          • -------- Sets Variable --------
          • Set T_Light = (Last created unit)
          • -------- Turns Off Collision --------
          • Unit - Turn collision for T_Light Off
          • -------- Adds Caster to Unit-Group --------
          • Unit Group - Add (Triggering unit) to T_Holders
          • -------- Saves Light --------
          • Hashtable - Save Handle OfT_Light as (Key light) of (Key (Triggering unit)) in T_Hashtable
          • -------- Sets that the Torch is On --------
          • Set T_isOn = True
          • -------- Saves Variable --------
          • Hashtable - Save T_isOn as (Key boolean) of (Key (Triggering unit)) in T_Hashtable
          • -------- Removes Leaks --------
          • Custom script: call RemoveLocation (udg_T_Loc)
          • Custom script: call RemoveLocation (udg_T_Loc2)
        • Else - Actions
          • -------- Removes Light From the Game --------
          • Unit - Remove T_Light from the game
          • -------- Removes Caster from group --------
          • Unit Group - Remove (Triggering unit) from T_Holders
          • -------- Clears hashtable --------
          • Hashtable - Clear all child hashtables of child (Key (Triggering unit)) in T_Hashtable
          • -------- Sets that the torch is off --------
          • Set T_isOn = False
          • Hashtable - Save T_isOn as (Key boolean) of (Key (Triggering unit)) in T_Hashtable

  • Move
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
      • (Number of units in T_Holders) Greater than 0
    • Actions
      • Unit Group - Pick every unit in T_Holders and do (Actions)
        • Loop - Actions
          • -------- Sets Angle And Location --------
          • Set T_Angle = (Facing of (Picked unit))
          • Set T_Loc = (Position of (Picked unit))
          • Set T_Loc2 = (T_Loc offset by 500.00 towards T_Angle degrees)
          • -------- Loads unit --------
          • Set T_Light = (Load (Key light) of (Key (Picked unit)) in T_Hashtable)
          • -------- Moves Light --------
          • Unit - Move T_Light instantly to T_Loc2
          • -------- Removes Leaks --------
          • Custom script: call RemoveLocation (udg_T_Loc)
          • Custom script: call RemoveLocation (udg_T_Loc2)
Keywords:
torch, flashlight, light, vision, system, simple
Contents

Torch (Map)

Reviews
20:15, 9th Nov 2009 The_Reborn_Devil: This isn't MUI nor MPI and please use intervals of 0.03 or 0.04 instead. Status: Rejected Until Updated Rating: N/A Once you've fixed this please PM me or another mod to get the spell reviewed again.

Moderator

M

Moderator

20:15, 9th Nov 2009
The_Reborn_Devil:

This isn't MUI nor MPI and please use intervals of 0.03 or 0.04 instead.

Status: Rejected Until Updated
Rating: N/A

Once you've fixed this please PM me or another mod to get the spell reviewed again.
 
Level 10
Joined
Sep 21, 2007
Messages
517
ok man, its a good system, but since this is used every 0.02 seconds you need to make sure it will not negatively effect a map thay may already have other timed events as much as possible, so here is the deal:

make timer iteration 0.03/0.04 unless if the eye candy is bad,
and most importantly use XY coordinates instead of locations that not only need to be removed, but are slower

Paperjacks solution is best for that problem.

i would say its an extremely useful system mate ^^ ima rate it 5/5 because of its usefulness after you make it as efficient as possible )
 
Last edited:
Level 4
Joined
Apr 23, 2009
Messages
65
I like the idea but yeah its really simple. I find no leaks but I'm not the best with normal triggers. Maybe add a oil system: If you have no oil anymore the torch can't burn. And maybe a weather system wich modifies the sight range.
Hmm an oil system. Thats a really good idea. I might also add an intensity level. The higher the intensity, the more oil it uses up.
Make the dummy fly
Thanks for the idea.
ok man, its a good system, but since this is used every 0.02 seconds you need to make sure it will not negatively effect a map thay may already have other timed events as much as possible, so here is the deal:

make timer iteration 0.03/0.04 unless if the eye candy is bad,
and most importantly use XY coordinates instead of locations that not only need to be removed, but are slower

meaning use the customScript:
JASS:
call SetUnitX(Torch, x)
and this
JASS:
call SetUnitY(Torch, y)
I didnt use SetUnitPosition() because that takes in some unit pathability collision of a place and may bug. Sometimes it bugged for me when i started a projectile system so... else you could use the function SetUnitPosition().

Paperjacks solution is best for that problem.

i would say its an extremely useful system mate ^^ ima rate it 5/5 because of its usefulness after you make it as efficient as possible )
Thanks. I might need a bit of help with the x and y coordinates though.

EDIT: Is there an event for when a unit uses an ability in a spellbook? I tried unit starts the affect of an ability but it doesnt work. I want to put all the torch options into a spellbook so it looks nicer and more organised.
 
Last edited:
Level 10
Joined
Sep 21, 2007
Messages
517
o hey sorry about the coordinates man, you dont need to use SetUnitX() or SetUnitY() in this case, its for another. Its better if u use SetUnitPosition(). try to learn some basic jass, itll get easy after a bit; google JASS functions or something :p i really suggest looking at tutorials and just finding the Functions label and to know about them cus thats all you need to know: the basics of calling functions.

its like this:

call FunctionName(Parameter1, Parameter2, Parameter3)

the parameter contains the value that you need to fill in for the function; of course there can be one parameter or more, maximum of 7 i think; anywways thats how itll work, in the SetUnitPosition() example, do this:

JASS:
call SetUnitPosition(unit, x, y)

The x parameter is a real value, which is supposed to be the X coordinate of the position your unit would be in, and the same applies for the y parameter. The unit parameter is the unit that is going to be moved, so the torch would be in that parameter.
Good luck with the XY intercepts mate. You can use the functions
JASS:
GetUnitX(unit)
and
JASS:
GetUnitY(unit)
to get the X and Y coordinates of the unit that is supposed to have his torch. So you can do this
JASS:
call SetUnitPosition(torch, GetUnitX(unit), GetUnitY(unit))
the torch would be the torch, the unit would be the unit that needs the torch for his/her vision.

btw the only event for the abilities of a spellbook is the normal ability, for spellbook you need to give a unit the spellbook ability, which you can then add the torch ability within object editor; no need to do it through triggers.
 
Top