| 12-02-2007, 03:59 AM | #1 |
JASS://Autocast ability ID. function AC_AbilityID takes nothing returns integer return 'A005' endfunction //Autocast buff ID. function AC_AbilityBuffID takes nothing returns integer return 'B000' endfunction //Autocast ability's turn-on string function AC_AbilityOrderIDOn takes nothing returns string return "poisonarrows" endfunction //Autocast ability's turn-off string function AC_AbilityOrderIDOff takes nothing returns string return "unpoisonarrows" endfunction //* Floating Text misc functions //Floating text red color level (%) function AC_TextTagRedLevel takes nothing returns real return 1.00 endfunction //Floating text green color level (%) function AC_TextTagGreenLevel takes nothing returns real return 85.00 endfunction //Floating text blue color level (%) function AC_TextTagBlueLevel takes nothing returns real return 86.00 endfunction //Floating text's transparency (%) function AC_TextTagTransparency takes nothing returns real return 15.00 endfunction //Actual floating text string. for now, returns base damage + extra damage. function AC_TextTagString takes real damage, real extradmg returns string return I2S(R2I(damage+extradmg)) endfunction //determines whether to use the floating text or not. currently enabled; //in order to disable it, change "return true" to "return false". function AC_UseTextTag takes nothing returns boolean return true endfunction //* End floating text misc functions //Trigger's main condition function AC_Condition takes nothing returns boolean return( GetLearnedSkill() == AC_AbilityID() ) endfunction function AutoCast_Effect takes nothing returns nothing local texttag g local real d = 1 local trigger t=GetTriggeringTrigger() local real vel = TextTagSpeed2Velocity(64.0) local real xvel = vel * Cos(90.0 * bj_DEGTORAD) local real yvel = vel * Sin(90.0 * bj_DEGTORAD) local real textHeight if GetUnitAbilityLevel(GetTriggerUnit(), AC_AbilityBuffID()) > 0 and GetUnitAbilityLevel( GetEventDamageSource(), AC_AbilityID() )>0 then call DestroyTrigger(t) call KillUnit(GetTriggerUnit()) // Add whatever actions you want // in these lines; // this function triggers when the target unit is hit // by the autocast ability. // you may change the floating text's color, transparency, // string, state (enabled or disabled) by changing // the misc floating text functions above. if AC_UseTextTag() then set g = CreateTextTag() set textHeight = TextTagSize2Height(10.0) call SetTextTagText(g, AC_TextTagString(GetEventDamage(), 0.00), textHeight) call SetTextTagPosUnit(g, GetTriggerUnit(), 64.0) call SetTextTagColor(g, PercentTo255(AC_TextTagRedLevel()), PercentTo255(AC_TextTagGreenLevel()), PercentTo255(AC_TextTagBlueLevel()), PercentTo255(100.0-AC_TextTagTransparency())) call SetTextTagVelocity(g, xvel,yvel) call UnitDamageTarget(GetEventDamageSource(), GetTriggerUnit(), d, true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_DIVINE, WEAPON_TYPE_WHOKNOWS) call PolledWait(1) call DestroyTextTag( g ) endif endif set g=null set t=null endfunction function AutoCast_Conditions takes nothing returns boolean if GetTriggerEventId() == EVENT_PLAYER_UNIT_ATTACKED then return GetUnitAbilityLevel( GetAttacker(), AC_AbilityID() ) == 0 or (GetAttachedInt(GetAttacker(),"CSon")==1 and IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) == false) elseif GetTriggerEventId() == EVENT_UNIT_ISSUED_ORDER then if GetIssuedOrderId() == OrderId(AC_AbilityOrderIDOn()) then call AttachInt( GetTriggerUnit(), "CSon", 1) elseif GetIssuedOrderId() == OrderId(AC_AbilityOrderIDOff()) then call AttachInt( GetTriggerUnit(), "CSon", 0) endif elseif GetTriggerEventId() == EVENT_UNIT_SPELL_EFFECT then return GetSpellAbilityId()== AC_AbilityID() endif return false endfunction function AutoCast_Activate takes nothing returns nothing local trigger r=CreateTrigger() local unit t local event e local triggeraction ta if GetTriggerEventId() == EVENT_UNIT_SPELL_EFFECT then set t=GetSpellTargetUnit() else set t=GetTriggerUnit() endif set e = TriggerRegisterUnitEvent( r, t, EVENT_UNIT_DAMAGED ) set ta = TriggerAddAction(r,function AutoCast_Effect) call TriggerSleepAction(2) call DestroyTrigger(r) set r=null set t=null set e = null set ta = null endfunction function Trig_AutoCastSystem_Actions takes nothing returns nothing local trigger r=GetTriggeringTrigger() local trigger t=CreateTrigger() local triggeraction ta local triggercondition tc local event array e1 local event e2 local event e3 local integer index set index = 0 loop set e1[index] = TriggerRegisterPlayerUnitEvent(t, Player(index), EVENT_PLAYER_UNIT_ATTACKED, null) set index = index + 1 exitwhen index == bj_MAX_PLAYER_SLOTS endloop set e2 = TriggerRegisterUnitEvent( t, GetLearningUnit(), EVENT_UNIT_SPELL_EFFECT ) set e3 = TriggerRegisterUnitEvent( t, GetLearningUnit(), EVENT_UNIT_ISSUED_ORDER ) set tc = TriggerAddCondition(t, Condition(function AutoCast_Conditions) ) set ta = TriggerAddAction(t , function AutoCast_Activate ) call DestroyTrigger(r) set r=null set t=null set gg_trg_AutoCastSystem=null set index = 0 loop set e1[index] = null set index = index + 1 exitwhen index == bj_MAX_PLAYER_SLOTS endloop set e2 = null set e3 = null set tc = null set ta = null endfunction //=========================================================================== function InitTrig_AutoCastSystem takes nothing returns nothing set gg_trg_AutoCastSystem = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_AutoCastSystem, EVENT_PLAYER_HERO_SKILL ) call TriggerAddCondition( gg_trg_AutoCastSystem, Condition( function AC_Condition ) ) call TriggerAddAction( gg_trg_AutoCastSystem, function Trig_AutoCastSystem_Actions ) endfunction im sure that i changed the raw codes to my spells and buffs raw codes im confused on some auto cast attack buffs....like in poison arrow, it uses 2 buffs, first is the stacking poison, and the second is the non stacking poison...but what buff will i use in this template? i tried the 2 buffs one by one, but still doesnt work... i added a function that kills the unit that being hit by the auto cast attack ability, but still doesnt work and it didnt give me some errors while saving the map any ideas? |
