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

Lightning from the ground, to the ground.

Status
Not open for further replies.
Level 4
Joined
Aug 26, 2012
Messages
123
When I'm creating Lightning Effects with action - "Lightning - Create", why the connection point always on the ground?
(Example, when targeting to point {position-of-unit}, it would simply connect to that unit's base, not to it's chest, or head, or foot, or hand-left, or weapon, [enough!])

How it works?
 
Level 4
Joined
Aug 26, 2012
Messages
123
Thanks a lot, still confusing though...

(No GUI trigger? Oh, Blizzard, please create a new patch for this...)
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Apo, you forgot to include MoveLightningEx function, as most of the people want to keep their Lightning to have timers before they expire right after creation.
I mean, most of the Lightning created in-between Caster and Target unit, they would move around, right ?

The problem is that the Z depends on the unit type.
How so ?
Z is the height of current position (terrain) you're at.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Apo, you forgot to include MoveLightningEx function, as most of the people want to keep their Lightning to have timers before they expire right after creation.
I mean, most of the Lightning created in-between Caster and Target unit, they would move around, right ?


How so ?
Z is the height of current position (terrain) you're at.
The MoveLightningEx is in the rest of the thread (which I obviously didn't link xD).

Well, he wants the lightning to go to the head/chest of a unit.
If a unit is really big, then the Z will be higher. Thus it is unit type-dependent.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
GetLocationZ returns the height of the terrain
The ModifyValue is for you to modify it for yourselves, if you don't understand, take a look at this example I made for a spell of mine.

  • Actions
    • Custom script: local unit Caster = GetTriggerUnit()
    • Custom script: local location CasterLoc = GetUnitLoc(Caster)
    • Custom script: local unit Target = GetSpellTargetUnit()
    • Custom script: local location TargetLoc = GetUnitLoc(Target)
    • Custom script: local real x1 = GetUnitX(Caster)
    • Custom script: local real y1 = GetUnitY(Caster)
    • Custom script: local real x2 = GetUnitX(Target)
    • Custom script: local real y2 = GetUnitY(Target)
    • Custom script: local real z1
    • Custom script: local real z2
    • Custom script: if IsUnitType(Caster, UNIT_TYPE_FLYING) then
    • Custom script: set z1 = GetLocationZ(CasterLoc) + GetUnitFlyHeight(Caster)
    • Custom script: else
    • Custom script: set z1 = GetLocationZ(CasterLoc) + 50.00
    • Custom script: endif
    • Custom script: if IsUnitType(Target, UNIT_TYPE_FLYING) then
    • Custom script: set z2 = GetLocationZ(TargetLoc) + GetUnitFlyHeight(Target)
    • Custom script: else
    • Custom script: set z2 = GetLocationZ(TargetLoc) + 50.00
    • Custom script: endif
    • Custom script: set udg_LS_Lightning = AddLightningEx(udg_LS_LightningStringName, true, x1, y1, z1, x2, y2, z2)
    • Custom script: set udg_LS_Key = GetHandleId(Caster)
    • Custom script: call SaveLightningHandle(udg_LS_Hashtable, udg_LS_Key, 0, udg_LS_Lightning)
    • Custom script: call SaveUnitHandle(udg_LS_Hashtable, udg_LS_Key, 1, Target)
    • Custom script: call GroupAddUnit(udg_LS_Group, Caster)
    • Custom script: set Caster = null
    • Custom script: call RemoveLocation(CasterLoc)
    • Custom script: set Target = null
    • Custom script: call RemoveLocation(TargetLoc)
    • Trigger - Turn on LS Loop <gen>
This trigger will create a Lightning from Caster to Target.
It has IF/THEN/ELSE function check.

If the unit is Ground Unit, the Lightning is created GetLocationZ + ModifyValue in this case, the ModifyValue is constant 50.00.
If the unit is Flying Unit, the Lightning will be created base on its FlyHeight + GetLocationZ (GetUnitFlyHeight returns the center of body of the FlyingUnit so you don't have to further modify the value).

The 50.00 represents the height value from the unit's base (only applies to Ground Unit).

GetLocationZ does not has to do anything with the unit's height adjustment, it's the ModifyValue.
 
Level 4
Joined
Aug 26, 2012
Messages
123
Umm... defskull, on StaRMaestroS's link, there's said that the "AddLightningEx" is a JASS. So, if my WE is still original, I should install it first, right?

(It won't be work on my --current-- WE, right?)
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Umm... defskull, on StaRMaestroS's link, there's said that the "AddLightningEx" is a JASS. So, if my WE is still original, I should install it first, right?

(It won't be work on my --current-- WE, right?)
JASS and vJASS is two different things.
JASS is what you write in the Custom script via GUI.
Obviously, vJASS > JASS, but vJASS requires you to first install it on your WE while JASS does not requires you to install any add-ons.

So, in your Trigger Editor, go to Custom script action, and type some native functions or whatever, THAT is JASS.

So basically, your current WE works fine with Custom script, you do not need to install anything else.
 
Level 4
Joined
Aug 26, 2012
Messages
123
Thank you very much, defskull! The Action "custom script" is one of the "list of actions that I NEVER used"... And I'll remove it from that list...
(Don't forget to recycle, Go Green!)

And, if i'm using JASS first, will the action "Lightning - Move Lightning" work for the lightning I made?
(Make it with JASS, move it with GUI, he means...)
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
And, if i'm using JASS first, will the action "Lightning - Move Lightning" work for the lightning I made?
(Make it with JASS, move it with GUI, he means...)
No, because the GUI MoveLightningLoc function does not provide any Z value.
You have to use AddLightningEx + MoveLightningEx if you want the Lightning to not stay on ground to ground.
 
Status
Not open for further replies.
Top