Failed Attempt in vJASS

cleeezzz

The Undead Ranger.
Reaction score
268
original GUI
Code:
Holy Arrow
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Ability being cast) Equal to Holy Arrow 
                (Ability being cast) Equal to Holy Arrow (Archer Mastery 1)
    Actions
        For each (Integer P) from 1 to 12, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Owner of (Triggering unit)) Equal to (Player(P))
                    Then - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Remaining time for Holy_Arrow_Timer[P]) Greater than 0.01
                            Then - Actions
                                Custom script:   call RemoveLocation(udg_Holy_Arrow_Position[udg_P])
                                Custom script:   call RemoveLocation(udg_Holy_Arrow_Spot[udg_P])
                            Else - Actions
                        Set HolyArrowOwner[P] = (Triggering unit)
                        Set Holy_Arrow_Position[P] = (Position of HolyArrowOwner[P])
                        Set Shake_Group[P] = (Units within 4000.00 of Holy_Arrow_Position[P])
                        Unit Group - Pick every unit in Shake_Group[P] and do (Actions)
                            Loop - Actions
                                Camera - Shake the camera for (Owner of (Picked unit)) with magnitude 50.00
                        Custom script:   call DestroyGroup(udg_Shake_Group[udg_P])
                        Special Effect - Create a special effect at Holy_Arrow_Position[P] using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
                        Special Effect - Destroy (Last created special effect)
                        Special Effect - Create a special effect at Holy_Arrow_Position[P] using Abilities\Spells\Orc\AncestralSpirit\AncestralSpiritCaster.mdl
                        Special Effect - Destroy (Last created special effect)
                        Special Effect - Create a special effect at Holy_Arrow_Position[P] using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
                        Special Effect - Destroy (Last created special effect)
                        Environment - Create a 4.00 second Depression ripple deformation at Holy_Arrow_Position[P] with starting radius 500.00, ending radius 2000.00, and depth 60.00, using 0.50 second ripples spaced 1000.00 apart
                        Unit - Set life of HolyArrowOwner[P] to 100.00%
                        Set Holy_Arrow_Spot[P] = (Target point of ability being cast)
                        Unit - Create 1 Holy Arrow Dummy for (Owner of HolyArrowOwner[P]) at Holy_Arrow_Position[P] facing Holy_Arrow_Spot[P]
                        Set Holy_Dummy[P] = (Last created unit)
                        Unit - Add a 7.00 second Generic expiration timer to Holy_Dummy[P]
                        Unit - Set level of Flame Strike (holy arrow)  for Holy_Dummy[P] to (Level of (Ability being cast) for HolyArrowOwner[P])
                        Set Holy_Fire_Offset[P] = 250
                        Set Holy_Fire_Offset_Max[P] = (1500 + (500 x (Level of (Ability being cast) for HolyArrowOwner[P])))
                        Countdown Timer - Start Holy_Arrow_Timer[P] as a Repeating timer that will expire in 0.27 seconds
                        Unit - Create 1 Holy Arrow Dummy for (Player(P)) at Holy_Arrow_Position[P] facing Holy_Arrow_Spot[P]
                        Set Shockwave_Dummy[P] = (Last created unit)
                        Unit - Add a 5.00 second Generic expiration timer to (Last created unit)
                        Unit - Set level of Holy Arrow (Dummy) (Cairne) for Shockwave_Dummy[P] to (Level of (Ability being cast) for HolyArrowOwner[P])
                        Unit - Order Shockwave_Dummy[P] to Orc Tauren Chieftain - Shockwave Holy_Arrow_Spot[P]
                    Else - Actions



(In my attempt)
JASS:
scope HolyArrowvJASS

private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A00C' or GetSpellAbilityId() == 'A00W'
endfunction

function Trig_Holy_Arrow_vJASS_Func002Func001Func001C takes nothing returns boolean
    if ( not ( TimerGetRemaining(udg_Holy_Arrow_Timer[udg_P]) > 0.01 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Holy_Arrow_vJASS_Func002Func001Func005A takes nothing returns nothing
    call CameraSetEQNoiseForPlayer( GetOwningPlayer(GetEnumUnit()), 50.00 )
endfunction

function Trig_Holy_Arrow_vJASS_Func002Func001C takes nothing returns boolean
    if ( not ( GetOwningPlayer(GetTriggerUnit()) == ConvertedPlayer(i) ) ) then
        return false
    endif
    return true
endfunction

private function Actions takes nothing returns nothing
    local integer i = 1
    loop
        exitwhen i > 12
        if ( Trig_Holy_Arrow_vJASS_Func002Func001C() ) then
            if ( Trig_Holy_Arrow_vJASS_Func002Func001Func001C() ) then
                call RemoveLocation(udg_Holy_Arrow_Position[udg_P])
                call RemoveLocation(udg_Holy_Arrow_Spot[udg_P])
            else
            endif
            local unit Caster = GetTriggerUnit()
            local location Caster_Loc = GetUnitLoc(Caster)
            local unit group Shake_Group = GetUnitsInRangeOfLocAll(4000.00, Caster_Loc)
            call ForGroupBJ(unit group Shake_Group, function Trig_Holy_Arrow_vJASS_Func002Func001Func005A )
            call DestroyGroup(unit group Shake_Group)
            call AddSpecialEffectLocBJ( "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", location Caster_Loc  )
            call DestroyEffectBJ( GetLastCreatedEffectBJ() )
            call AddSpecialEffectLoc( "Abilities\\Spells\\Orc\\AncestralSpirit\\AncestralSpiritCaster.mdl", location Caster_Loc )
            call DestroyEffect( GetLastCreatedEffectBJ() )
            call AddSpecialEffectLoc( "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl", location Caster_Loc )
            call DestroyEffect( GetLastCreatedEffectBJ() )
            call TerrainDeformationRippleBJ( 4.00, true, location Caster_Loc, 500.00, 2000.00, 60.00, 0.50, 1000.00 )
            call SetUnitLifePercentBJ( unit Caster, 100 )
            local location Cast_Point = GetSpellTargetLoc()
            call CreateNUnitsAtLoc( 1, 'h000', GetOwningPlayer(unit Caster), location Caster_Loc , AngleBetweenPoints(location Caster_Loc, location Cast_Point)
            local unit Dummy = GetLastCreatedUnit()
            call UnitApplyTimedLifeBJ( 7.00, 'BTLF', unit Dummy )
            call SetUnitAbilityLevel( unit Dummy, 'A00A', GetUnitAbilityLevel(unit Caster, GetSpellAbilityId())
            local real Holy_Fire_Offset = 250.
            local real Holy_Fire_Offset_Max = ( 1500 + ( 500 * GetUnitAbilityLevel(unit Caster, GetSpellAbilityId())) )
            call StartTimerBJ( udg_Holy_Arrow_Timer[udg_P], true, 0.27 )
            call CreateNUnitsAtLocFacingLocBJ( 1, 'h000', ConvertedPlayer(integer i), location Caster_Loc, location Cast_Point )
            local unit Dummy2 = GetLastCreatedUnit()
            call UnitApplyTimedLifeBJ( 5.00, 'BTLF', GetLastCreatedUnit() )
            call SetUnitAbilityLevel( unit Dummy2, 'A001', GetUnitAbilityLevel(unit Caster, GetSpellAbilityId())
            call IssuePointOrderLocBJ( unit Dummy2, "shockwave", location Cast_Point )
        else
        endif
        set integer i = integer i + 1
    endloop
endfunction

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

endscope

im stuck on multiple things..

function Trig_Holy_Arrow_vJASS_Func002Func001Func001C takes nothing returns boolean
if ( not ( TimerGetRemaining(udg_Holy_Arrow_Timer[udg_P]) > 0.01 ) ) then
(Btw, i was forced to use a timer in GUI for MPI, im hoping to get rid of it if possible)

and how do i do multiple conditions?
private function Conditions takes nothing returns boolean
OR-
return GetSpellAbilityId() == 'A00C'
return GetSpellAbilityId() == 'A00W'
endfunction

also, how do i move stuff to the top (ive seen spells where they list all variables in the beginning to make it look cleaner)

and last but not least, millions of syntax errors =/
 

Flare

Stops copies me!
Reaction score
662
and how do i do multiple conditions?

return cond1 and cond2 or cond3

also, how do i move stuff to the top (ive seen spells where they list all variables in the beginning to make it look cleaner)

do you mean a global block?
JASS:
globals
constant real damage = 5
constant real projspeed = 700
constant string effectstring = "<Insert some modelfile string hyah>"
endglobals


function Trig_Holy_Arrow_vJASS_Func002Func001Func001C takes nothing returns boolean
if ( not ( TimerGetRemaining(udg_Holy_Arrow_Timer[udg_P]) > 0.01 ) ) then
(Btw, i was forced to use a timer in GUI for MPI, im hoping to get rid of it if possible)

how does the timer affect the skill? and for that condition, would be much cleaner to do
JASS:
return TimerGetRemaining (udg_Holy_Arrow_Timer[udg_P]) < 0.01
//Converted GUI conditions are really ghey because they just make everything negative and reverse stuff that doesn't need reversing
 

cleeezzz

The Undead Ranger.
Reaction score
268
JASS:
private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A00C' or GetSpellAbilityId() == 'A00W'
endfunction

so like that?

the timer creates a line of fire. which i was hoping i could combine the 2 triggers now that vJASS has locals and stuff.

heres the fire.
Code:
Holy Arrow 1
    Events
        Time - Holy_Arrow_Timer[1] expires
        Time - Holy_Arrow_Timer[2] expires
        Time - Holy_Arrow_Timer[3] expires
        Time - Holy_Arrow_Timer[4] expires
        Time - Holy_Arrow_Timer[5] expires
        Time - Holy_Arrow_Timer[6] expires
        Time - Holy_Arrow_Timer[7] expires
        Time - Holy_Arrow_Timer[8] expires
        Time - Holy_Arrow_Timer[9] expires
        Time - Holy_Arrow_Timer[10] expires
        Time - Holy_Arrow_Timer[11] expires
        Time - Holy_Arrow_Timer[12] expires
    Conditions
    Actions
        For each (Integer Q) from 1 to 12, do (Actions)
            Loop - Actions
                Custom script:   if GetExpiredTimer() == udg_Holy_Arrow_Timer[udg_Q] then
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Holy_Fire_Offset[Q] Less than or equal to Holy_Fire_Offset_Max[Q]
                    Then - Actions
                        Set Holy_Dummy_TargetP[Q] = (Holy_Arrow_Position[Q] offset by (Real(Holy_Fire_Offset[Q])) towards (Angle from Holy_Arrow_Position[Q] to Holy_Arrow_Spot[Q]) degrees)
                        Special Effect - Create a special effect at Holy_Dummy_TargetP[Q] using Abilities\Spells\Human\MarkOfChaos\MarkOfChaosTarget.mdl
                        Special Effect - Destroy (Last created special effect)
                        Unit - Order Holy_Dummy[Q] to Human Blood Mage - Flame Strike Holy_Dummy_TargetP[Q]
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Terrain type at Holy_Dummy_TargetP[Q]) Equal to Lordaeron Winter - Snow
                            Then - Actions
                                Environment - Change terrain type at Holy_Dummy_TargetP[Q] to Lordaeron Summer - Grass using variation -1 in an area of size 2 and shape Circle
                            Else - Actions
                        Set Holy_Fire_Offset[Q] = (Holy_Fire_Offset[Q] + 250)
                        Custom script:   call RemoveLocation(udg_Holy_Dummy_TargetP[udg_Q])
                    Else - Actions
                        Countdown Timer - Pause Holy_Arrow_Timer[Q]
                        Set Holy_Fire_Offset[Q] = 250
                        Player Group - Pick every player in (All players) and do (Actions)
                            Loop - Actions
                                Camera - Stop swaying/shaking the camera for (Picked player)
                        Custom script:   call RemoveLocation(udg_Holy_Arrow_Position[udg_Q])
                        Custom script:   call RemoveLocation(udg_Holy_Arrow_Spot[udg_Q])
                Custom script:   endif

and am i doing it right in the actions? like.. every time i refer to a local variable? location Cast_Point

for example
JASS:
call IssuePointOrderLocBJ( unit Dummy2, "shockwave", location Cast_Point )

is that correct?

>do you mean a global block?
sure, does that include locals too?
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
JASS:
scope HolyArrowvJASS

globals
timer array udg_Holy_Arrow_Timer
location array udg_Holy_Arrow_Position
location array udg_Holy_Arrow_Spot
integer udg_P
endglobals

private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A00C' or GetSpellAbilityId() == 'A00W'
endfunction

function GroupCallBack takes nothing returns nothing
    call CameraSetEQNoiseForPlayer( GetOwningPlayer(GetEnumUnit()), 50.00 )
endfunction

private function Actions takes nothing returns nothing
    local integer i = 1
    local unit Caster = GetTriggerUnit()
    local location Caster_Loc = GetUnitLoc(Caster)
    local group Shake_Group = GetUnitsInRangeOfLocAll(4000.00, Caster_Loc)
    local location Cast_Point = GetSpellTargetLoc()
    local unit Dummy
    local real Holy_Fire_Offset = 250.
    local real Holy_Fire_Offset_Max = (1500 + ( 500 * GetUnitAbilityLevel(Caster, GetSpellAbilityId()))) 
    local unit Dummy2
    
    loop
        exitwhen i > 12
        if ( GetOwningPlayer(GetTriggerUnit()) == ConvertedPlayer(i) ) then
            if ( TimerGetRemaining(udg_Holy_Arrow_Timer[udg_P]) > 0.01 ) then
                call RemoveLocation(udg_Holy_Arrow_Position[udg_P])
                call RemoveLocation(udg_Holy_Arrow_Spot[udg_P])
            endif

            call ForGroup(Shake_Group, function GroupCallBack )
            call DestroyGroup(Shake_Group)
            
            call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl",Caster_Loc)  )
            call DestroyEffect(AddSpecialEffectLoc( "Abilities\\Spells\\Orc\\AncestralSpirit\\AncestralSpiritCaster.mdl",Caster_Loc ))
            call DestroyEffect(AddSpecialEffectLoc( "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl",Caster_Loc))

            call TerrainDeformationRippleBJ( 4.00, true, Caster_Loc, 500.00, 2000.00, 60.00, 0.50, 1000.00 )
            call SetUnitState(Caster, UNIT_STATE_LIFE, GetUnitState(Caster, UNIT_STATE_MAX_LIFE))
            
            set Dummy = CreateUnitAtLoc(GetOwningPlayer(Caster),'h000',Caster_Loc , AngleBetweenPoints(Caster_Loc, Cast_Point))
            call UnitApplyTimedLife(Dummy,'BTLF',7)
            call SetUnitAbilityLevel(Dummy, 'A00A', GetUnitAbilityLevel(Caster, GetSpellAbilityId()))
            
            call TimerStart(udg_Holy_Arrow_Timer[udg_P],0.27, true, null )
            
            set Dummy2 = CreateUnitAtLoc(ConvertedPlayer(i), 'h000',Caster_Loc,AngleBetweenPoints(Caster_Loc, Cast_Point ) )
            call UnitApplyTimedLife(Dummy2,'BTLF',5)
            call SetUnitAbilityLevel(Dummy2, 'A001', GetUnitAbilityLevel(Caster, GetSpellAbilityId()))
            call IssuePointOrderLocBJ(Dummy2, "shockwave", Cast_Point )
        endif
        set i = i + 1
    endloop
endfunction

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

endscope


**Note**
This code is 100% passed the syntax checker, and I did not created any variable in the variable window on the worldeditor.

So if you do created variables that used in this code in the world editor, then just delete the whole global block..

ex:
Code:
[B]globals[/B]
...
...
...
[B]endglobals[/B]
Delete the whole thing if you want to create those variable in the variable window.
 

cleeezzz

The Undead Ranger.
Reaction score
268
hmm it would be nice if jasscraft had that built in =/

anyway, i decided to go simpler so i can get the hang of it,

original GUI
Code:
Spread Shot
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Ability being cast) Equal to Spread Shot 
                (Ability being cast) Equal to Spread Shot (Archer Mastery 1)
    Actions
        Set Spread_Shot_Position = (Position of (Triggering unit))
        Set Spread_Shot_Spot = (Target point of ability being cast)
        Unit - Create 1 Spread Shot Dummy for (Owner of (Triggering unit)) at Spread_Shot_Position facing Spread_Shot_Spot
        Unit - Add a 4.00 second Generic expiration timer to (Last created unit)
        Set Spread_Shot_Dummy = (Last created unit)
        Unit - Set level of Spread Shot (Dummy)  for Spread_Shot_Dummy to (Level of (Ability being cast) for (Triggering unit))
        Unit - Order Spread_Shot_Dummy to Neutral - Breath Of Frost (Spread_Shot_Spot offset by 256.00 towards ((Angle from Spread_Shot_Spot to Spread_Shot_Position) + 20.00) degrees)
        Unit - Order Spread_Shot_Dummy to Neutral - Breath Of Frost (Spread_Shot_Spot offset by 256.00 towards ((Angle from Spread_Shot_Spot to Spread_Shot_Position) - 20.00) degrees)
        Custom script:   call RemoveLocation(udg_Spread_Shot_Position)
        Custom script:   call RemoveLocation(udg_Spread_Shot_Spot)

vJASS
JASS:
scope SpreadShotvJASS

private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A00D' or GetSpellAbilityId() == 'A006'
endfunction

private function Actions takes nothing returns nothing
    local location Caster_Loc = GetUnitLoc(GetTriggerUnit())
    local location Cast_Point = GetSpellTargetLoc()
    local real x = GetUnitX(GetTriggerUnit())
    local real y = GetUnitY(GetTriggerUnit())
    local unit Dummy = CreateUnit(GetOwningPlayer(GetTriggerUnit), 'h001', x, y, 0)
    local real Angle = AngleBetweenPoints (Caster_Loc, Cast_Point)
    local location Polar_Loc1 = PolarProjectionBJ (Caster_Loc, 256, Angle + 20)
    local location Polar_Loc2 = PolarProjectionBJ (Caster_Loc, 256, Angle - 20)
    call UnitApplyTimedLife(Dummy(), 'BTLF', 4.00 )
    call SetUnitAbilityLevel(Dummy, 'A009', GetUnitAbilityLevel( GetTriggerUnit(), GetSpellAbilityId()) )
    call IssuePointOrderLoc(Dummy, "breathoffrost", Polar_Loc1 )
    call IssuePointOrderLoc(Dummy, "breathoffrost", Polar_Loc2 )
    call RemoveLocation(Caster_Loc)
    call RemoveLocation(Cast_Point)
    call RemoveLocation(Polar_Loc1)
    call RemoveLocation(Polar_Loc2)
endfunction

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

endscope

is that the most efficient i can get it? (probably not, theres a bj in polarprojections)

P.S. thanks everyone so far.

also, converting TerrainDeformationRippleBJ -> TerrainDeformRipple

seems like TerrainDeformRipple has one extra feature, integer count? whats that do.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Count of ripples? My guess. :p

You can still make it better by using real coordinates, and inlining the BJ functions such as "PolarProjection" or "AngleBetweenPoints". And you also need to null your local handle declarations.

:thup:
 

cleeezzz

The Undead Ranger.
Reaction score
268
hmm, how do i null them?

set unit = null o_o?

EDIT: ok, i looked at some spells and that indeed, is how you null. but just clarifying, only groups and points have to be nulled right? (maybe units) (not integers/reals)

EDIT2: ok, syntax told me null cant be converted to real, so reals dont need to be nulled, but it let units, so i guess i should null units. updated trigger below

alright, i attempted inlining.

JASS:
scope SpreadShotvJASS

private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A00D' or GetSpellAbilityId() == 'A006'
endfunction

private function Actions takes nothing returns nothing
    local location Caster_Loc = GetUnitLoc(GetTriggerUnit())
    local location Cast_Point = GetSpellTargetLoc()
    local real x = GetUnitX(GetTriggerUnit())
    local real y = GetUnitY(GetTriggerUnit())
    local real x1 = GetLocationX(Cast_Point)
    local real y1 = GetLocationY(Cast_Point)
    local real Angle = bj_RADTODEG * Atan2(y1 - y, x1 - x)
    local real px1 = x + 256 * Cos((Angle + 20)* bj_DEGTORAD)
    local real py1 = y + 256 * Sin((Angle + 20)* bj_DEGTORAD)
    local real px2 = x + 256 * Cos((Angle - 20)* bj_DEGTORAD)
    local real py2 = y + 256 * Sin((Angle - 20)* bj_DEGTORAD)
    local unit Dummy = CreateUnit(GetOwningPlayer(GetTriggerUnit()), 'h001', x, y, 0)
    call UnitApplyTimedLife(Dummy, 'BTLF', 4.00 )
    call SetUnitAbilityLevel(Dummy, 'A009', GetUnitAbilityLevel( GetTriggerUnit(), GetSpellAbilityId()) )
    call IssuePointOrder(Dummy, "breathoffrost", px1, py1)
    call IssuePointOrder(Dummy, "breathoffrost", px2, py2)
    call RemoveLocation(Caster_Loc)
    call RemoveLocation(Cast_Point)
    set Caster_Loc = null
    set Cast_Point = null
    set Dummy = null
endfunction

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

endscope

and it gets through syntax. (yay)

EDIT: tested spell, works just like the GUI one, i guess i just needa null now.
 
Reaction score
333
Few things about that code:
  • Caster_Loc appears to never be used.
  • You use GetTriggerUnit() a lot, why not put it in a variable?
  • Why not remove the bj_DEGTORAD and bj_RADTODEG? The radians for 20 is about 0.34906, so use that instead.
  • When you issue two orders at once, only one will be followed.
  • You don't need to use InitTrig. Give your scope an initializer with "scope X initializer Init" and use an initializer instead (this isn't vital though, it's more a matter of preference).
  • Why give the local trigger in InitTrig such a long name?

About nulling. All handles (objects such as items, units, locations) need to be nulled if they are going to be destroyed at some stage. Players are permanent, so they don't need to be nulled. Triggers don't need to be nulled unless you are planning on destroying them at some stage, etc.
 

cleeezzz

The Undead Ranger.
Reaction score
268
JASS:
scope Spread

globals
    constant real      PI                            = 3.14159
    constant real      RADTODEG                      = 180.0/PI
    constant real      DEGTORAD                      = PI/180.0
endglobals

private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A00D' or GetSpellAbilityId() == 'A006'
endfunction

private function Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local location Cast_Point = GetSpellTargetLoc()
    local real x = GetUnitX(Caster)
    local real y = GetUnitY(Caster)
    local real x1 = GetLocationX(Cast_Point)
    local real y1 = GetLocationY(Cast_Point)
    local real Angle = RADTODEG * Atan2(y1 - y, x1 - x)
    local real px1 = x + 256 * Cos((Angle + 20)* DEGTORAD)
    local real py1 = y + 256 * Sin((Angle + 20)* DEGTORAD)
    local real px2 = x + 256 * Cos((Angle - 20)* DEGTORAD)
    local real py2 = y + 256 * Sin((Angle - 20)* DEGTORAD)
    local unit Dummy = CreateUnit(GetOwningPlayer(Caster), 'h001', x, y, 0)
    call UnitApplyTimedLife(Dummy, 'BTLF', 4.00 )
    call SetUnitAbilityLevel(Dummy, 'A009', GetUnitAbilityLevel(Caster, GetSpellAbilityId()) )
    call IssuePointOrder(Dummy, "breathoffrost", px1, py1)
    call IssuePointOrder(Dummy, "breathoffrost", px2, py2)
    call RemoveLocation(Caster_Loc)
    call RemoveLocation(Cast_Point)
    set Caster = null
    set Cast_Point = null
    set Dummy = null
endfunction

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

endscope

i wasnt really sure where to put the constants, so i put it as globals?

When you issue two orders at once, only one will be followed.
even if the dummy has 0 animation time? it works for me
 
Reaction score
333
I didn't mean replace the bj constants with your own, that has almost no effect at all. Get rid of the deg/rad conversion entirely, I mean, you're essentially just converting to degrees and then back again.
 

cleeezzz

The Undead Ranger.
Reaction score
268
ahh, i see what your saying.

JASS:
scope Spread

private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A00D' or GetSpellAbilityId() == 'A006'
endfunction

private function Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local location Cast_Point = GetSpellTargetLoc()
    local real x = GetUnitX(Caster)
    local real y = GetUnitY(Caster)
    local real x1 = GetLocationX(Cast_Point)
    local real y1 = GetLocationY(Cast_Point)
    local real Angle = Atan2(y1 - y, x1 - x)
    local real px1 = x + 256 * Cos(Angle + 20)
    local real py1 = y + 256 * Sin(Angle + 20)
    local real px2 = x + 256 * Cos(Angle - 20)
    local real py2 = y + 256 * Sin(Angle - 20)
    local unit Dummy = CreateUnit(GetOwningPlayer(Caster), 'h001', x, y, 0)
    call UnitApplyTimedLife(Dummy, 'BTLF', 4.00 )
    call SetUnitAbilityLevel(Dummy, 'A009', GetUnitAbilityLevel(Caster, GetSpellAbilityId()) )
    call IssuePointOrder(Dummy, "breathoffrost", px1, py1)
    call IssuePointOrder(Dummy, "breathoffrost", px2, py2)
    call RemoveLocation(Cast_Point)
    set Caster = null
    set Cast_Point = null
    set Dummy = null
endfunction

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

endscope

finally, most efficient ? :p


going back to the original trigger,
JASS:
scope HA

private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A00C' or GetSpellAbilityId() == 'A00W'
endfunction

function Shake takes nothing returns nothing
    call CameraSetEQNoiseForPlayer( GetOwningPlayer(GetEnumUnit()), 50.00 )
endfunction

private function Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local location Caster_Loc = GetUnitLoc(Caster)
    local real x = GetUnitX(Caster)
    local real y = GetUnitY(Caster)
    local location Cast_Point = GetSpellTargetLoc()
    local real x1 = GetLocationX(Cast_Point) 
    local real y1 = GetLocationY(Cast_Point)         
    local group Shake_Group = GetUnitsInRangeOfLocAll(4000.00, Caster_Loc)
    local unit Dummy = CreateUnit(GetOwningPlayer(Caster),'h000', x, y, 0)
    local unit Dummy2 = CreateUnit(GetOwningPlayer(Caster),'h000', x, y, 0)
    local real Holy_Fire_Offset = 250.
    local real Holy_Fire_Offset_Max = (1500 + ( 500 * GetUnitAbilityLevel(Caster, GetSpellAbilityId()))) 
    local timer Holy_Arrow_Timer = CreateTimer ()

    call ForGroup(Shake_Group, function Shake )
    call DestroyGroup(Shake_Group)
            
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", x, y ))
    call DestroyEffect(AddSpecialEffect( "Abilities\\Spells\\Orc\\AncestralSpirit\\AncestralSpiritCaster.mdl", x , y ))
    call DestroyEffect(AddSpecialEffect( "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl", x, y ))

    call TerrainDeformRipple ( x, y, 2000, 60, 4, 20, 1000.00 , 0.5 , 500.00 , true)
    call SetUnitState(Caster, UNIT_STATE_LIFE, GetUnitState(Caster, UNIT_STATE_MAX_LIFE))
            
    call UnitApplyTimedLife(Dummy,'BTLF',7)
    call SetUnitAbilityLevel(Dummy, 'A00A', GetUnitAbilityLevel(Caster, GetSpellAbilityId()))
            
    call TimerStart(Holy_Arrow_Timer,0.27, true, null )
    
    call UnitApplyTimedLife(Dummy2,'BTLF',5)
    call SetUnitAbilityLevel(Dummy2, 'A001', GetUnitAbilityLevel(Caster, GetSpellAbilityId()))
    call IssuePointOrder(Dummy2, "shockwave", x1 , y1 )
    call RemoveLocation(Cast_Point)
    call RemoveLocation(Caster_Loc)
    call DestroyTimer(Holy_Arrow_Timer)
    set Caster = null
    set Dummy = null
    set Dummy2 = null
    set Holy_Arrow_Timer = null 
endfunction

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

endscope

i have a few questions, why isn't the Shake function Private? (everything else is)
and after i call StartTimer, how do i do actions when the timer expires (without a new trigger perhaps?)
 

SFilip

Gone but not forgotten
Reaction score
634
What i meant for you to do was to replace the bj's like:

With:
JASS:
3.14159/180.0
Actually, that does nothing. Can even make it slower.
BJ functions, on the other hand, should be replaced with their native equivalents.
 
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