Special effect problem

Kazuga

Let the game begin...
Reaction score
110
Hm this might be a problem... I need to change the real value each time the timer ends so that the dummy is moved towards the targeted unit. However the locals allways needs to be at the top and the value is changed below... Well you see what I mean in the code (Slide function)
JASS:
scope Lightnings
globals
unit dummy
unit caster
unit target
location targetloc
endglobals
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'AHtb'
endfunction

private function Slide takes nothing returns nothing
local location temp1 = GetUnitLoc(dummy)
local location temp2 = PolarProjectionBJ(temp1,50,0)
local location temp3 = GetUnitLoc(target)
local real angle

set targetloc = GetUnitLoc(target)
set angle = AngleBetweenPoints(temp1,temp3)
set location temp2 = PolarProjectionBJ(temp1,50,angle)        //This doesn't work...
call SetUnitPositionLoc(dummy,temp2)
call BJDebugMsg ("This part also works wohoo")
endfunction
private function Actions takes nothing returns nothing
local real real1 = GetUnitFacing(GetTriggerUnit())
local location point1 = GetUnitLoc(GetTriggerUnit())
local location point2 = PolarProjectionBJ(point1,300,real1+145)
local location point3 = PolarProjectionBJ(point1,300,real1+180)
local location point4 = PolarProjectionBJ(point1,300,real1+215)
local unit Unit = GetTriggerUnit()
local timer SlideTimer = CreateTimer()
local real realD1
local real realD2

set target = (GetSpellTargetUnit())
call BJDebugMsg ("This part works")
call TriggerSleepAction (0.1)
call AddSpecialEffectLocBJ(point2,"Abilities\\Weapons\\Bolt\\BoltImpact.mdl")
call AddSpecialEffectLocBJ(point3,"Abilities\\Weapons\\Bolt\\BoltImpact.mdl")
call AddSpecialEffectLocBJ(point4,"Abilities\\Weapons\\Bolt\\BoltImpact.mdl")
call PauseUnit (GetTriggerUnit(), true)
call AddLightningLoc ("CLPB", point2,point1)
call AddLightningLoc ("CLPB", point3,point1)
call AddLightningLoc ("CLPB", point4,point1)
call TriggerSleepAction (1.00)
set dummy = CreateUnitAtLoc (GetOwningPlayer(GetTriggerUnit()),'h000',(point1),0)
call PauseUnit (GetTriggerUnit(), false)
call TimerStart (SlideTimer,0.1,true, function Slide)
endfunction


//===========================================================================
public function InitTrig takes nothing returns nothing
 local trigger trig = CreateTrigger()
 call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )
 call TriggerAddCondition (trig, Condition (function Conditions ) )
 call TriggerAddAction (trig, function Actions )
endfunction

endscope
 

Flare

Stops copies me!
Reaction score
662
JASS:
set location temp2 = PolarProjectionBJ(temp1,50,angle)


Remove the 'location' bit from it.

JASS:
local location temp2 = PolarProjectionBJ(temp1,50,0)

//Must be changed to

local location temp2
//Then give temp2 a value later in the trigger.
//Locals don't have to be given a value when declared, but they need to be given some value before they can be used

//OR
local location temp1 = GetUnitLoc (caster)
local location temp2 = GetUnitLoc (target)
local real angle = AngleBetweenPoints (temp1, temp2)
local location temp3 = PolarProjectionBJ (temp1, 50, angle)


Also, why do you set a global and local location variable to target's location?
 

Kazuga

Let the game begin...
Reaction score
110
Thanks, got it to work:thup:

Hm dunno really, will move it down to locals^^

However I'm stuck at an If-then-else, I tested to convert a normal if-then-else to see what it looked like from gui but it looked so wierd that I didn't really know what was what...
JASS:
private function Slide takes nothing returns nothing
local location temp1 = GetUnitLoc(dummy)
local location temp2 = GetUnitLoc(target)
local real angle = AngleBetweenPoints(temp1,temp2)
local location temp3 PolarProjectionBJ(temp1,50,angle
local real distance = DistanceBetweenPoints(temp1,temp2)

set targetloc = GetUnitLoc(target)
call SetUnitPositionLoc(dummy,temp2)
if ( not (udg_distance>= 100.00) then
call BJDebugMsg ("think it's working")
endif
endfunction

Edit: Hm earlier part doesn't work fully properly, ingame I get error message that says that I have to initstilize temp3, wich it is here?...
JASS:
local location temp3 PolarProjectionBJ(temp1,50,angle
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
your global block needs to be ABOVE everything else. JASS reads functions from bottom to top, so as far as it is concerned, you dont have a global variable called dummy to assign.

No, afaik globals within global blocks are directly moved to the global block at the top of the script. No matter where you put it, it will come first. Globals come first, then libraries etc.

Yeah, I know you are new to JASS and it is hard to learn it, but a lot is common sense. Do a bit of light reading on some JASS tutorials. ;)

And I'll help you optimize your code...

First off, let us look at the initTrig:
JASS:
public function InitTrig takes nothing returns nothing
 local trigger trig = CreateTrigger()
 call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )
 call TriggerAddCondition (trig, Condition (function Conditions ) )
 call TriggerAddAction (trig, function Actions )
endfunction


What is wrong with this? Well, it leaks and it uses InitTrig rather than scope's handy initializers. You can easily just create scope initializers rather than init trigger functions. So, let us do that, change your initTrig func to this:
JASS:
private function Lightning takes nothing returns nothing
    local trigger trig = CreateTrigger()
     call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SPELL_EFFECT)
 call TriggerAddCondition(trig,Condition(function Conditions))
 call TriggerAddAction(trig,function Actions)
endfunction


Sorry if everything seems to cluttered, I just don't see how people love that spacing convention. (As in call myFunc ( param , param ) or something along those lines, it doesn't make a difference, I just think it looks a little more weird :p)

Then change your scope declaration to this:
JASS:
scope Lightnings initializer Lightning


What this does, is basically like InitTrig. In the scope, the "initializer" declares basically the initialization function, so it can be used to declare the initialization trigger functions.

Ok, well we have that small portion, now we will move on to the leak. TriggerRegisterAnyUnitEventBJ() leaks as each time it is called, it will null a boolexpr value for TriggerRegisterPlayerUnitEvent(...), thus causing a leak. It is best to just move the functions out and use a safe filter.

JASS:
private function SafeFilt takes nothing returns boolean
    return true
endfunction

private function Lightning takes nothing returns nothing
    local trigger trig = CreateTrigger()
    local integer i = 0
    loop
        exitwhen i > 15
        call TriggerRegisterPlayerUnitEvent(trig,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,Condition(function SafeFilt))
        set i = i + 1
    endloop
    call TriggerAddCondition(trig,Condition(function Conditions))
    call TriggerAddAction(trig,function Actions)
    set trig = null
endfunction


Well, why do I prefer this? Well, it prevents a leak. You see, Condition() functions do create a leak. They do, but it is a small and one time leak. On first creation, it will create the function. All other times though, it will simply reuse the condition rather than recreating it.

Now we will move on to the actions function. Oh dear lord, this needs a bit of work. :p

Let's first look at the decleration BJ hell. :D Ok, here it is:
JASS:
    local location point1 = GetUnitLoc(GetTriggerUnit())
    local location point2 = PolarProjectionBJ(point1,300,real1+145)
    local location point3 = PolarProjectionBJ(point1,300,real1+180)
    local location point4 = PolarProjectionBJ(point1,300,real1+215)


Well, a few pointers:
- In JASS, locations are more deprecated... Coordinates are better and allow usage of more functions.
- Locations leak
- PolarProjectionBJ is a BJ function so it is slower than natives...

So let's fix that. Instead, we will use reals. For the first part:
JASS:


Now we will inline the polar projection. This might be a little odd but it is better. You see, the formula for offsetting, whichever way you want to put it, is:

X = X Coordinate Source + Distance * Cos(Angle * bj_DEGTORAD)
Y = Y Coordinate Source + Distance * Sin(Angle * bj_DEGTORAD)

So, what you would do is this:
JASS:
    local real real1 = GetUnitFacing(GetTriggerUnit())
    local real x = GetUnitX(GetTriggerUnit())
    local real y = GetUnitY(GetTriggerUnit())
    
    local real x2 = x + 300 * Cos((real1+145)*bj_DEGTORAD)
    local real y2 = y + 300 * Sin((real1+145)*bj_DEGTORAD)
    
    local real x3 = x + 300 * Cos((real1+180)*bj_DEGTORAD)
    local real y3 = y + 300 * Sin((real1+180)*bj_DEGTORAD)
    
    local real x4 = x + 300 * Cos((real1+215)*bj_DEGTORAD)
    local real y4 = y + 300 * Sin((real1+215)*bj_DEGTORAD)


Now we will reorganize them a bit:
JASS:
    local timer SlideTimer = CreateTimer()
    local unit Unit        = GetTriggerUnit()
    local real real1       = GetUnitFacing(Unit)
    
    local real x           = GetUnitX(Unit)
    local real y           = GetUnitY(Unit)
    
    local real x2          = x + 300 * Cos((real1+145)*bj_DEGTORAD)
    local real y2          = y + 300 * Sin((real1+145)*bj_DEGTORAD)
    
    local real x3          = x + 300 * Cos((real1+180)*bj_DEGTORAD)
    local real y3          = y + 300 * Sin((real1+180)*bj_DEGTORAD)
    
    local real x4          = x + 300 * Cos((real1+215)*bj_DEGTORAD)
    local real y4          = y + 300 * Sin((real1+215)*bj_DEGTORAD)
    
    local real realD1
    local real realD2


Lol, this spacing for initial and setting isn't necessary, it just increases readability for me. Some people, it will and others it won't.

This part right here is fine:
JASS:
    set target = GetSpellTargetUnit()
    call BJDebugMsg("This part works")
    call TriggerSleepAction(0.1)


When setting values, you don't have to have the value in parenthesis, it doesn't matter but usually parenthesis are used to hold arguments and for math. (If you want one portion performed before another)

Now that we have coordinates, we can use coordinates, hoooray! :D

The below functions are BJs, eww. Remember to avoid them as much as you can. Some BJ functions are helpful, but others are just seriously swapped functions or other fluff types.

JASS:
    call AddSpecialEffectLocBJ(point2,"Abilities\\Weapons\\Bolt\\BoltImpact.mdl")
    call AddSpecialEffectLocBJ(point3,"Abilities\\Weapons\\Bolt\\BoltImpact.mdl")
    call AddSpecialEffectLocBJ(point4,"Abilities\\Weapons\\Bolt\\BoltImpact.mdl")


Then you can convert that to this:

JASS:
    call AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x2,y2)
    call AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x3,y3)
    call AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x4,y4)


The reason why we use coordinates is because they are accurate, and they don't leak. They also allow the usage of certain functions and are easier to use in some ways.

Anywho, now we will fix the next portion to use reals instead:
JASS:
    call PauseUnit(Unit,true)
    call AddLightning("CLPB",true,x,y,x2,y2)
    call AddLightning("CLPB",true,x,y,x3,y3)
    call AddLightning("CLPB",true,x,y,x4,y4)


Using "Unit" shouldn't make too much of a difference except that it is a reference to the unit rather than calling the function again.

AddLightning takes the string of the rawcode. CLPB is Chain Lightning Primary I think, right? Not sure though. :D "True" checks the visibility (I assume you want to as that is how they do it in the AddLightningLoc() BJ)... Then the first coordinate pair is the coordinates for the first location, then the last coordinate pair is for the ending location. It doesn't matter the order in that situation.

Now the last portion:
JASS:
    call TriggerSleepAction (1.00)
    set dummy = CreateUnitAtLoc (GetOwningPlayer(GetTriggerUnit()),'h000',(point1),0)
    call PauseUnit (GetTriggerUnit(), false)
    call TimerStart (SlideTimer,0.1,true, function Slide)


Well, now we will use coordinates and fix the leaks. When you locally declare a non-permanent handle, you will have to null it. You can't null reals, but you can null stuff like timers and units.

Now here is the "actions" function:
JASS:
private function Actions takes nothing returns nothing
    local timer SlideTimer = CreateTimer()
    local unit Unit        = GetTriggerUnit()
    local real real1       = GetUnitFacing(Unit)
    
    local real x           = GetUnitX(Unit)
    local real y           = GetUnitY(Unit)
    
    local real x2          = x + 300 * Cos((real1+145)*bj_DEGTORAD)
    local real y2          = y + 300 * Sin((real1+145)*bj_DEGTORAD)
    
    local real x3          = x + 300 * Cos((real1+180)*bj_DEGTORAD)
    local real y3          = y + 300 * Sin((real1+180)*bj_DEGTORAD)
    
    local real x4          = x + 300 * Cos((real1+215)*bj_DEGTORAD)
    local real y4          = y + 300 * Sin((real1+215)*bj_DEGTORAD)
    
    local real realD1
    local real realD2

    set target = GetSpellTargetUnit()
    call BJDebugMsg("This part works")
    call TriggerSleepAction(0.1)
    
    call AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x2,y2)
    call AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x3,y3)
    call AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x4,y4)
    
    call PauseUnit(Unit,true)
    call AddLightning("CLPB",true,x,y,x2,y2)
    call AddLightning("CLPB",true,x,y,x3,y3)
    call AddLightning("CLPB",true,x,y,x4,y4)
    
    call TriggerSleepAction (1)
    set dummy = CreateUnit(GetOwningPlayer(Unit),'h000',x,y,0)
    call PauseUnit(Unit,false)
    call TimerStart(SlideTimer,0.1,true,function Slide)
    
    set t     = null
    set Unit  = null
endfunction


Ok, now we will move on to the slide function. Phew!

JASS:
private function Slide takes nothing returns nothing
    local location temp1 = GetUnitLoc(dummy)
    local location temp2 = PolarProjectionBJ(temp1,50,0)
    local location temp3 = GetUnitLoc(target)
    local real angle

    set targetloc = GetUnitLoc(target)
    set angle = AngleBetweenPoints(temp1,temp3)
    set location temp2 = PolarProjectionBJ(temp1,50,angle)        //This doesn't work...
    call SetUnitPositionLoc(dummy,temp2)
    call BJDebugMsg ("This part also works wohoo")
endfunction


Well, we will use reals instead again because they are better.
JASS:
private function Slide takes nothing returns nothing
    local real x = GetUnitX(dummy)
    local real y = GetUnitY(dummy)
    local real newX
    local real newY
    
    set targetloc = GetUnitLoc(target)
    set angle = Atan2(GetLocationY(targetloc)-y,GetLocationX(targetloc)-x)
    set newX = x + 50 * Cos(angle)
    set newY = y + 50 * Sin(angle)
    
    call SetUnitPosition(dummy,newX,newY)
    call BJDebugMsg ("This part also works wohoo")
endfunction


The next final product will use reals instead of the targetloc var. Atan2(...) uses the dummy Y coordinate subtracted by the targetloc Y coordinate as the first argument, then the Y coordinate of the dummy subtracted by X coordinate of targetloc to calculate the angle. In the BJ functions, it uses a RADTODEG conversion as Atan2() returns the result in radians rather than degrees.

The reason why I didn't use this conversion is because when using polar projection, it does the opposite conversion (DEGTORAD) so it is really pointless.

So now you have the whole big result:
JASS:
scope Lightnings initializer Lightning

globals
    integer raw = 'AHtb'
//Increases configurability
    unit dummy
    unit caster
    unit target
    real tx
    real ty
endglobals

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == raw
endfunction

private function Slide takes nothing returns nothing
    local real x = GetUnitX(dummy)
    local real y = GetUnitY(dummy)
    local real newX
    local real newY
    
    set tx = GetUnitX(target)
    set ty = GetUnitY(target)
    set angle = Atan2(ty-y,tx-x)
    set newX = x + 50 * Cos(angle)
    set newY = y + 50 * Sin(angle)
    
    call SetUnitPosition(dummy,newX,newY)
    call BJDebugMsg ("This part also works wohoo")
endfunction

private function Actions takes nothing returns nothing
    local timer SlideTimer = CreateTimer()
    local unit Unit        = GetTriggerUnit()
    local real real1       = GetUnitFacing(Unit)
    
    local real x           = GetUnitX(Unit)
    local real y           = GetUnitY(Unit)
    
    local real x2          = x + 300 * Cos((real1+145)*bj_DEGTORAD)
    local real y2          = y + 300 * Sin((real1+145)*bj_DEGTORAD)
    
    local real x3          = x + 300 * Cos((real1+180)*bj_DEGTORAD)
    local real y3          = y + 300 * Sin((real1+180)*bj_DEGTORAD)
    
    local real x4          = x + 300 * Cos((real1+215)*bj_DEGTORAD)
    local real y4          = y + 300 * Sin((real1+215)*bj_DEGTORAD)
    
    local real realD1
    local real realD2

    set target = GetSpellTargetUnit()
    call BJDebugMsg("This part works")
    call TriggerSleepAction(0.1)
    
    call AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x2,y2)
    call AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x3,y3)
    call AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x4,y4)
    
    call PauseUnit(Unit,true)
    call AddLightning("CLPB",true,x,y,x2,y2)
    call AddLightning("CLPB",true,x,y,x3,y3)
    call AddLightning("CLPB",true,x,y,x4,y4)
    
    call TriggerSleepAction(1)

    set dummy = CreateUnit(GetOwningPlayer(Unit),'h000',x,y,0)
    call PauseUnit(Unit,false)
    call TimerStart(SlideTimer,0.1,true,function Slide)
    
    set t     = null
    set Unit  = null
endfunction

private function SafeFilt takes nothing returns boolean
    return true
endfunction

private function Lightning takes nothing returns nothing
    local trigger trig = CreateTrigger()
    local integer i = 0
    loop
        exitwhen i > 15
        call TriggerRegisterPlayerUnitEvent(trig,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,Condition(function SafeFilt))
        set i = i + 1
    endloop
    call TriggerAddCondition(trig,Condition(function Conditions))
    call TriggerAddAction(trig,function Actions)
    set trig = null
endfunction

endscope


I think it is fully optimized, I would check for errors I made and syntax errors, but I can't at the moment. (Even after doing all this :p)

Anywho, cheers.

~Purge

(to avoid these kind of rants or lectures or whatever you'd like to call them, read a tutorial xD)
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
JASS:
    call TimerStart(SlideTimer,0.1,true,function Slide)


That is what you cann to start a timer (makes sense eh?).

SlideTimer indicates what timer he's starting, while 0.1 is the duration of the timer. The next one is a boolean flag, if set to true this becomes a periodic timer, if set to false it becomes a one-shot timer. Last but not least is the callback function, this is the function that executes all the actions that should be executed when the timer expires.
 

Kazuga

Let the game begin...
Reaction score
110
May I ask what this line does?
JASS:
    call TimerStart(SlideTimer,0.1,true,function Slide)
That starts the timer wich when ends will call upon the Slide function wich moves the dummy 50 range towards the target unit of ability being cast.

Thanks Purgeandfire, that helped a real lot^^
However I got 23 errors...
One of them is "Too many arguments passed to function"
JASS:
call SetUnitPositionLoc(dummy , newX , newY)


Current code:
JASS:
scope Lightnings initializer Lightning
globals
integer raw = 'AHtb'
unit dummy
unit caster
unit target
real tx
real ty
endglobals

private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == raw
endfunction

private function Slide takes nothing returns nothing
local real x = GetUnitX(dummy)
local real y = GetUnitY(dummy)
local real newX
local real newY

set tx = GetUnitX(target)
set ty = GetUnitY(target)
set angle = Atan2(ty-y,tx-x)
set newX = x + 50 *Cos(angle)
set newY = y + 50 *Sin(angle)


call SetUnitPositionLoc(dummy,newX,newY)
endfunction
private function Actions takes nothing returns nothing
local timer CreateTimer SlideTimer = CreateTimer()
local unit Unit                    = GetTriggerUnit()
local real real1                   = GetUnitFacing(Unit)

local real x = GetUnitX(GetTriggerUnit())
local real y = GetUnitY(GetTriggerUnit())

local real x2 = x + 300 * Cos((real1+145)*bj_DEGTORAD)
local real y2 = x + 300 * Sin((real1+145)*bj_DEGTORAD)

local real x3 = x + 300 * Cos((real1+180)*bj_DEGTORAD)
local real y3 = x + 300 * Sin((real1+180)*bj_DEGTORAD)

local real x4 = x + 300 * Cos((real1+215)*bj_DEGTORAD)
local real y4 = x + 300 * Sin((real1+215)*bj_DEGTORAD)


local real realD1
local real realD2

set target = (GetSpellTargetUnit())
call BJDebugMsg ("This part works")
call TriggerSleepAction (0.1)
call AddSpecialEffect(point2,"Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x2,y2)
call AddSpecialEffect(point3,"Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x3,y3)
call AddSpecialEffect(point4,"Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x4,y4)
call PauseUnit (Unit, true)
call AddLightning ("CLPB", x,y,x2,y2)
call AddLightning ("CLPB", x,y,x3,y3)
call AddLightning ("CLPB", x,y,x4,y4)
call TriggerSleepAction (1)
set dummy = CreateUnitAtLoc (GetOwningPlayer(Unit),'h000',x,y,0)
call PauseUnit (Unit, false)
call TimerStart (SlideTimer,1.00,true, function Slide)

set t    = null
set Unit = null
endfunction


//===========================================================================

private function SafeFilt takes nothing returns boolean
return true
endfunction
private function Lightning takes nothing returns nothing
 local trigger trig = CreateTrigger()
local integer i = 0
loop
    exitwhen i > 15
    call TriggerRegisterPlayerUnitEvent(trig,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,Condition(function SafeFilt))
    set i = i + 1
endloop
 call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )
 call TriggerAddCondition (trig, Condition (function Conditions ) )
 call TriggerAddAction (trig, function Actions )
 set trig = null
 endfunction

endscope
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
JASS:
call SetUnitPositionLoc(dummy , newX , newY)


Should be

JASS:
call SetUnitPosition(dummy , newX , newY)

//=============================================
JASS:
set newX = x + 50 *Cos(angle)
set newY = y + 50 *Sin(angle)


You forgot the bj_DEGTORAD such as
JASS:
set newX = x + 50 *Cos(angle * bj_DEGTORAD)
set newY = y + 50 *Sin(angle * bj_DEGTORAD)

//============================================
JASS:
local timer CreateTimer SlideTimer = CreateTimer()


Should be

JASS:
local timer SlideTimer = CreateTimer()

//============================================
JASS:
call AddSpecialEffect(point2,"Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x2,y2)
call AddSpecialEffect(point3,"Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x3,y3)
call AddSpecialEffect(point4,"Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x4,y4)


These should probably be
JASS:
call DestroyEffect(AddSpecialEffect(point2,"Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x2,y2))
call DestroyEffect(AddSpecialEffect(point3,"Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x3,y3))
call DestroyEffect(AddSpecialEffect(point4,"Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x4,y4))

//=====================================================
JASS:
integer raw = 'AHtb'


Could be changed to

JASS:
private constant integer raw = 'AHtb'

//====================================================
JASS:
local real realD1
local real realD2


These aren't even used.
 

Kazuga

Let the game begin...
Reaction score
110
Thanks so much both of you^^ From 25 errors down to 10:thup:

However this:
JASS:
set angle = Atan2(ty-y,tx-x)

makes
JASS:
set newX = x + 50 *Cos(angle * bj_DEGTORAD)
set newY = y + 50 *Sin(angle * bj_DEGTORAD)

unable to work..
Those are the last current errors^^
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
I didn't even see the location, since he used X and Y at the end I didn't think that there would be a location inside. All I did was adding the DestroyEffect in front of his already excisting line.
 

Kazuga

Let the game begin...
Reaction score
110
Ok there are no errors left, the code works but not still now...
First of all, the code is runed twice for some reason... There is 2 dummy units crated, 2 of each lightning effect and the bugg check message is displayed twice... Also the dummy is moved east and not towards the targeted unit...
+ The code is not mui for some reason, guess it's cuase the dummy variable is global so it's overwritten?
JASS:
scope Lightnings initializer Lightning
globals
private constant integer raw = 'AHtb'
unit dummy
unit caster
unit target
real tx
real ty
endglobals

private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == raw
endfunction

private function Slide takes nothing returns nothing
local real x = GetUnitX(dummy)
local real y = GetUnitY(dummy)
local real newX
local real newY
local real angle

set tx    = GetUnitX(target)
set ty    = GetUnitY(target)
set angle = Atan2(ty-y,tx-x)
set newX  = x + 50 *Cos(angle * bj_DEGTORAD)
set newY  = y + 50 *Sin(angle * bj_DEGTORAD)


call SetUnitPosition(dummy,newX,newY)
endfunction
private function Actions takes nothing returns nothing
local timer SlideTimer = CreateTimer()
local unit Unit                    = GetTriggerUnit()
local real real1                   = GetUnitFacing(Unit)

local real x = GetUnitX(GetTriggerUnit())
local real y = GetUnitY(GetTriggerUnit())

local real x2 = x + 300 * Cos((real1+145)*bj_DEGTORAD)
local real y2 = x + 300 * Sin((real1+145)*bj_DEGTORAD)

local real x3 = x + 300 * Cos((real1+180)*bj_DEGTORAD)
local real y3 = x + 300 * Sin((real1+180)*bj_DEGTORAD)

local real x4 = x + 300 * Cos((real1+215)*bj_DEGTORAD)
local real y4 = x + 300 * Sin((real1+215)*bj_DEGTORAD)


call TriggerSleepAction(1)
set target = (GetSpellTargetUnit())
call BJDebugMsg ("This part works")
call TriggerSleepAction (0.1)
call AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x2,y2)
call AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x3,y3)
call AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x4,y4)
//call PauseUnit (Unit, true)
call AddLightning ("CLPB",true, x,y,x2,y2)
call AddLightning ("CLPB",true, x,y,x3,y3)
call AddLightning ("CLPB",true, x,y,x4,y4)
call TriggerSleepAction (1)
set dummy = CreateUnit (GetOwningPlayer(Unit),'h000',x,y,0)
//call PauseUnit (Unit, false)
call TimerStart (SlideTimer,1.00,true, function Slide)

//set t    = null
set Unit = null
endfunction


//===========================================================================

private function SafeFilt takes nothing returns boolean
return true
endfunction
private function Lightning takes nothing returns nothing
 local trigger trig = CreateTrigger()
local integer i = 0
loop
    exitwhen i > 15
    call TriggerRegisterPlayerUnitEvent(trig,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,Condition(function SafeFilt))
    set i = i + 1
endloop
 call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )
 call TriggerAddCondition (trig, Condition (function Conditions ) )
 call TriggerAddAction (trig, function Actions )
 set trig = null
 endfunction

endscope
 

Flare

Stops copies me!
Reaction score
662
JASS:
loop
    exitwhen i > 15
    call TriggerRegisterPlayerUnitEvent(trig,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,Condition(function SafeFilt))
    set i = i + 1
endloop
 call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )


You registered the event twice. Remove the TriggerRegisterAnyUnitEventBJ

+ The code is not mui for some reason, guess it's cuase the dummy variable is global so it's overwritten?

Yup. You will need structs and some form of attachment system (such as ABC, HAIL, HSAS, CSData) to make it MUI

Also the dummy is moved east and not towards the targeted unit...

JASS:
set angle = Atan2(ty-y,tx-x)
set newX  = x + 50 *Cos(angle * bj_DEGTORAD)
set newY  = y + 50 *Sin(angle * bj_DEGTORAD)


angle is already set as radians (read first part of post 75), so you dont need to convert the angle from degrees to radians (since it's already radians)
 

Kazuga

Let the game begin...
Reaction score
110
Ah thanks^^ So those wasn't to be there anyway?

Yey it's working now^^ The dummy is moved towards the targeted unit and the trigger is only runed once.

All that is needed now is an ABC system to make it mui.
 

Flare

Stops copies me!
Reaction score
662
All that is needed now is an ABC system to make it mui.

IMO, use HAIL or CSData. They are simple to use (once you understand how to use the textmacro in the case of HAIL), but it can attach to alot more things (if you ever need unit attachment but don't want to use custom value, ABC isn't of much use, ad you will be forced to find another system anyway, so why bother learning how to use 2 systems when you can use 1 for everything :p

CSData is part of the CasterSystem but you don't need all of it, just CSData and any libraries that it requires.

HAIL thread can be found here

And here's a post showing a very simple way to initialize the HAIL functions that you need.
Link
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top