- Joined
- Jul 4, 2016
- Messages
- 14
I am making triggerd spell an "insanity curse"
"Insanity Curse (Passive)"
Grants a chance to curse attacked enemy with "Insanity curse". Cursed unit attacks random ally near him untill curse ends.
But I can't get unit filter for this working...
Here is a code of problem place:
Here is a code of the spell:
Thanks in advance.
"Insanity Curse (Passive)"
Grants a chance to curse attacked enemy with "Insanity curse". Cursed unit attacks random ally near him untill curse ends.
But I can't get unit filter for this working...
Here is a code of problem place:
JASS:
//unit u = udg_cursed_unit
//unit t = udg_cursed_unit_attack_target
//location p = udg_cursed_unit_position
if (( t == null ) or (IsUnitDeadBJ(t))) then
set t = GroupPickRandomUnit(GetUnitsInRangeOfLocMatching(512, p, Condition(function GetBooleanAnd(( IsUnitAlly(GetFilterUnit(), GetOwningPlayer(t)) == true), IsUnitAliveBJ(GetFilterUnit()) == true)))) ///// This line causes problems - syntax checker says ' symbol is missing
endif
call IssueTargetOrderBJ( u, "attack", t)
Here is a code of the spell:
JASS:
//////////////////////////////////////////////////////////////////////
//////////////////////////// INSANITY PASSIVE ////////////////////////////
//////////////////////////////////////////////////////////////////////
function Trig_Insanity_Passive_Conditions takes nothing returns boolean
if ( (GetUnitAbilityLevelSwapped('Abun', GetAttackedUnitBJ()) > 0 ) or (IsUnitType(GetAttackedUnitBJ(), UNIT_TYPE_HERO) == true) or ( IsUnitType(GetAttackedUnitBJ(), UNIT_TYPE_STRUCTURE) == true )) then
return false
endif
if ( not ( GetUnitAbilityLevelSwapped('Aesr', GetAttacker()) > 0 ) ) then
return false
endif
return true
endfunction
function Trig_Insanity_Passive_Actions takes nothing returns nothing
// ------create local variables------//
local effect e
local unit u
local unit t
local real r = 0.0
local location p
// ------assign local variables------//
set u = GetAttackedUnitBJ()
set p = GetUnitLoc(u)
// ------calculate chance ------//
if ( GetUnitLevel(u) <= 1 ) then
set r = 0.75
else
set r = r + (0.7 - 0.07 * (I2R(GetUnitLevel(u))))/2 /// depends on victim Level
set r = r + (1 - GetUnitLifePercent(u)/75) /// and current health
if (r > 0.5) then
set r = 0.5
endif
endif
// ----
// ------compare chance ------//
if ( r >= GetRandomReal(0, 1) ) then
call DoNothing( )
else
return
endif
// ------attach effect ------//
/// call AddSpecialEffectTargetUnitBJ( "overhead", u, "war3campImported\\ForsakenInsanity.mdx" )
call AddSpecialEffectTargetUnitBJ( "overhead", u, "Abilities\\Spells\\Other\\TalkToMe\\TalkToMe.mdx" )
set e = GetLastCreatedEffectBJ()
// ------PROBLEM PLACE------//
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 6
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
if (( t == null ) or (IsUnitDeadBJ(t))) then
set t = GroupPickRandomUnit(GetUnitsInRangeOfLocMatching(512, p, Condition(function GetBooleanAnd(( IsUnitAlly(GetFilterUnit(), GetOwningPlayer(t)) == true), IsUnitAliveBJ(GetFilterUnit()) == true))))
endif
call IssuePointOrderLocBJ( u, "move", PolarProjectionBJ(p, 256.00, GetRandomDirectionDeg()) )
call IssueTargetOrderBJ( u, "attack", t)
call TriggerSleepAction( 0.5 )
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
// ------destroy effect------//
call DestroyEffectBJ(e)
call RemoveLocation(p)
set u = null
set r = 0.0
set t = null
// ------resume order ------//
call IssuePointOrderLocBJ( u, "attack", p )
endfunction
//===========================================================================
function InitTrig_Insanity_Passive takes nothing returns nothing
set gg_trg_Insanity_Passive = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Insanity_Passive, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( gg_trg_Insanity_Passive, Condition( function Trig_Insanity_Passive_Conditions ) )
call TriggerAddAction( gg_trg_Insanity_Passive, function Trig_Insanity_Passive_Actions )
endfunction
Thanks in advance.
Last edited: