| 11-04-2006, 07:15 AM | #1 |
Hi This is a spell i have ben working on for the last two days, but i still cant make it to work right. Finaly i did at least got it throught the WE's syntax checker, but it wont work right. Her comes the code: JASS:// =============== \\ // BoolExpr Filter \\ // =============== \\ function RaptorFilter takes nothing returns boolean if ( not ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(udg_RampageCaster)) == true ) ) then return false endif if ( not ( IsUnitAliveBJ(GetFilterUnit()) == true ) ) then return false endif if ( not ( IsUnitHiddenBJ(GetFilterUnit()) == false ) ) then return false endif return true endfunction // ================ \\ // Fading Functions \\ // ================ \\ function RaptorFadeIn takes nothing returns nothing local timer fader = GetExpiredTimer() local unit raptor = GetHandleUnit( fader, "raptor" ) local integer rate = GetHandleInt( fader, "rate" ) call SetUnitVertexColorBJ( raptor, 100, 100, 100, rate ) call SetHandleInt( fader, "rate", rate-5 ) if rate <= 0 then call SetUnitVertexColor( raptor, 255, 255, 255, 255 ) call FlushHandleLocals( fader ) call PauseTimer( fader ) call DestroyTimer( fader ) endif set fader = null set raptor = null endfunction function RaptorFadeOut takes nothing returns nothing local timer fader = GetExpiredTimer() local unit raptor = GetHandleUnit( fader, "raptor" ) local integer rate = GetHandleInt( fader, "rate" ) call SetUnitVertexColorBJ( raptor, 100, 100, 100, rate ) call SetHandleInt( fader, "rate", rate+5 ) if rate >= 100 then call RemoveUnit( raptor ) call FlushHandleLocals( fader ) call PauseTimer( fader ) call DestroyTimer( fader ) endif set fader = null set raptor = null endfunction // =================== \\ // Attacking Functions \\ // =================== \\ function RaptorAttacks takes nothing returns nothing local timer atk = GetExpiredTimer() local timer fader = CreateTimer() local unit raptor = GetHandleUnit( atk, "raptor" ) call SetHandleHandle( fader, "raptor", raptor ) call SetHandleInt( fader, "rate", 0 ) call TimerStart( fader, 0.05, true, function RaptorFadeOut ) set atk = null set fader = null set raptor = null endfunction // ============================= \\ // Moving and Damaging Functions \\ // ============================= \\ function RaptorHitsUnit takes nothing returns nothing local timer rt = GetExpiredTimer() local timer atk = CreateTimer() local timer fader = CreateTimer() local unit raptor = GetHandleUnit( rt, "raptor" ) local boolean canattack = GetHandleBoolean( rt, "canattack" ) local group target = CreateGroup() local boolexpr filter = Filter( function RaptorFilter ) local unit t local location loca = GetUnitLoc( udg_RampageCaster ) local location locb = GetUnitLoc( raptor ) if canattack == true then set target = GetUnitsInRangeOfLocMatching( 250, locb, filter ) if FirstOfGroup( target ) != null then set t = FirstOfGroup( target ) call IssueTargetOrder( raptor, "attack", t ) call SetHandleHandle( atk, "raptor", raptor ) call TimerStart( atk, 5, false, function RaptorAttacks ) call FlushHandleLocals( rt ) call PauseTimer( rt ) call DestroyTimer( rt ) endif endif if DistanceBetweenPoints( loca, locb ) >=1250 then call SetHandleHandle( fader, "raptor", raptor ) call SetHandleInt( fader, "rate", 0 ) call TimerStart( fader, 0.05, true, function RaptorFadeOut ) call FlushHandleLocals( rt ) call PauseTimer( rt ) call DestroyTimer( rt ) endif call RemoveLocation( loca ) call RemoveLocation( locb ) call DestroyBoolExpr( filter ) call DestroyGroup( target ) set rt = null set fader = null set fader = null set raptor = null set target = null endfunction function Rampaging takes nothing returns nothing local timer t = GetExpiredTimer() local timer rt = CreateTimer() local timer fader = CreateTimer() local unit caster = GetHandleUnit( t, "caster" ) local unit raptor local real angle = GetUnitFacing( caster ) local location loc = PolarProjectionBJ( GetUnitLoc( caster ), 400, angle-180 ) local real x = GetLocationX( loc )+GetRandomReal( -350, 350 ) local real y = GetLocationY( loc )+GetRandomReal( -350, 350 ) local location targloc = PolarProjectionBJ( GetUnitLoc( caster ), 2000, angle ) local real targx = GetLocationX( targloc )+GetRandomReal( -400, 400 ) local real targy = GetLocationY( targloc )+GetRandomReal( -400, 400 ) if udg_Rampaging == true then set raptor = CreateUnit( GetOwningPlayer( caster ), 'h000', x, y, angle ) call SetUnitVertexColor( raptor, 255, 255, 255, 0 ) call UnitAddAbility( raptor, 'Aloc' ) call SetUnitMoveSpeed( raptor, 522 ) call SetUnitPathing( raptor, false ) call IssuePointOrder( raptor, "move", targx, targy ) call SetHandleHandle( rt, "raptor", raptor ) call SetHandleBoolean( rt, "canattack", true ) call SetHandleHandle( fader, "raptor", raptor ) call SetHandleInt( fader, "rate", 100 ) call TimerStart( fader, 0.05, true, function RaptorFadeIn ) call TimerStart( rt, 0.2, true, function RaptorHitsUnit ) set raptor = null else call FlushHandleLocals( t ) call PauseTimer( t ) call DestroyTimer( t ) endif call RemoveLocation( loc ) call RemoveLocation( targloc ) // call TriggerSleepAction( 1 ) // call SetHandleBoolean( rt, "canattack", true ) set t = null set caster = null set rt = null set fader = null endfunction // ====================== \\ // Initializing Functions \\ // ====================== \\ function Trig_Rampage_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'A002' endfunction function Trig_Rampage_Actions takes nothing returns nothing local timer t = CreateTimer() local unit caster = GetTriggerUnit() call SetHandleHandle( t, "caster", caster ) call SetHandleInt( t, "steps", 60 ) call TimerStart( t, 0.5, true, function Rampaging ) set udg_RampageCaster = GetTriggerUnit() set udg_Rampaging = true set t = null set caster = null endfunction //=========================================================================== function InitTrig_Rampage takes nothing returns nothing set gg_trg_Rampage = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Rampage, EVENT_PLAYER_UNIT_SPELL_CHANNEL ) call TriggerAddCondition( gg_trg_Rampage, Condition( function Trig_Rampage_Conditions ) ) call TriggerAddAction( gg_trg_Rampage, function Trig_Rampage_Actions ) endfunction This lasts up to 40 seconds at max level, what it does? Every half second it summons a unit that fades in from 100% transparency over a second, whe transparency=0 they are able to attack. When theyre out of a set distance from the caster, they will fade out(but they dont, they just dissapear). My problem is, they dont attack anything, they just runrunrun and dissapears. So, help would be nice. I got another code to detect when i finish casting and when i stop channeling, but is it a way to detect that in the same trigger? |
| 11-04-2006, 08:06 AM | #2 |
I'm sorry, but half the thing's a mess atm. You're creating timers you never use, you're creating so many timers anyway, you're double destroying some filters because the BJ's also do that... it needs some coherency. As a side note, ordering a unit to attack every 0.2 seconds could stop it attacking altogether (as it starts attacking and is reordered, so it starts again etc). I would also suggest debug messages, as they are the best way to debug. Staring at a huge script isn't going to make the bugs jump out at you, but displaying the values and finding which ones aren't correct can lead you to the problem. |
| 11-04-2006, 08:10 AM | #3 |
Hmm, sry im not too experienced with jass, but i think that attacking thing stopped when i order the units attacks? Because if not this script have become a big mess... Eeven bigger then it was. Btw ive tried to fix it, i remade some of the code, then it attacked the caster most of the time. So i made a global caster var, just to make it easier, then the WE crashed. EIDT: Yes, ive ben trying debug messages, the i had the boolean "canattack" returning false all the time, and the triggering unit in the filter was null and void, and some other stuff... I have updated the code. EDIT 2: Another update on the script, the timer is stopped and destroyed when the units is ordered attack or gets out of range. DOH! double sry wtf?!? EDIT: Nevermind, i made it work :p But i would still like to know if i could detect if my guy stops casting then set a var to false in same trigger |
