| 05-13-2007, 04:59 AM | #1 |
I've been working for an hour or so trying to get this function to make one end of a lightning effect (LEAS is the rawcode of areal shackles) rotate around the other end work properly, trying about everything I can think of (which isn't a whole lot because I am so very tired now), but alas, to no avail. Here is the trigger as I see it should work: JASS:function Trig_Clothesline_Actions takes nothing returns nothing local integer intx = 0 local real locx = GetLocationX(GetUnitLoc(gg_unit_negf_0002)) local real locy = GetLocationY(GetUnitLoc(gg_unit_negf_0002)) local location varloc call AddLightning( "LEAS", true, locx, locy, locx+200, locy+200) loop set intx = intx+1 if (intx >359) then set intx = 0 endif set varloc = (PolarProjectionBJ( GetUnitLoc(gg_unit_negf_0002), 200, intx)) call MoveLightning(GetLastCreatedLightningBJ(), true, locx, locy, GetLocationX(varloc), GetLocationY(varloc)) call TriggerSleepAction(.01) endloop set varloc = null endfunction //=========================================================================== function InitTrig_Clothesline takes nothing returns nothing set gg_trg_Clothesline = CreateTrigger( ) call TriggerAddAction( gg_trg_Clothesline, function Trig_Clothesline_Actions ) endfunction Please, any help, weather it be optimizing the code, or making the bolt rotate around one point would be greatly apreciated. |
| 05-13-2007, 05:17 AM | #2 |
JASS:function Trig_Clothesline_Actions takes nothing returns nothing local integer intx = 0 local real locx = GetUnitX(gg_unit_negf_0002) //here you can just use GetUnitX instead local real locy = GetUnitY(gg_unit_negf_0002) //here too local location varloc local lightning lig = AddLightning( "LEAS", true, locx, locy, locx+200, locy+200) loop set intx = intx+1 if (intx >359) then set intx = 0 endif set varloc = (PolarProjectionBJ( GetUnitLoc(gg_unit_negf_0002), 200, intx)) call MoveLightning(lig, true, locx, locy, GetLocationX(varloc), GetLocationY(varloc)) call TriggerSleepAction(.01) endloop call DestroyLightning(lig) set lig=null call RemoveLocation(varloc) set varloc = null endfunction //=========================================================================== function InitTrig_Clothesline takes nothing returns nothing set gg_trg_Clothesline = CreateTrigger( ) call TriggerAddAction( gg_trg_Clothesline, function Trig_Clothesline_Actions ) endfunction try use this one, i think the problem come from GetLastCreatedLighitnig() |
| 05-13-2007, 07:44 AM | #3 |
demonstration on lightning rotation for my very old crappy vector system... Btw check it out, wait a bit untill the end when u can dinamically rotate them |
| 05-13-2007, 05:28 PM | #4 | |
Quote:
Is there a way to create lightning and assign it to a variable at the same time (I.E. one line of code)? |
| 05-13-2007, 05:56 PM | #5 |
Edit: I'm a de de dee. |
| 05-13-2007, 06:16 PM | #6 |
Edited to save Rising from a certain fate of laughter. |
| 05-13-2007, 06:26 PM | #7 |
Lmao, I didn't know those natives existed. Learn something new everyday... *Slaps self* Let me delete my last post... |
| 05-13-2007, 08:19 PM | #8 |
I had thought about quoting from common.j and blizzard.j, but I decided not to... Either way, it doesn't move them. I can make it create them according to the polar projections just fine, but I can't move them... P.S. Does GetLastCreatedLightningBJ() not work? I've tried setting lig to last created lightning, and it doesn't work... Does GLCLBJ() only work for the vertical lightnings, like MonsoonBolt(targ)? ... No... that can't be. Those are special effects... Gack.. Someone help! |
| 05-14-2007, 04:17 AM | #9 |
it depends on how u create lightning, if u use BJ functions to create then it works. else it wont. Cus if u use direct native, then the last created lightning variable is not set. so u cant move it |
| 05-14-2007, 09:43 PM | #10 |
Excellent! MaD, that was all I needed to get it to properly work. Thanks a bunch. Now... if only I can get it to move faster... (stupid call PolledWait(.04) and call TriggerSleepAction(.04) not working right...) Anyone know how to get short periods to be timed accurately? Other than the timing issue, any other optimizations that can be done? My code as of now:function Trig_Clothesline_Actions takes nothing returns nothing local integer intx = 0 local location fixedloc = GetUnitLoc(gg_unit_negf_0002) local location varloc local lightning lig = AddLightningLoc( "LEAS", fixedloc, fixedloc ) loop call DisplayTextToForce( GetPlayersAll(), I2S(intx) ) //debug function, shows the value of intx. Won't be in final script. exitwhen intx>360 set intx = intx+1 set varloc = (PolarProjectionBJ(GetUnitLoc(gg_unit_negf_0002), 200, I2R(intx))) call DisplayTextToForce(GetPlayersAll(), R2S(GetLocationX(varloc))) //debug function, shows the x coordinate of the unanchored end. Won't be in final script. call DisplayTextToForce(GetPlayersAll(), R2S(GetLocationY(varloc))) //debug function, shows the y coordinate of the unanchored end. Won't be in final script. call DestroyLightningBJ( lig ) call AddLightningLoc( "LEAS", fixedloc, varloc) call PolledWait(.04) endloop call DestroyLightning(lig) set lig = null call RemoveLocation(varloc) set varloc = null call RemoveLocation(fixedloc) set fixedloc = null endfunction //=========================================================================== function InitTrig_Clothesline takes nothing returns nothing set gg_trg_Clothesline = CreateTrigger( ) call TriggerAddAction( gg_trg_Clothesline, function Trig_Clothesline_Actions ) endfunction [Note]: I forgot about Timers, the Tricks and the Traps provided by Rising_Dusk. OK... I was messing around with it, changing a few things, whatever. Then I tried to revert to this and it doesn't work anymore... I must have changed something, but I have no clue what... I'll give you guys (and girls) an update when I figure out what hath gone wrong. OK, I dunno what I did, but I fixed it... Now I just need a working timer thingy.. I'm doing something odd... |
| 05-15-2007, 09:44 PM | #11 |
*Bump* (Which, by the way, I don't like doing) OK, well, I have things working quite nicely... for a short period of time. Then things start lagging, not sure why. Map Specific Code:globals constant real downtime = 0.0027 integer intx = 0 location varloc location TowerLoc lightning lig timer t endglobals function LigSpin takes nothing returns nothing call DisplayTextToForce( GetPlayersAll(), I2S(intx) ) //Debug code for checking intx's value. set varloc = (PolarProjectionBJ(GetUnitLoc(gg_unit_negf_0002), 200, I2R(intx))) call DisplayTextToForce(GetPlayersAll(), R2S(GetLocationX(varloc))) //Debug code for checking X position of my variable location (varloc). call DisplayTextToForce(GetPlayersAll(), R2S(GetLocationY(varloc))) //Debug code for checking Y position of my variable location (varloc). call DestroyLightningBJ( lig ) set lig = null //Is this necessary, or worth doing? Does it do anything? call AddLightningLoc( "LEAS", TowerLoc, varloc) set lig = GetLastCreatedLightningBJ() set intx = intx+1 if intx > 360 then set intx = 1 endif endfunction Trigger Code:function Trig_Clothesline_Actions takes nothing returns nothing set TowerLoc = GetUnitLoc(gg_unit_negf_0002) set lig = AddLightningLoc( "LEAS", TowerLoc, TowerLoc) set t = CreateTimer() call TimerStart( t , downtime, true , function LigSpin) endfunction //=========================================================================== function InitTrig_Clothesline takes nothing returns nothing set gg_trg_Clothesline = CreateTrigger( ) call TriggerAddAction( gg_trg_Clothesline, function Trig_Clothesline_Actions ) endfunction Again, any optimizations? |
| 05-15-2007, 09:50 PM | #12 |
This JASS:call AddLightningLoc( "LEAS", TowerLoc, varloc) set lig = GetLastCreatedLightningBJ() JASS:set lig = AddLightningLoc(... An you also IMO leak location here JASS:set varloc = (PolarProjectionBJ(GetUnitLoc(gg_unit_negf_0002), 200, I2R(intx))) |
