• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Poison Spell

Status
Not open for further replies.
Level 6
Joined
Oct 10, 2009
Messages
1,426
So yeah, I'm trying to add a poison effect to Fan of Knives.

I managed to create it, it fails in two different and annoying ways.

1) that the poison buff never goes away. The unit no longer get hurt, it just still has the buff.
The base ability of the buff is unholy aura with a -10% move speed modifer and a poison buff on the caster in 0 range.

2) It also annoys me by only picking out a few units from all the units within range.
It always picks three, when there are more than three. It will add the effect to them all, but only damages the three.


Any help would be appreciated. greatly. :thumbs_up:

In the hidden tags are all 4 triggers, even though I could have made it just 3.
You can completely redo them and the spell, or just tell me what's wrong. Either way you will get rep if it fixes the problem or helps show me what's wrong.

Triggers have been converted to Jass.
But I have the longest one in both GUI and Jass.


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

function Trig_FoK_Func002001003001 takes nothing returns boolean
    return ( GetOwningPlayer(GetFilterUnit()) == Player(11) )
endfunction

function Trig_FoK_Func002001003002 takes nothing returns boolean
    return ( GetOwningPlayer(GetFilterUnit()) == Player(PLAYER_NEUTRAL_AGGRESSIVE) )
endfunction

function Trig_FoK_Func002001003 takes nothing returns boolean
    return GetBooleanOr( Trig_FoK_Func002001003001(), Trig_FoK_Func002001003002() )
endfunction

function Trig_FoK_Func002A takes nothing returns nothing
    call GroupAddUnitSimple( GetEnumUnit(), udg_PoisonGroup )
    call UnitAddAbilityBJ( 'A00F', GetEnumUnit() )
endfunction

function Trig_FoK_Actions takes nothing returns nothing
    call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_609" )
    call ForGroupBJ( GetUnitsInRangeOfLocMatching(450.00, GetUnitLoc(GetTriggerUnit()), Condition(function Trig_FoK_Func002001003)), function Trig_FoK_Func002A )
    call EnableTrigger( gg_trg_Ticking )
    call StartTimerBJ( udg_TenSecPoisonTimer, false, 10.00 )
endfunction

//===========================================================================
function InitTrig_FoK takes nothing returns nothing
    set gg_trg_FoK = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_FoK, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_FoK, Condition( function Trig_FoK_Conditions ) )
    call TriggerAddAction( gg_trg_FoK, function Trig_FoK_Actions )
endfunction


Untitled1.jpg



JASS:
function Trig_Ticking_Func001A takes nothing returns nothing
    call SetUnitLifeBJ( GetEnumUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetEnumUnit()) - 30.00 ) )
endfunction

function Trig_Ticking_Actions takes nothing returns nothing
    call ForGroup( udg_PoisonGroup, function Trig_Ticking_Func001A )
endfunction

//===========================================================================
function InitTrig_Ticking takes nothing returns nothing
    set gg_trg_Ticking = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Ticking, 2 )
    call TriggerAddAction( gg_trg_Ticking, function Trig_Ticking_Actions )
endfunction


JASS:
function Trig_Stop_Poison_Actions takes nothing returns nothing
    call DisableTrigger( gg_trg_Ticking )
    call TriggerExecute( gg_trg_Remove_Poison )
    set udg_PoisonGroup = null
    set udg_TenSecPoisonTimer = null
endfunction

//===========================================================================
function InitTrig_Stop_Poison takes nothing returns nothing
    set gg_trg_Stop_Poison = CreateTrigger(  )
    call TriggerRegisterTimerExpireEvent( gg_trg_Stop_Poison, udg_TenSecPoisonTimer )
    call TriggerAddAction( gg_trg_Stop_Poison, function Trig_Stop_Poison_Actions )
endfunction


JASS:
function Trig_Untitled_Trigger_002_Func001A takes nothing returns nothing
    call UnitRemoveAbilityBJ( 'A00F', GetEnumUnit() )
    call UnitRemoveBuffBJ( 'Bpoi', GetEnumUnit() )
endfunction

function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing
    call ForGroupBJ( udg_PoisonGroup, function Trig_Untitled_Trigger_002_Func001A )
endfunction

//===========================================================================
function InitTrig_Remove_Poison takes nothing returns nothing
    set gg_trg_Remove_Poison = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Remove_Poison, function Trig_Untitled_Trigger_002_Actions )
endfunction
 
I made the spell for you; you don't need weird effects, just a Shadow Strike casted by a dummy and all set :)
JASS:
function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'AEfk' //The rawcode id of the Fan of Knives. Change it to your own rawcode.
endfunction

function Filter1 takes nothing returns boolean
    local unit filt = GetFilterUnit()
    local real x1
    local real y1
    local unit cast
    if IsUnitEnemy (filt, GetOwningPlayer(udg_F_Caster)) then
     set x1 = GetUnitX (filt)
     set y1 = GetUnitY (filt)
     set cast = CreateUnit (GetOwningPlayer(udg_F_Caster), 'h000', x1, y1, 0)
     call UnitApplyTimedLife (cast, 'BTLF', 1)
     call UnitAddAbility (cast, 'A000') //'A000' the rawcode of the dummy Shadow Strike ability.
     call SetUnitAbilityLevel (cast, 'A000', GetUnitAbilityLevel(udg_F_Caster, 'AEfk')) //Again, 'A000' and 'AEfk' are the codes of Shadow Strike (dummy) and Fan of Knives respectively.
     call IssueTargetOrder (cast, "shadowstrike", filt)
    endif
    set filt = null
    set cast = null
    return false
endfunction

function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local real x = GetUnitX (u)
    local real y = GetUnitY (u)
    local real d = 100 * GetUnitAbilityLevel (u, 'AEfk') + 300 //This defines the AoE of the Fan of Knives
    set udg_F_Caster = u
    call GroupEnumUnitsInRange (udg_F_Group, x, y, d, Filter (function Filter1))
    set u = null
endfunction

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

Test Map:
View attachment Fan of Knives + Poison.w3x
 
Level 6
Joined
Oct 10, 2009
Messages
1,426
I looked at your test map, and it worked great.

It however does not work when I copy the code into my map. >.>

The syntax errors I get are only undeclared variables, which of course is no problem.

I also created the two globals you use (F_Caster & F_Group), but It won't let me test the map. It simply goes to the wc3 menu. Which tells me that there must be a mistake somewhere. >.>

I still gave you rep though because you're still awesome :grin:
 
Ok, for future references:

The spell I made in the test map used a dummy, a shadow strike ability, and a buff. You need to copy all the stuff that I use in the map and transfer it into your own, not just the code.

Then, in the code, everything written in green letters should be really read! You always forget about the rawcodes. Each ability has a rawcode (press Ctrl + D in your Object Editor to check it out and press it again to disable it). Whenever you see "GetSpellAbilityId()" in a code, you will see the rawcode (e.g. 'AEfk'). In order to make the code work with your ability, replace AEfk with the rawcode of your ability. So, if it is A000, it will become 'A000', instead of the previous 'AEfk'.

View attachment Sunken City v.1.4..w3x
 
Level 6
Joined
Oct 10, 2009
Messages
1,426
I use the fan of knives as well, so it had same raw code. I read everything in the green letters, but you're right, I didn't know to the dummy, buff, etc...

And the map you gave me, I couldn't open. It said level data missing or invalid in both regular WE and NewGen
 
:eek:
That's... really weird. Anyway, here is what you have to do:
• Copy paste the dummy of the test map.
• Copy paste the Shadow strike (dummy) of the test map.
• Copy paste the "Poison" buff of the test map.
• Go to the code and replace (you will see it in two spots) the 'A000' with 'A00A' (this was the rawcode of the ability, when I pasted in your map, so, unless you created another ability, this will be the rawcode of yours too; press Ctrl + D to make sure)

That's all ;)
 
Status
Not open for further replies.
Top