[JASS] Need some expert jass help please *_*

Status
Not open for further replies.
Level 2
Joined
Oct 31, 2007
Messages
14
I'm having trouble with a couple abilities, they seem to work correctly, but have a small glitch. In the case of both, the problem is that, when you click the ability, and target the unit of which you'll be using the ability on, as your unit moves into place right BEFORE the ability goes off, if you order-move, the ability will malfunction.

In the case of this one, if you order-move when it's about to go off, you get warped to the middle of the map.

JASS:
function Trig_Akira_Func002C takes nothing returns boolean
if(not(GetSpellAbilityId()=='A024'))then
return false
endif
return true
endfunction

function Trig_Akira_Actions takes nothing returns nothing
if(Trig_Akira_Func002C())then
call TriggerSleepAction(0.10)
set udg_Akira=GetSpellAbilityUnit()
set udg_Loc2=GetUnitLoc(udg_Akira)
set bj_forLoopBIndex=1
set bj_forLoopBIndexEnd=GetUnitAbilityLevelSwapped('A024',udg_Akira)
loop
exitwhen bj_forLoopBIndex>bj_forLoopBIndexEnd
call UnitAddItemByIdSwapped('I00H',GetSpellAbilityUnit())
set bj_forLoopBIndex=bj_forLoopBIndex+1
endloop
call RemoveLocation(udg_Loc2)
set udg_Loc2=PolarProjectionBJ(GetUnitLoc(GetSpellTargetUnit()),50.00,GetUnitFacing(GetSpellTargetUnit()))
call SetUnitFacingToFaceUnitTimed(udg_Akira,GetSpellTargetUnit(),0.01)
call SetUnitPositionLocFacingLocBJ(udg_Akira,udg_Loc2,udg_Loc2)
call AddSpecialEffectLocBJ(udg_Loc2,"Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl")
call DestroyEffectBJ(GetLastCreatedEffectBJ())
call RemoveLocation(udg_Loc2)
endfunction

function InitTrig_Akira takes nothing returns nothing
set gg_trg_Akira=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Akira,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(gg_trg_Akira,function Trig_Akira_Actions)
endfunction

In this one, if you order-move when it's about to go off, the unit just keeps moving for awhile, it doesn't always stop in a pleasant place. =(

JASS:
function Trig_Akira_Choke_Func001C takes nothing returns boolean
if(not(GetSpellAbilityId()=='A09R'))then
return false
endif
return true
endfunction

function Trig_Akira_Choke_Actions takes nothing returns nothing
if(Trig_Akira_Choke_Func001C())then
call TriggerSleepAction(0.20)
set udg_Loc1=GetUnitLoc(GetSpellAbilityUnit())
set udg_AkiraLOC=PolarProjectionBJ(GetUnitLoc(GetSpellTargetUnit()),5.00,0)
set udg_AkiraChoke=GetSpellAbilityUnit()
call PauseUnitBJ(true,udg_AkiraChoke)
call SetUnitPathing(udg_AkiraChoke,false)
call RemoveLocation(udg_Loc1)
call SetUnitAnimation(udg_AkiraChoke,"attack")
call TriggerSleepAction((DistanceBetweenPoints(GetUnitLoc(udg_AkiraChoke),udg_AkiraLOC)/1500.00))
call PauseUnitBJ(false,udg_AkiraChoke)
call SetUnitPathing(udg_AkiraChoke,true)
set udg_AkiraChoke=null
call RemoveLocation(udg_AkiraLOC)
else
endif

function InitTrig_Akira_Choke takes nothing returns nothing
set gg_trg_Akira_Choke=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Akira_Choke,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(gg_trg_Akira_Choke,function Trig_Akira_Choke_Actions)
endfunction

Any help would be awesome =( thanks much
 
Level 11
Joined
Aug 25, 2006
Messages
971
Uh. Just a question, did you just convert GUI to jass for the fun of posting in this section of the forum? (Sarcasm)

Anyway I would switch the event to EVENT_PLAYER_UNIT_SPELL_CAST
besides that I don't see much wrong, except that maybe your "TriggerSleepAction" is clearing some of your variables... You should learn to use local variables before the TriggerSleepAction. This is because certain natives no longer return the correct units after a TriggerSleepAction, I know that 'GetTriggerUnit' happens to be one of the rare ones not effected.
 
Level 2
Joined
Oct 31, 2007
Messages
14
Eh...well...I'm more of a newb with jass than WE is, and these 2 abilities are driving me insane, I'll try changing EVENT_PLAYER_UNIT_SPELL_CAST, hopefully it works =( It just seemed a bit easier to see how jass works by making them in GUI and converting them. If it's the local variables thing, I'm in some trouble. >_< I'll have to look for a tut on local variables. Gonna go try it now, here's hopin', thanks.
 
Level 11
Joined
Aug 25, 2006
Messages
971
Try commenting out the waits, just to see what happens. Sometimes as I said before, waits screw up the return values of several natives. (Waits being TriggerSleepAction)
 
Level 2
Joined
Oct 31, 2007
Messages
14
Try commenting out the waits, just to see what happens. Sometimes as I said before, waits screw up the return values of several natives. (Waits being TriggerSleepAction)

*scratches head cluelessly* umm How do I "comment out" a wait? ^_^; *moves into a defensive stance for the inevitable backhand*
 
Level 11
Joined
Aug 25, 2006
Messages
971
Add a // before the 'TriggerSleepAction'. Anything on the same line to the right of a // will not be read by wc3. It'll just pass over that area like it doesn't exist. Its mainly used for adding comments, but you can comment out code to see what happens if a certain thing isn't there.
 
Last edited:
Level 19
Joined
Aug 24, 2007
Messages
2,888
:( converted GUI
and you need jass beginner not expert
damn too much BJ's unneeded globals
This is worst thing I saw ever
 
Level 2
Joined
Oct 31, 2007
Messages
14
:( converted GUI
and you need jass beginner not expert
damn too much BJ's unneeded globals
This is worst thing I saw ever

Why, thank you very much for that crucial piece of destructive criticism.
Yanno what, why do people like you even bother to place your hands on your keyboard for threads like mine? You have nothing useful to say, you don't offer any help, you just lay down insults. I'm rather certain I already said I was a newb with jass, sliding isn't one of the easier things to do for me. If you're not going to offer any help, don't offer anything at all. How messy the script happens to be is not the problem, it's the way it's malfunctioning. Yet someone always has to make some utterly useless comment about "oh too many of that" or "take that out it's ugly", or your own personal "this is the worst thing I saw ever" Two words for you, CONSTRUCTIVE CRITICISM, try it.
 
:( converted GUI
and you need jass beginner not expert
damn too much BJ's unneeded globals
This is worst thing I saw ever

The last comment was probably the only one that seemed rude.

But his facts are facts. I guess this is Spam, but more like Beef Jerky instead. Then again, all our posts are turkey, on the inside. Unless they are helpful, then they are steak/prime rib depending on how helpful they are.

ANYWAY, I highly suggest not converting GUI, unless you know what you are doing. Despite that, I'll make this post more useful. Add this function:
JASS:
call BJDebugMsg("HELLO!")

At the beginning of your actions function. Test your spell and it should say "HELLO!" on your screen.

Report your results here. This will prove it is not the initialization or condition's fault.
 
Level 2
Joined
Oct 31, 2007
Messages
14
Firstly, thanks a bunch donut and purge, I appreciate the help more than I can say, and after I get this working I'll be doing what ya said and trying to make all them BJ's natives instead. I seen another post somewhere about it and it didn't seem too hard, I already have Jasscraft.

Secondly, I did as ya said and added
Code:
call BJDebugMsg("HELLO!")
at the beginning of the actions function, for both the abilities I listed that I'm having trouble with, and tested the abilities, and it did show HELLO! on the screen as I activated the abilities.

Also, I don't know if this will come as any use, but I was told by someone else, in reference to the first ability, that if a unit is moved to the middle of the map when moving as an ability casts, it means that it's returning a null location (I'm not sure what that means exactly, if that's the case, but maybe it means something to you). If a location returns null, is that like, a location that was used in the trigger in question but was removed? Like...
Code:
call RemoveLocation(udg_Loc2)
would make udg_Loc2, null, right?

Once again, I really appreciate the help, you guys must come across SCORES of newbs asking jass questions. I hope eventually I'll be on the answering end of questions like these, instead of asking. :hohum:
 
Level 11
Joined
Aug 25, 2006
Messages
971
Hes correct of course. It won't set the value to null, but the variable will remove the 'point' like removing a unit. So if you call it after you've done that it'll return the center of the map. You don't need to null it for globals though.
 
Last edited:
Status
Not open for further replies.
Top