HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

WC2 Runes: Triggers to Jass

06-12-2006, 09:51 PM#1
Kam
So I came up with this triggered spell for Runes. It works in a multi instance game, but at some points if you tell more than one ogre to cast it on different locations they just cast it on the same spot. So, I was wondering if someone could help me convert to JASS using the JESP standard.
I use three triggers:

Runes
Trigger:
Runes
Collapse Events
Unit - A unit Begins casting an ability
Collapse Conditions
(Ability being cast) Equal to Runes
Collapse Actions
Unit - Create 1 Rune for (Owner of (Casting unit)) at ((Target point of ability being cast) offset by (0.00, 0.00)) facing (Source of current camera view)
Unit - Create 1 Rune for (Owner of (Casting unit)) at ((Target point of ability being cast) offset by (150.00, 0.00)) facing (Source of current camera view)
Unit - Create 1 Rune for (Owner of (Casting unit)) at ((Target point of ability being cast) offset by (-150.00, 0.00)) facing (Source of current camera view)
Unit - Create 1 Rune for (Owner of (Casting unit)) at ((Target point of ability being cast) offset by (0.00, 150.00)) facing (Source of current camera view)
Unit - Create 1 Rune for (Owner of (Casting unit)) at ((Target point of ability being cast) offset by (0.00, -150.00)) facing (Source of current camera view)

Runes Timed Life
Trigger:
Runes Timed Life
Collapse Events
Unit - A unit enters (Playable map area)
Collapse Conditions
(Unit-type of (Triggering unit)) Equal to Rune
Collapse Actions
Unit - Add a 60.00 second Generic expiration timer to (Triggering unit)

Rune Kill
Trigger:
Rune Kill
Collapse Events
Unit - A unit Dies
Collapse Conditions
(Ability being cast) Equal to AOE damage upon death (Rune)
((Dying unit) is A ground unit) Equal to True
Collapse Actions
Ubersplat - Create ubersplat at (Position of (Dying unit)) of type Test with color (100.00%, 100.00%, 100.00%) and 0.00% transparency (Disable paused state, Disable skipping birth time)
06-12-2006, 11:02 PM#2
Rising_Dusk
Trigger:
Runes
Collapse Events
Unit - A unit Begins casting an ability
Collapse Conditions
(Ability being cast) Equal to Runes
Collapse Actions
Unit - Create 1 Rune for (Owner of (Casting unit)) at ((Target point of ability being cast) offset by (0.00, 0.00)) facing (Source of current camera view)
Unit - Add a 60.00 second Generic expiration timer to (last created unit)
Unit - Create 1 Rune for (Owner of (Casting unit)) at ((Target point of ability being cast) offset by (150.00, 0.00)) facing (Source of current camera view)
Unit - Add a 60.00 second Generic expiration timer to (last created unit)
Unit - Create 1 Rune for (Owner of (Casting unit)) at ((Target point of ability being cast) offset by (-150.00, 0.00)) facing (Source of current camera view)
Unit - Add a 60.00 second Generic expiration timer to (last created unit)
Unit - Create 1 Rune for (Owner of (Casting unit)) at ((Target point of ability being cast) offset by (0.00, 150.00)) facing (Source of current camera view)
Unit - Add a 60.00 second Generic expiration timer to (last created unit)
Unit - Create 1 Rune for (Owner of (Casting unit)) at ((Target point of ability being cast) offset by (0.00, -150.00)) facing (Source of current camera view)
Unit - Add a 60.00 second Generic expiration timer to (last created unit)

Also, on your third trigger remove the condition for (Ability being cast), with a death event there is no ability being cast.

If you're serious about making it into jass and making it fit the JESP manifest you should look around the sites for tutorials and try to first attempt it yourself, then post your own jass work for looking over.

You don't learn anything if someone else makes it for you.
A good tutorial to get you started is here.
06-13-2006, 01:17 AM#3
Kam
Thanks.
06-13-2006, 03:19 AM#4
PipeDream
" Unit - A unit Begins casting an ability " is not exactly what you want, since it fires before the good stuff happens. I'm not certain it's the cause of your problem, but it will let another bug in: players will be able to cancel the actual spell cast so that they get the trigger effects with no mana or cooldown cost. Change to "starts the effect of an ability" and both problems should go away.
06-13-2006, 07:20 AM#5
Kam
I converted these two triggers to JASS in the editor, but I am having trouble figuring out how to combine the two and why the ubersplat does not work.

Collapse JASS:
function Trig_Runes_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A028' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Runes_Actions takes nothing returns nothing
    call CreateNUnitsAtLocFacingLocBJ( 1, 'n00C', GetOwningPlayer(GetSpellAbilityUnit()), OffsetLocation(GetSpellTargetLoc(), 0.00, 0.00), GetCameraEyePositionLoc() )
    call UnitApplyTimedLifeBJ( 60, 'BTLF', GetLastCreatedUnit() )
    call CreateNUnitsAtLocFacingLocBJ( 1, 'n00C', GetOwningPlayer(GetSpellAbilityUnit()), OffsetLocation(GetSpellTargetLoc(), 150.00, 0), GetCameraEyePositionLoc() )
    call UnitApplyTimedLifeBJ( 60, 'BTLF', GetLastCreatedUnit() )
    call CreateNUnitsAtLocFacingLocBJ( 1, 'n00C', GetOwningPlayer(GetSpellAbilityUnit()), OffsetLocation(GetSpellTargetLoc(), -150.00, 0), GetCameraEyePositionLoc() )
    call UnitApplyTimedLifeBJ( 60, 'BTLF', GetLastCreatedUnit() )
    call CreateNUnitsAtLocFacingLocBJ( 1, 'n00C', GetOwningPlayer(GetSpellAbilityUnit()), OffsetLocation(GetSpellTargetLoc(), 0.00, 150.00), GetCameraEyePositionLoc() )
    call UnitApplyTimedLifeBJ( 60, 'BTLF', GetLastCreatedUnit() )
    call CreateNUnitsAtLocFacingLocBJ( 1, 'n00C', GetOwningPlayer(GetSpellAbilityUnit()), OffsetLocation(GetSpellTargetLoc(), 0.00, -150.00), GetCameraEyePositionLoc() )
    call UnitApplyTimedLifeBJ( 60, 'BTLF', GetLastCreatedUnit() )
endfunction

//===========================================================================
function InitTrig_Runes takes nothing returns nothing
    set gg_trg_Runes = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Runes, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Runes, Condition( function Trig_Runes_Conditions ) )
    call TriggerAddAction( gg_trg_Runes, function Trig_Runes_Actions )
endfunction

Collapse JASS:
function Trig_Runes_Kill_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetKillingUnitBJ()) == 'n00C' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Runes_Kill_Actions takes nothing returns nothing
    call CreateUbersplatBJ( GetUnitLoc(GetKillingUnitBJ()), "NVOL", 100, 100, 100, 0, false, false )
endfunction

//===========================================================================
function InitTrig_Runes_Kill takes nothing returns nothing
    set gg_trg_Runes_Kill = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Runes_Kill, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Runes_Kill, Condition( function Trig_Runes_Kill_Conditions ) )
    call TriggerAddAction( gg_trg_Runes_Kill, function Trig_Runes_Kill_Actions )
endfunction
06-13-2006, 07:33 AM#6
Anitarf
You should use GetDyingUnit(), not GetKillingUnit(), in both the condition and action.
06-13-2006, 08:45 AM#7
Captain Griffen
They already are MUI. Converting them into JASS will make them more efficient, though.

A major problem there is leaks (10 location leaks at least). Meanwhile, THE major problem is this:

Collapse JASS:
GetCameraEyePositionLoc()

That will desync in multiplayer (oh, and leaks as well).
06-13-2006, 08:52 AM#8
Kam
How do I fix the getcamera desyncing?
06-13-2006, 09:04 AM#9
PipeDream
Oh, I didn't even notice that. The problem is that camera targets are local information. You'll have to manually send the information. see http://www.wc3jass.com/viewtopic.php?t=2676&start=0

You could try mike's snippets as is. If it takes too long to sync that many values one by one, you'll have to modify it so that it sets up selections for all players at once.

Of course since all you want is facing.. You might as well just say screw it and have the runes face a random direction.
06-13-2006, 09:36 AM#10
Kam
So here is the new first part:

Collapse JASS:
function Trig_Runes_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A028' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Runes_Actions takes nothing returns nothing
    call CreateNUnitsAtLocFacingLocBJ( 1, 'n00C', GetOwningPlayer(GetSpellAbilityUnit()), OffsetLocation(GetSpellTargetLoc(), 0.00, 0.00), GetRandomLocInRect(GetPlayableMapRect()) )
    call UnitApplyTimedLifeBJ( 60, 'BTLF', GetLastCreatedUnit() )
    call CreateNUnitsAtLocFacingLocBJ( 1, 'n00C', GetOwningPlayer(GetSpellAbilityUnit()), OffsetLocation(GetSpellTargetLoc(), 150.00, 0), GetRandomLocInRect(GetPlayableMapRect()) )
    call UnitApplyTimedLifeBJ( 60, 'BTLF', GetLastCreatedUnit() )
    call CreateNUnitsAtLocFacingLocBJ( 1, 'n00C', GetOwningPlayer(GetSpellAbilityUnit()), OffsetLocation(GetSpellTargetLoc(), -150.00, 0), GetRandomLocInRect(GetPlayableMapRect()) )
    call UnitApplyTimedLifeBJ( 60, 'BTLF', GetLastCreatedUnit() )
    call CreateNUnitsAtLocFacingLocBJ( 1, 'n00C', GetOwningPlayer(GetSpellAbilityUnit()), OffsetLocation(GetSpellTargetLoc(), 0.00, 150.00), GetRandomLocInRect(GetPlayableMapRect()) )
    call UnitApplyTimedLifeBJ( 60, 'BTLF', GetLastCreatedUnit() )
    call CreateNUnitsAtLocFacingLocBJ( 1, 'n00C', GetOwningPlayer(GetSpellAbilityUnit()), OffsetLocation(GetSpellTargetLoc(), 0.00, -150.00), GetRandomLocInRect(GetPlayableMapRect()) )
    call UnitApplyTimedLifeBJ( 60, 'BTLF', GetLastCreatedUnit() )
endfunction

//===========================================================================
function InitTrig_Runes takes nothing returns nothing
    set gg_trg_Runes = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Runes, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Runes, Condition( function Trig_Runes_Conditions ) )
    call TriggerAddAction( gg_trg_Runes, function Trig_Runes_Actions )
endfunction

And here is the new second part:

Collapse JASS:
function Trig_Runes_Kill_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetDyingUnitBJ()) == 'n00C' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Runes_Kill_Actions takes nothing returns nothing
    call CreateUbersplatBJ( GetUnitLoc(GetDyingUnitBJ()), "NVOL", 100, 100, 100, 0, false, false )
endfunction

//===========================================================================
function InitTrig_Runes_Kill takes nothing returns nothing
    set gg_trg_Runes_Kill = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Runes_Kill, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Runes_Kill, Condition( function Trig_Runes_Kill_Conditions ) )
    call TriggerAddAction( gg_trg_Runes_Kill, function Trig_Runes_Kill_Actions )
endfunction

The attempts I have made in WE to combine these two have failed. I believe they have because I am not sure how to deal with the closing lines of each script, the part under the green line. At any rate, a few of the leaks should now be fixed.
06-13-2006, 01:15 PM#11
TaintedReality
The bottom function, as its name implies, initializes the trigger. It adds events to it, conditions to it, and actions to it. Since you just converted from GUI you shouldn't have to worry about it (unless you want to add new events).

You don't need to combine them together, they both have seperate events so there's no reason to.
06-13-2006, 02:33 PM#12
Captain Griffen
First trigger still has 15 location leaks. Also, you keep using BJs, rather than natives. Change to:

Collapse JASS:
function Trig_Runes_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A028' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Runes_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local player p = GetOwningPlayer(p)
    set u = CreateUnit( p, 'n00C', x, y, 0.00)
    call UnitApplyTimedLife( u, 'BTLF', 60)
    set u = CreateUnit( p, 'n00C', x + 150, y, 0.00)
    call UnitApplyTimedLife( u, 'BTLF', 60)
    set u = CreateUnit( p, 'n00C', x - 150, y, 0.00)
    call UnitApplyTimedLife( u, 'BTLF', 60)
    set u = CreateUnit( p, 'n00C', x, y + 150, 0.00)
    call UnitApplyTimedLife( u, 'BTLF', 60)
    set u = CreateUnit( p, 'n00C', x, y - 150, 0.00)
    call UnitApplyTimedLife( u, 'BTLF', 60)
    set u = null
    set p = null
endfunction

//===========================================================================
function InitTrig_Runes takes nothing returns nothing
    set gg_trg_Runes = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Runes, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Runes, Condition( function Trig_Runes_Conditions ) )
    call TriggerAddAction( gg_trg_Runes, function Trig_Runes_Actions )
endfunction

Fixed the leaks. If you want it to face random directions, then use GetRandomReal(0, 360) in place of the 0.00 at the end.
06-13-2006, 04:10 PM#13
Rising_Dusk
In Runes Trigger:

Change the condition function to this.
Collapse JASS:
function Trig_Runes_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A028'
endfunction

In Rune Kill Trigger:

Change the condition function to this.
Collapse JASS:
function Trig_Runes_Kill_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetDyingUnit()) == 'n00C'
endfunction

And you don't need to nullify Players, Griffen. Just a heads up. :P
06-13-2006, 04:24 PM#14
Captain Griffen
Rising Dusk, yes, you do need to nullify players. Any local variable that extends a handle must be nullified.

Collapse JASS:
type player             extends     handle
06-13-2006, 04:27 PM#15
Rising_Dusk
I'm not sure the reasoning offhand, but I've been told numerous times by people not to.
I'd like someone who plays with jass a lot (Weeaddar/Vex/Pipe) to clarify that either way, I really am 90% sure they don't have to be nulled for some mitigating reason.