Some jass questions

Knight7770

Hippopotomonstrosesquiped aliophobia
Reaction score
187
Can't you just do this?
JASS:
local effect special1 = "Abilities\\Spells\\NightElf\\Starfall\\StarfallCaster.mdl",x,y

Or am I wrong (which I probably am)?
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
You added "udg_" in front of the local variable's name, it's not a user defined global.

Also to remove effects you can do this:

JASS:
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\NightElf\\Starfall\\StarfallCaster.mdl",x,y))
 

Flare

Stops copies me!
Reaction score
662
hm the effect isn't seen at all with that line =/

It works the same as
Code:
Special Effect - Create...
Special Effect - Destroy (Last Created Special Effect)

It shows the effect's birth(or death, im not sure) anim and removes it after that has played out fully.

local effect special1 = "Abilities\\Spells\\NightElf\\Starfall\\StarfallCaster.mdl",x,y

You still have to call the function i.e.
JASS:
local effect special1 = AddSpecialEffect ("Abilities\\Spells\\NightElf\\Starfall\\StarfallCaster.mdl",x,y)
 

SerraAvenger

Cuz I can
Reaction score
234
Hm back to the unit group thing, should I have all the functions alone and then call for the action or...? Sort of confusing to handle 4 functions for one action..

JASS:
function Trig_x_Func001002003001 takes nothing returns boolean
    return ( IsUnitAliveBJ(GetFilterUnit()) == true )
endfunction

function Trig_x_Func001002003002 takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true )
endfunction

function Trig_x_Func001002003 takes nothing returns boolean
    return GetBooleanAnd( Trig_x_Func001002003001(), Trig_x_Func001002003002() )
endfunction
this can be easily rewritten as:

JASS:
function Trig_x_FilterCondition takes nothing returns boolean
    local unit filterUnit = GetFilterUnit()
    return GetUnitState( filterUnit ) > 0 and IsUnitEnemy( filterUnit, GetOwningPlayer( GetTriggerUnit() ) )
endfunction

function Trig_x_Actions takes nothing returns nothing
    set udg_z = GetUnitsInRangeOfLocMatching(512, GetUnitLoc(GetTriggerUnit()), Condition(function Trig_x_FilterCondition))
endfunction

JASS:
library HAILInit requires HAIL
//! runtextmacro HAIL_CreateProperty ("Data", "integer", "")
endlibrary
scope Lightnings initializer Lightning
globals
private constant integer raw = 'A001'
endglobals
private struct TestStruct
unit dummy
unit caster
unit target
real tx
real ty
timer SlideTimer
endstruct

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


// --- Here --- !!

private function Effect takes real myX, real myY, unit Target returns nothing
    local real x
    local real y
    local real x2
    local real y2
    local real real1 = 0
    local unit dummy
    
    set x  = myX + 300 * Cos((45)  * bj_DEGTORAD)
    set y  = myY + 300 * Sin((45)  * bj_DEGTORAD)
    set x2 = myX + 300 * Cos((315) * bj_DEGTORAD)
    set y2 = myY + 300 * Sin((315) * bj_DEGTORAD)
    
    call TimedLightning ("CLPB", x2, y2, 0, myX, myY, 0, 2., true, 1, 0)
    call TimedLightning ("CLPB", x, y, 0, myX, myY, 0, 2., true, 1, 0)

    set x  = myX + 300 * Cos((125)  * bj_DEGTORAD)
    set y  = myY + 300 * Sin((125)  * bj_DEGTORAD)
    set x2 = myX + 300 * Cos((225) * bj_DEGTORAD)
    set y2 = myY + 300 * Sin((225) * bj_DEGTORAD)
    
    call TimedLightning ("CLPB", x2, y2, 0, myX, myY, 0, 2., true, 1, 0)
    call TimedLightning ("CLPB", x, y, 0, myX, myY, 0, 2., true, 1, 0)

    call BJDebugMsg("wait works")
    call PauseUnit(Target,false)
    
    call AddSpecialEffect("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl",myX,myY)  
endfunction
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
I'd also suggest you changing this:

JASS:
//! runtextmacro HAIL_CreateProperty ("Data", "integer", "")


Into this:

JASS:
//! runtextmacro HAIL_CreateProperty ("Data", "integer", "private")


Considering you're using a name like "Data" it would be for the greater good making it private.
 

Kazuga

Let the game begin...
Reaction score
110
Changed (altough I don't really know what that line does at all =/ )
JASS:
function Trig_x_FilterCondition takes nothing returns boolean
    local unit filterUnit = GetFilterUnit()
    return GetUnitState( filterUnit ) > 0 and IsUnitEnemy( filterUnit, GetOwningPlayer( GetTriggerUnit() ) ) //Doesn't work "Not enough arguments passed to function"
endfunction

This action is put into the action function instead of having it's own right?
JASS:
function Trig_x_Actions takes nothing returns nothing
    set udg_z = GetUnitsInRangeOfLocMatching(512, GetUnitLoc(GetTriggerUnit()), Condition(function Trig_x_FilterCondition))
endfunction
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
My line makes the HAIL property private, meaning that you can use the name "Data" in all your triggers as long as you make them "private".

JASS:
function Trig_x_FilterCondition takes nothing returns boolean
    local unit filterUnit = GetFilterUnit()
    return GetUnitState( filterUnit ) > 0 and IsUnitEnemy( filterUnit, GetOwningPlayer( GetTriggerUnit() ) ) //Doesn't work "Not enough arguments passed to function"
endfunction


Should be:
JASS:
function Trig_x_FilterCondition takes nothing returns boolean
    local unit filterUnit = GetFilterUnit()
    return GetUnitState( filterUnit ) > 0 and IsUnitEnemy( filterUnit, GetOwningPlayer( GetTriggerUnit() ) ) == true
endfunction


Allthough you could use GetFilterUnit() inside the return rather than making a local unit variable that can't be nulled.

And the last call goes in your Actions-function.
 

Kazuga

Let the game begin...
Reaction score
110
Ah thanks^^

I really apriciate your help I really do:thup: Sorry that I can't give you more rep atm since I did yesterday or if it was the day before =/
 

SerraAvenger

Cuz I can
Reaction score
234
My line makes the HAIL property private, meaning that you can use the name "Data" in all your triggers as long as you make them "private".

JASS:
function Trig_x_FilterCondition takes nothing returns boolean
    local unit filterUnit = GetFilterUnit()
    return GetUnitState( filterUnit ) > 0 and IsUnitEnemy( filterUnit, GetOwningPlayer( GetTriggerUnit() ) ) //Doesn't work "Not enough arguments passed to function"
endfunction


Should be:
JASS:

function Trig_x_FilterCondition takes nothing returns boolean
    local unit filterUnit = GetFilterUnit()
    return GetUnitState( filterUnit ) > 0 and IsUnitEnemy( filterUnit, GetOwningPlayer( GetTriggerUnit() ) ) == true
endfunction


Allthough you could use GetFilterUnit() inside the return rather than making a local unit variable that can't be nulled.

And the last call goes in your Actions-function.

the == true is useless here.
If true == true will return the same as
if true, as true == true will return true anyway. Just a comparision less and a bit more of readability
apart from that, I forgot the ", UNIT_STATE_LIFE" in
JASS:
, sorry
 

Kazuga

Let the game begin...
Reaction score
110
Now when I have the group, I need to do something with the units inside of it. The converted code is 2 functions and 2 BJ:s...
JASS:
function Trig_x_Func001A takes nothing returns nothing
    call UnitDamageTargetBJ( GetTriggerUnit(), GetEnumUnit(), ( I2R(GetUnitAbilityLevelSwapped('A001', GetTriggerUnit())) * 200.00 ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endfunction

function Trig_x_Actions takes nothing returns nothing
    call ForGroupBJ( udg_z, function Trig_x_Func001A )
endfunction

Should it be a function for itself containing the actions the loop should do? Also I need to change the call ForGroupBJ?
 

Flare

Stops copies me!
Reaction score
662
ForGroupBJ becomes ForGroup

UnitDamageTargetBJ becomes UnitDamageTarget (I think they take the arguments in same order, except the native has the addition of weapontype IIRC)

Should it be a function for itself containing the actions the loop should do

What? Do you mean "are the group loop actions supposed to be in another function?", then yes, they are.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
The native would take weapon-type, but also booleans for attack and range.

I think it is something like:

JASS:
UnitDamageTarget(unit WhichUnit, widget Target, boolean attack, boolean range, attack type, damage type, weapon type)


An easy way would be:


Just alter the damage type or something.

IIRC the first boolean "attack" is whether or not the damaged unit will respond to the damage. The second one, "range", I do not know for sure what it does, maybe it's just if it's counted as melee or ranged damage?
 

Kazuga

Let the game begin...
Reaction score
110
Hm that's just for one unit or? I want to damage all units within the unit group =/
 

Kazuga

Let the game begin...
Reaction score
110
Get the error "Undeclared variable WEAPON_TYPE_NORMAL", why do you need a variable for a weapon type...?
JASS:
   call UnitDamageTarget(caster, GetEnumUnit(), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_NORMAL)


Whole code:
JASS:
library HAILInit requires HAIL
//! runtextmacro HAIL_CreateProperty ("Data", "integer", "")
endlibrary
scope Lightnings initializer Lightning
globals
private constant integer raw = 'A001'
unit caster = GetTriggerUnit ()
endglobals
private struct TestStruct
unit dummy
unit caster
unit target
real tx
real ty
timer SlideTimer
endstruct

private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == raw
endfunction
function Trig_Lightnings_FilterCondition takes nothing returns boolean
    
    return GetWidgetLife( GetFilterUnit() ) > 0.405 and IsUnitEnemy( GetFilterUnit(), GetOwningPlayer( GetTriggerUnit() ) ) == true
    
endfunction
function Trig_Lightnings_Func001A takes nothing returns nothing
    call UnitDamageTarget(caster, GetEnumUnit(), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_NORMAL)
    endfunction

private function Effect takes real myX, real myY, unit Target returns nothing
    local real x
    local real y
    local real x2
    local real y2
    local real real1 = 0
    local unit dummy
    
    set x  = myX + 300 * Cos((45)  * bj_DEGTORAD)
    set y  = myY + 300 * Sin((45)  * bj_DEGTORAD)
    set x2 = myX + 300 * Cos((315) * bj_DEGTORAD)
    set y2 = myY + 300 * Sin((315) * bj_DEGTORAD)
    
    call TimedLightning ("CLPB", x2, y2, 0, myX, myY, 0, 2., true, 1, 0)
    call TimedLightning ("CLPB", x, y, 0, myX, myY, 0, 2., true, 1, 0)

    set x  = myX + 300 * Cos((125)  * bj_DEGTORAD)
    set y  = myY + 300 * Sin((125)  * bj_DEGTORAD)
    set x2 = myX + 300 * Cos((225) * bj_DEGTORAD)
    set y2 = myY + 300 * Sin((225) * bj_DEGTORAD)
    
    call TimedLightning ("CLPB", x2, y2, 0, myX, myY, 0, 2., true, 1, 0)
    call TimedLightning ("CLPB", x, y, 0, myX, myY, 0, 2., true, 1, 0)

    call PauseUnit(Target,false)
    set udg_z = GetUnitsInRangeOfLocMatching(500, GetUnitLoc(GetTriggerUnit()), Condition(function Trig_Lightnings_FilterCondition))
    call ForGroup( udg_z, function Trig_Lightnings_Func001A )
    call AddSpecialEffect("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl",myX,myY)  
endfunction



private function Slide takes nothing returns nothing
local TestStruct data = GetData (GetExpiredTimer ())
local real x = GetUnitX(data.dummy)
local real y = GetUnitY(data.dummy)
local real newX
local real newY
local real angle
local real distance
local real real1=45
local real x2 
local real y2 



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

call SetUnitPosition(data.dummy,newX,newY)
call AddSpecialEffect("Abilities\\Spells\\Items\\AIma\\AImaTarget.mdl",newX,newY)
set distance=SquareRoot( (x-data.tx)*(x-data.tx) + (y-data.ty)*(y-data.ty) )
if distance < 50 then
    call PauseTimer (data.SlideTimer)
    call ResetData (data.SlideTimer)
    call DestroyTimer (data.SlideTimer)
    call PauseUnit (data.target,true)
    call RemoveUnit(data.dummy)
    call data.destroy ()
    call Effect(data.tx, data.ty, data.target)

endif
endfunction


private function Actions takes nothing returns nothing
local TestStruct data = TestStruct.create ()
local unit Unit                    = GetTriggerUnit()
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)
local effect special1

set data.SlideTimer = CreateTimer()
set data.target = (GetSpellTargetUnit())
set special1 = AddSpecialEffect("Abilities\\Spells\\NightElf\\Starfall\\StarfallCaster.mdl",x,y)
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 AddSpecialEffect("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl",x,y)
call PauseUnit (Unit, true)

call TimedLightning ("CLPB", x, y, 0, x2, y2, 0, 2., true, 1, 0)
call TimedLightning ("CLPB", x, y, 0, x3, y3, 0, 2., true, 1, 0)
call TimedLightning ("CLPB", x, y, 0, x4, y4, 0, 2., true, 1, 0)


call TriggerSleepAction (1)
call DestroyEffect(special1)
set data.dummy = CreateUnit (GetOwningPlayer(Unit),'h001',x,y,0)
call SetUnitPathing(data.dummy, false )
call PauseUnit (Unit, false)
call TimerStart (data.SlideTimer,0.05,true, function Slide)
call SetData (data.SlideTimer, data)
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
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top