| 06-22-2006, 06:55 PM | #1 |
In my map, their is a turret that casts an impale based spell on any nearby enemies. I want to make it so that when the turret channels the ability (here on referred to as "minigun cast") it will create a lightning effect from the turret to the point of ability being cast to signify when the turret is going to fire and where it will fire to warn players to get out of the way. I made a trigger that goes like this. Event - A unit begins channeling an ability. Condition - Ability being cast equal to minigun cast. Action - Create lightning effect from position of casting unit to point of ability being cast. Then another trigger to get rid of the lightning effect. Event - A unit begins channeling an ability. Condition - Ability being cast equal to minigun cast. Action - wait 1 game seconds - destroy last created lightning effect. This works but sometimes more then one turret is firing, so then one of the lightning effects is left their permanently! How can I get rid of all of them? |
| 06-22-2006, 07:12 PM | #2 |
well... easiest way probably is to set unique custom value for every minigun, and make array of lightning effects... and then you refer to lightnings as lightnings[Custom value of Casting unit] or something like this... or if you are clever and use jass, you can try attaching lightning to unit. And if the unit stops casting the ability, "call DestroyLightning(GetHandleHandle("lightning", GetSpellAbilityUnit()))" EDIT: --------------------- why you can't just: Events unit begins channeling of ability Conditions ability = minigun cast Actions Custom script "local lightning l = createlightning(blablabla)" Wait 1 seconds Custom script "call removelightning(l)" Custom script "set l = null I don't remember exact functions but it should work ... |
| 06-22-2006, 08:20 PM | #3 |
Put this is your main map script: JASS:function GC takes nothing returns gamecache if(udg_GC == null) then call FlushGameCache(InitGameCache("GC")) set udg_GC = InitGameCache("GC") endif return udg_GC endfunction function H2I takes handle H returns integer return H return 0 endfunction function I2Lightning takes integer I returns lightning return I return null endfunction function AddTempLightning_Remove takes nothing returns nothing local timer t = GetExpiredTimer() local lightning l = I2Lightning(GetStoredInteger(GC(), I2S(H2I(t)), "TempLightning")) call DestroyTimer(t) call DestroyLightning(l) set t = null set l = null endfunction function AddTempLightning takes string codename, location L1, location L2, real duration returns lightning local timer t = CreateTimer() local lightning l = AddLightningEx(codename, true, GetLocationX(L1), GetLocationY(L1), 5., GetLocationX(L2), GetLocationY(L2), 5.) call StoreInteger(GC(), I2S(H2I(t)), "TempLightning", H2I(l)) call TimerStart(t, duration, false, function AddTempLightning_Remove) return l endfunction I just wrote it .Anyway, you need a global gamecache called 'GC', or in Jass it will be called udg_GC. Add that to your map script, and to use it, just use Trigger: Actions
![]() Custom script: local location UnitLoc = GetUnitLoc(GetSpellAbilityUnit())
![]() Custom script: call AddTempLightning('your codeName', UnitLoc, GetSpellTargetLoc(), 1.)
![]() Custom script: call RemoveLocation(UnitLoc)
![]() Custom script: set UnitLoc = nullChange 'your codeName' to the lightning codename you want, to get the codename just click Convert to custom text at the top and look what it is, i tried Chain Lightning - Primary, and it came out as "CLPB". So change 'your codename to "CLPB" if you want it Chain Lightning - Primary. If you need further help with this just post |
| 06-22-2006, 08:35 PM | #4 |
I don't know the slightest thing about jass. How do I put this in map? |
| 06-22-2006, 08:58 PM | #5 |
Go to the trigger editor. On the left hand side, there is catagories and triggers. The top label is the name of your map. Click the label, then where the trigger normaly is, its just a blank white box where you can type things in. It should look like This. Where the Type things here is, copy: JASS:function GC takes nothing returns gamecache if(udg_GC == null) then call FlushGameCache(InitGameCache("GC")) set udg_GC = InitGameCache("GC") endif return udg_GC endfunction function H2I takes handle H returns integer return H return 0 endfunction function I2Lightning takes integer I returns lightning return I return null endfunction function AddTempLightning_Remove takes nothing returns nothing local timer t = GetExpiredTimer() local lightning l = I2Lightning(GetStoredInteger(GC(), I2S(H2I(t)), "TempLightning")) call FlushStoredMission(GC(), I2S(H2I(t)) call DestroyTimer(t) call DestroyLightning(l) set t = null set l = null endfunction function AddTempLightning takes string codename, location L1, location L2, real duration returns lightning local timer t = CreateTimer() local lightning l = AddLightningEx(codename, true, GetLocationX(L1), GetLocationY(L1), GetLocationZ(L1) + 5., GetLocationX(L2), GetLocationY(L2), GetLocationZ(L2) + 5.) call StoreInteger(GC(), I2S(H2I(t)), "TempLightning", H2I(l)) call TimerStart(t, duration, false, function AddTempLightning_Remove) return l endfunction Into it. Then, in your trigger, instead of having that 'Create lightning at loc', wait 1 sec etc. Just type: JASS:call AddTempLightning('Codename', Point1, Point2, duration) Please can you say which lightning you want? then i can just give you a working example. Because every lightning has its own CodeName. |
| 06-22-2006, 09:10 PM | #6 |
I can't actually work on my map and look at what lightning I need. I can't do that until summer which is like in 1-2 weeks for me when i get access to internet and wc3 at the same time. I'll tell you then. |
| 06-22-2006, 11:00 PM | #7 |
Yes Jacek just adding a local var to the trigger would work, but using timers is way better and not difficult, just different. - Takes handles hostage: use integers and ItoTimer,HtoI - Won't work well with flying units: use GetLocationZ() and possibly GetTerrainCliffLevel() - Leaks GetSpellTargetLoc(): stash it in variable, destroy - Lightning codes are strings and go in double quotes "" |
| 06-23-2006, 03:44 PM | #8 |
Ah yes, i dident put in GetLocationZ(), il edit it. |
