| 11-10-2006, 04:52 AM | #1 |
OK here is my problem, I found a jass trigger for jumping but it has excess code(I can see somthing about towers...) in it and i dont know where to begin. I am jass illiterate and i need to know what parts are required and which parts are not, also i need to know what to change to make it relevant to my map aka variables.(Switch $$$ with %%%)(Create &&&) Basicly i want to be able to jump (never to higher ground) and get hurt / slowed when falling from too high. Thanks in advance, I really appreciate it. JASS:function JumpDamage takes nothing returns nothing local unit u = GetHandleUnit(null,"jumpunit") call SetHandleInteger(null,"jumpunit",0) call SetUnitAnimation(u,"death") call UnitDamageTargetBJ(u,u,120.0,ATTACK_TYPE_MELEE,DAMAGE_TYPE_NORMAL) call UnitAddAbility(u,'A05S') call ShiftMoveSpeed(u,-80.0) call TriggerSleepAction(0) call ResetUnitAnimation(u) call PolledWait(2.5) call ShiftMoveSpeed(u,30.0) call PolledWait(2.5) call UnitRemoveAbility(u,'A05S') call ShiftMoveSpeed(u,50.0) set u = null endfunction function InsideTower takes unit u returns boolean local real x = GetUnitX(u) local real y = GetUnitY(u) return RectContainsCoords(gg_rct_Tower1,x,y) or RectContainsCoords(gg_rct_Tower2,x,y) or RectContainsCoords(gg_rct_Tower3,x,y) or RectContainsCoords(gg_rct_Tower4,x,y) or RectContainsCoords(gg_rct_Tower5,x,y) or RectContainsCoords(gg_rct_Tower6,x,y) endfunction function hiphop_callback_inner takes timer t returns nothing local integer i = GetHandleInteger(t,"i") local integer momentum = GetHandleInteger(t,"momentum") local real x0 = GetHandleReal(t,"x0") local real y0 = GetHandleReal(t,"y0") local real x1 = GetHandleReal(t,"x1") local real y1 = GetHandleReal(t,"y1") local integer maxiter = R2I(SquareRoot((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0))/20) local real s = i/(maxiter + 0.001) local unit u = GetHandleUnit(t,"u") if t==null then call BJDebugMsg("Bunny hop timer in hell") elseif u==null then call FlushHandleLocals(t) call DestroyTimer(t) elseif i>maxiter then call FlushHandleLocals(t) call DestroyTimer(t) call SetUnitFlyHeight(u,0.0,1000.0) call SetUnitPathing(u,true) if momentum==1 then call UnitRemoveAbility(u,'A07O') //Footsteps animation call UnitRemoveAbility(u,'A05O') //Jump failsafe endif if GetTerrainCliffLevel(x0,y0)-GetTerrainCliffLevel(x1,y1)>1 or GetUnitAbilityLevel(u,'Bslo')>0 or InsideTower(u) then call SetHandleHandle(null,"jumpunit",u) call ExecuteFunc("JumpDamage") endif else call PauseUnit(u,true) call SetUnitX(u,(1.0-s)*x0 + s*x1) call SetUnitY(u,(1.0-s)*y0 + s*y1) call PauseUnit(u,false) call SetHandleInteger(t,"i",i+1) endif set u = null endfunction function hiphop_callback takes nothing returns nothing call hiphop_callback_inner(GetExpiredTimer()) endfunction function hippityhoppity takes unit u, real x0, real y0, real x1, real y1, integer momentum returns nothing local integer t = H2I(CreateTimer()) local integer current = udg_Second if current-udg_JumpLimit!=0 then call AttachSoundToUnit(gg_snd_Jump,u) call SetSoundVolume(gg_snd_Jump,127) call StartSound(gg_snd_Jump) else set udg_JumpLimit=current endif call UnitAddAbility(u,'A05O') call UnitRemoveAbility(u,'A05O') call SetUnitPathing(u,false) call SetUnitFlyHeight(u,45.0,500.0) call SetHandleHandle(I2T(t),"u",u) call SetHandleReal(I2T(t),"x0",x0) call SetHandleReal(I2T(t),"y0",y0) call SetHandleReal(I2T(t),"x1",x1) call SetHandleReal(I2T(t),"y1",y1) call SetHandleInteger(I2T(t),"momentum",momentum) call SetHandleInteger(I2T(t),"i",1) call TimerStart(I2T(t),0.03,true,function hiphop_callback) endfunction function Jump takes nothing returns nothing local unit u = GetTriggerUnit() local location l = GetSpellTargetLoc() local real x0 local real y0 local real x1 = GetLocationX(l) local real y1 = GetLocationY(l) local real dx local real dy local real xm = GetUnitX(u) local real ym = GetUnitY(u) local real distance local real maxjump = 270.0 local integer currentlevel local integer momentum = 0 call PolledWait(0.3) set x0 = GetUnitX(u) set y0 = GetUnitY(u) set currentlevel = GetTerrainCliffLevel(x0,y0) if SquareRoot(((xm-x0)*(xm-x0)+(ym-y0)*(ym-y0))+0.01)>25.0 then //achieved momentum set momentum = 1 set maxjump=maxjump+65.0 endif set dx = x0-x1 set dy = y0-y1 set distance = SquareRoot(((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1))+0.01) if currentlevel==GetTerrainCliffLevel(x1,y1) then set maxjump=maxjump-50.0 endif if GetSpellAbilityId()=='A05N' then //pet jump bonus set maxjump=maxjump+100.0 endif if distance>maxjump then set x1 = x0 - dx*maxjump/distance set y1 = y0 - dy*maxjump/distance endif if currentlevel<GetTerrainCliffLevel>GetRectMaxX(bj_mapInitialPlayableArea) or x1<GetRectMinX>GetRectMaxY(bj_mapInitialPlayableArea) or y1<GetRectMinY(bj_mapInitialPlayableArea)) then //target point is too high or out of map call IssueImmediateOrder(u,"holdposition") else if momentum==1 then call UnitAddAbility(u,'A07O') //Footsteps animation endif call hippityhoppity(u,x0,y0,x1,y1,momentum) endif call RemoveLocation(l) set l = null set u = null endfunction function JumpConditions takes nothing returns boolean local integer i = GetSpellAbilityId() return (i=='A05P' or i=='A05N' or i=='A05X' or i=='A07X') and GetUnitAbilityLevel(GetTriggerUnit(),'B001')<1 and GetUnitAbilityLevel(GetTriggerUnit(),'Beng')<1 //no suppressive fire and nanosteel net endfunction function InitTrig_Jump takes nothing returns nothing set gg_trg_Jump = CreateTrigger() call TriggerAddCondition(gg_trg_Jump,Condition(function JumpConditions)) call TriggerAddAction(gg_trg_Jump,function Jump) endfunction |
| 11-10-2006, 05:04 AM | #2 |
Nice to see people reusing code from Aftermath. You need variables for each udg_* and you need Kattana's attached var script from wc3jass. Then you need to learn JASS and understand the code so that you're able to maintain it. |
| 11-10-2006, 07:08 PM | #3 |
Thank you for replying, but i am still quite clueless. I obtained kattanas local handle variables script(I think thats what you ment by attached var script), I also made the "Seconds" and "JumpLimit" INT variables as you advised. I wasnt told however which parts of the code are irrelevant and how to make it work. Obviously it is my lack of jass knowledge that is preventing it from working (I am just starting to learn about the basics). If you could point me in the right direction again it would be very helpful. Giving me the anwser would be nice as well. : P (As much as you want me to learn jass it doesnt happen in a day, nor will i know jass by solving this problem, I will learn just as much if i saw the correct version and looked the differences) Again, Thank you for replying, it helps so much. ------ Almost got it to Work except one part where it "expected a"(". and 2 missing endif's (which are there...i suspect it has somthing to do with the first problem) |
