| 10-04-2007, 09:47 AM | #1 | |
As metioned in the topic I suck when making a certain type of spell that includes any type of movement. First I'll post the code. JASS:scope Charge private function sid takes nothing returns integer return 'A00E' //Charge's trigger ability endfunction private function did takes nothing returns integer return 'hfoo' //Charge's dummy unit type endfunction private function sdid takes nothing returns integer return 'A00B' //Charge's dummy spell endfunction private function RageRegain takes real l returns real return 6+(3*l) //Charge's rage regain from reaching the target. l is your ability level endfunction private function ActiveRange takes nothing returns real return 150. //Charge's activation range endfunction private function SplitPerMove takes nothing returns real return 10. //Charge's movement distance per move divider endfunction private function MinRange takes nothing returns real return 240. //Charge's minium range endfunction private function mr takes nothing returns real return .3 //Charge's move rate endfunction private function CheckIfAttackedInterval takes nothing returns real return .1 //Charge's interval before declaring if it is in combat or not. This only detects if the endfunction //Caster is hit //! runtextmacro COLLECTION ("Charge","private") private struct Charge unit c = null unit t = null player o = null integer oid = 0 boolean b = false real r = 0. endstruct globals private timer ChargeMoveTimer = CreateTimer() endglobals private function Periodic takes nothing returns nothing local Charge dat local unit d = null local integer i = 0 call IteratorCharge.reset() loop exitwhen IteratorCharge.noNext() set dat = IteratorCharge.next() if not (GetUnitCurrentOrder(dat.c) == dat.oid) or GetWidgetLife(dat.c) < .405 or dat.b == true then call dat.destroy() call IteratorCharge.remove() else set dat.r = SH_DistanceBetweenLocs (GetUnitX(dat.c),GetUnitY(dat.c), GetUnitX(dat.t),GetUnitY(dat.t)) / SplitPerMove() if GetUnitX(dat.t) > 0 then call SetUnitX(dat.c,GetUnitX(dat.c)+dat.r) else call SetUnitX(dat.c,GetUnitX(dat.c)-dat.r) endif if GetUnitY(dat.t) > 0 then call SetUnitY(dat.c,GetUnitY(dat.c)+dat.r) else call SetUnitY(dat.c,GetUnitY(dat.c)-dat.r) endif if IsUnitInRange(dat.c,dat.t,ActiveRange()) then set d = CreateUnit(dat.o,did(),GetUnitX(dat.t),GetUnitY(dat.t),bj_UNIT_FACING) call ShowUnit(d,false) call UnitAddAbility(d,sdid()) call SetUnitAbilityLevel(d,sdid(),GetUnitAbilityLevel(d,sid())) call IssueTargetOrder(d,"thunderbolt",dat.t) call UnitApplyTimedLife(d,'BTLF',2.) call SetUnitState(dat.c,UNIT_STATE_MANA,GetUnitState(dat.c,UNIT_STATE_MANA) + RageRegain(I2R(GetUnitAbilityLevel(dat.c,sid())))) set d = null set dat.b = true endif endif set i = 0 endloop if CollectionCharge.size() == 0 then call PauseTimer(ChargeMoveTimer) endif endfunction private function Check takes nothing returns nothing local timer t = GetExpiredTimer() local Charge dat = GetHandleInt(t,"struct") local real r = GetWidgetLife(dat.c) if not (dat.r == r) then call SimError(dat.o,"You are in combat") set dat.b = true endif call FlushHandleLocals(t) call ReleaseTimer(t) set t = null endfunction private function Conditions takes nothing returns boolean return GetSpellAbilityId() == sid() endfunction private function Actions takes nothing returns nothing local Charge dat = Charge.create() local timer t = null local location l1 = null local location l2 = null local boolean b = false set dat.c = GetTriggerUnit() set dat.t = GetSpellTargetUnit() set dat.o = GetOwningPlayer(dat.c) set l1 = GetUnitLoc(dat.c) set l2 = GetUnitLoc(dat.t) if DistanceBetweenPoints(l1,l2) < 240. then call SimError(dat.o,"You are too close") set b = true endif if b == false then set t = NewTimer() set dat.r = GetWidgetLife(dat.c) call SetHandleInt(t,"struct",dat) call TimerStart(t,CheckIfAttackedInterval(),false,function Check) endif call PolledWait(CheckIfAttackedInterval()) if dat.b == true or b == true then call IssueImmediateOrder(dat.c,"stop") call dat.destroy() else set dat.b = false set dat.oid = GetIssuedOrderId() if CollectionCharge.size() == 0 then call TimerStart(ChargeMoveTimer,mr(),true,function Periodic) endif call CollectionCharge.add(dat) endif set t = null call RemoveLocation(l1) call RemoveLocation(l2) set l1 = null set l2 = null endfunction function InitTrig_Charge 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 ) set t = null endfunction endscope JASS:function SH_DistanceBetweenLocs takes real px1, real py1, real px2, real py2 returns real local real dx = px2 - px1 local real dy = py2 - py1 return SquareRoot(dx * dx + dy * dy) endfunction Now here's the problem I don't know if it is the right way but it isn't working. Unfortunantly I cannot post the map with the spell on it. Since it is for Wc3WoW. Here's what the spell does: Quote:
The problem is that I cannot seem to move the hero casting the spell... Especially since it also still charge'sf the target moves that makes my job more difficult... Here's the spell in Wc3c resource database that is simliar. LINK I personally didn't want to rip off Airy Charge(The spell within that link) by modifying it and go and claim its my work and worser since Blade is no longer active. I read his notes + code. Didn't get a thing from it. Like in Blade's notes I used Life Drain for the trigger spell(Whch might not of been the best idea but what he made it work with tht spell) So anyone wants to help me. Hopefully I covered the aspects I needed to tell you guys P.S Its not sorted so... yea good luck -Av3n |
| 10-04-2007, 01:43 PM | #2 |
I got this one guys...... I'll edit with the help :) Btw, a textmacro is missing.... Also, a big struct (or more) are also missing. And another thing, what's up with the locations? :P I'll go on-topic now...... EDIT1: not (GetUnitCurrentOrder(dat.c) == dat.oid) == GetUnitCurrentOrder(dat.c) != dat.oid or dat.b == true == or dat.b And what's up with if GetUnitX(dat.t) > 0 then and if GetUnitY(dat.t) > 0 then? That would check if the unit is in the right-hand quarter of a map, was that what you wanted? |
| 10-04-2007, 10:12 PM | #3 |
That textmacro is something tht you dn't need to know about. Well anyway with if GetUnitX(dat.t) > 0 then is something is used to check if it in the right upper hand corner yea. I hate movement stuff -Av3n |
| 10-05-2007, 04:04 PM | #4 | |
Ok, yeah that's what I meant. What the hell is "rage"? You said you need to generate 9 rages. Also, what's 0.? Damn this is hard...... Guys, actually you can scratch this: Quote:
It was harder than I thought. I'm asking again, what's up with the locations? |
| 10-05-2007, 09:55 PM | #5 |
rage in WoW for Warrior equals mana. Locations... Yeah I'll have to fix tht up soon. Anyway anyone else up for it? -Av3n |
