• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[JASS] JASS Spell help - Wont Work!

Status
Not open for further replies.
Level 5
Joined
Jul 17, 2006
Messages
145
:< i cant get this JASS trigger to work, but iv looked over it over and over, and i dont understand why it wont work.

It passes syntax checks fine and i can run the game with it, but when I use the ability 'A054' it dosent do what its supposed to (shoot a line of frost in front of a unit)

why this wont work dosent make ANY sence, so any help is appreciated

JASS:
function Trig_Captian_Hapos_Freezer_Cannon_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A04S'
endfunction

function Trig_Captian_Hapos_Freezer_Cannon_Actions takes nothing returns nothing
    local unit cast = GetTriggerUnit()
    local location l = GetUnitLoc(cast)
    local location facing = PolarProjectionBJ(l,300,GetUnitFacing(cast))
    
    call CreateUnitAtLoc(GetOwningPlayer(cast),'o001',l,GetUnitFacing(cast))
    call IssuePointOrderLoc(GetLastCreatedUnit(),"shockwave",facing)
    call UnitApplyTimedLife(GetLastCreatedUnit(),'BTLF',2.00)

    set cast = null
    set l = null
    set facing = null
endfunction

//===========================================================================
function InitTrig_Captian_Hapos_Freezer_Cannon takes nothing returns nothing
    set gg_trg_Captian_Hapos_Freezer_Cannon = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Captian_Hapos_Freezer_Cannon, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Captian_Hapos_Freezer_Cannon, Condition( function Trig_Captian_Hapos_Freezer_Cannon_Conditions ) )
    call TriggerAddAction( gg_trg_Captian_Hapos_Freezer_Cannon, function Trig_Captian_Hapos_Freezer_Cannon_Actions )
endfunction
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
CreateUnitAtLoc() doesn't set bj_lastCreatedUnit.

You should do

JASS:
local unit u = CreateUnit...
call DoSomething( u )
call DoSomethingElse( u )
// or
set bj_lastCreatedUnit = CreateUnit...

and so on

Also, CreateUnit > CreateUnitAtLoc. Finally, you're leaking a few locations
 
Last edited:
Level 5
Joined
Jul 17, 2006
Messages
145
:S :S
JASS:
function Trig_Captian_Hapos_Freezer_Cannon_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A04S'
endfunction

function Trig_Captian_Hapos_Freezer_Cannon_Actions takes nothing returns nothing
    local unit cast = GetTriggerUnit()
    local location l = GetUnitLoc(cast)
    local unit u = CreateUnit(GetOwningPlayer(cast),'o001',GetLocationX(l),GetLocationZ(l),GetUnitFacing(cast))
    local location facing = PolarProjectionBJ(l,300,GetUnitFacing(cast))
    
    call IssuePointOrderLoc(u,"shockwave",facing)
    call UnitApplyTimedLife(u,'BTLF',2.00)

    set cast = null
    set l = null
    set u = null
    set facing = null
endfunction

//===========================================================================
function InitTrig_Captian_Hapos_Freezer_Cannon takes nothing returns nothing
    set gg_trg_Captian_Hapos_Freezer_Cannon = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Captian_Hapos_Freezer_Cannon, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Captian_Hapos_Freezer_Cannon, Condition( function Trig_Captian_Hapos_Freezer_Cannon_Conditions ) )
    call TriggerAddAction( gg_trg_Captian_Hapos_Freezer_Cannon, function Trig_Captian_Hapos_Freezer_Cannon_Actions )
endfunction

well thats what i have now
and i found out whats wrong. apperently when you tell a unit to use an ability at a point with shockwave, it only works if that point is accually a unit O_O
any way to fix this? if you use shockwave manually you can target ground, but using this trigger it only worked if i was "300 units" from an enemy unit in front of me :(
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
:S :S
JASS:
function Trig_Captian_Hapos_Freezer_Cannon_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A04S'
endfunction

function Trig_Captian_Hapos_Freezer_Cannon_Actions takes nothing returns nothing
    local unit cast = GetTriggerUnit()
    local location l = GetUnitLoc(cast)
    local unit u = CreateUnit(GetOwningPlayer(cast),'o001',GetLocationX(l),GetLocationZ(l),GetUnitFacing(cast))
    local location facing = PolarProjectionBJ(l,300,GetUnitFacing(cast))
    
    call IssuePointOrderLoc(u,"shockwave",facing)
    call UnitApplyTimedLife(u,'BTLF',2.00)

    set cast = null
    set l = null
    set u = null
    set facing = null
endfunction

//===========================================================================
function InitTrig_Captian_Hapos_Freezer_Cannon takes nothing returns nothing
    set gg_trg_Captian_Hapos_Freezer_Cannon = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Captian_Hapos_Freezer_Cannon, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Captian_Hapos_Freezer_Cannon, Condition( function Trig_Captian_Hapos_Freezer_Cannon_Conditions ) )
    call TriggerAddAction( gg_trg_Captian_Hapos_Freezer_Cannon, function Trig_Captian_Hapos_Freezer_Cannon_Actions )
endfunction

well thats what i have now
and i found out whats wrong. apperently when you tell a unit to use an ability at a point with shockwave, it only works if that point is accually a unit O_O
any way to fix this? if you use shockwave manually you can target ground, but using this trigger it only worked if i was "300 units" from an enemy unit in front of me :(

I don't wanna know who told you that o_O.

Also, as for the JASS, you can use more efficient things than locations. You also accidentally used GetLocationZ instead of GetLocationY

Here's an update on your script;

JASS:
function Trig_Captian_Hapos_Freezer_Cannon_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A04S'
endfunction

function Trig_Captian_Hapos_Freezer_Cannon_Actions takes nothing returns nothing
    local unit cast = GetTriggerUnit()
    local unit u = CreateUnit(GetOwningPlayer(cast),'o001',GetUnitX(cast),GetUnitY(cast),GetUnitFacing(cast))
    local real a = GetUnitFacing(cast)*bj_DEGTORAD
    
    call IssuePointOrder(u,"shockwave",GetUnitX(u)+300*Cos(a),GetUnitY(u)+300*Sin(a))
    call UnitApplyTimedLife(u,'BTlf',2)

    set cast = null
    set u = null
endfunction

//===========================================================================
function InitTrig_Captian_Hapos_Freezer_Cannon takes nothing returns nothing
    set gg_trg_Captian_Hapos_Freezer_Cannon = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Captian_Hapos_Freezer_Cannon, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Captian_Hapos_Freezer_Cannon, Condition( function Trig_Captian_Hapos_Freezer_Cannon_Conditions ) )
    call TriggerAddAction( gg_trg_Captian_Hapos_Freezer_Cannon, function Trig_Captian_Hapos_Freezer_Cannon_Actions )
endfunction
 
Level 5
Joined
Jul 17, 2006
Messages
145
I don't wanna know who told you that o_O.

lol i figured it out based on observation, but it confused me too O_O
anyways with GetLocationZ() changed to GetLocationY() it works properly now >_>

JASS:
local real a = GetUnitFacing(cast)*bj_DEGTORAD
call IssuePointOrder(u,"shockwave",GetUnitX(u)+300*Cos(a),GetUnitY(u)+300*Sin(a))
O_O what would that do for me. what i have already clears all locations preventing leaks. however im intrested in learning more so walk me though this :p

right now im in Geometry, so iv only had a basic course in Cos/Sin.
first, i see that bj_DEGTORAD divides Pi by 180...what does that do for you O_O
could i have a mathmatcal explanation of how (location of unit + (300*Cos(Unit Facing*0.017453292519943295769236907684886)) will get you the X of the point 300 units in front of a unit >_>

anyways helping me on this would be....helpful ^^ im always willing to learn
 
Last edited by a moderator:
Level 40
Joined
Dec 14, 2005
Messages
10,532
First; you don't clear the locations X_x

bj_DEGTORAD -- as it looks, n*that, where n is in degrees, becomes n in radians. All trigonometry is done in radians, so that's why I convert it.

And what I did is exactly what PolarProjectionBJ does, but with x/y and being more efficient (seeing as you don't have to call the wrapper).

If you want to know what all the Cos and Sin and junk are, ask someone to teach you trigonometry (the geometry of triangles)

Mathematical explanation, if you already know trigonometry --

If we have a triangle that looks something like

/|
~

with the bottom-left angle being t (short for theta), the diagonal being the Hypotenuse, the ~ being the Adjacent, and the | being the opposite, and hypotenuse being "d",

d*Cos(t) = Adjacent (X distance)
d*Sin(t) = Opposite (Y distance)

If theta is in radians. Since GetUnitFacing returns degrees, GetUnitFacing * bj_DEGTORAD is the radian equivelant
 
Level 5
Joined
Jul 17, 2006
Messages
145
ok well converting it to radians makes sence..
i know what sin and con are.. hmm
hmm dont locations destory themsleves if you set them to a var and then nullify the var?
 
Level 5
Joined
Sep 19, 2006
Messages
152
Just to clarify: so GetUnitX(unit) and GetUnitY(unit) values are self-destroying, whereas local location UnitPlace = GetUnitLoc(unit) is not?
 
Status
Not open for further replies.
Top