| 09-20-2007, 02:00 PM | #1 |
Hello everybody here and this is my first post here. I have a small innocent problem while I'm coding a very simple autocast arrow ability. You can consider it an ability which deals 0.5x the caster's agility in damage when the missile hits the target (my version is a little more but the extra part does not affect). Currently I can achieve the effect except for the time - I am using the "Unit is Attacked" event, which I believe is the source of the problem. Can anyone please help me on this? Thanks very much. If you think I didn't describe it clearly enough, just point out and I'll try my best to make myself understood. |
| 09-20-2007, 06:06 PM | #2 |
This is quite hard, attack hit detection is still a very unresolved area. But there are plenty of good alternatives out there that may require some heave Jass but they do exist, look for attack hit detection in the search and you'll see how complicated it can get... In the case of your spell you may take advantage of cold arrows since it uses a buff, but you still need a global got damaged event which if used without care can lead to a lot of issues (leaks, ref counter corruption, etc) |
| 09-20-2007, 09:22 PM | #3 |
my recommendation is using a modified cold arrows like vex said and going off the buff by doing something like this (if it does not need to be MUI) add to your ability trigger Trigger: ![]() turn on trigger - damage check![]() set damage_unit = attacked unit![]() wait until damaged = true checking every .1 seconds![]() set damaged = false![]() turn off trigger - damage checkTrigger: ![]() trigger - damage check![]() event![]() every .1 seconds of game time![]() condition![]() actions![]() if damaged_unit has buff = cold arrows buff then set damaged = true |
| 09-20-2007, 10:25 PM | #4 |
off topic Botanic, you gotta learn to use [trigger] tags on topic try posting your code so we can see if anything else is wrong |
| 09-20-2007, 10:30 PM | #5 |
I added trigger tags :/ however I hate the white page thing that I always get ~.~ |
| 09-21-2007, 02:45 AM | #6 |
Trigger: aaaedit: I would blame a problem in your end for this. |
| 09-21-2007, 03:53 AM | #7 |
it is true I dont have the GUI syntax memorized and 98% of the time I am not on a comp with wc3 and so that leaves 2 options 1) dont post because it will be ugly or 2) post and have it be as readable as possible :/ (and honistly i like txt better then the white pages |
| 09-21-2007, 04:41 AM | #8 |
Hmm, do you mean that I should place a buff and then check if the target has the buff when damaged? This should be good, I'll try it. Thanks! EDIT: I've met a problem. If I order the caster to attack the target with the arrow on, and just as she raises her bow (she's an archer), I cancel the attack. And repeat this several times. And next if I really attack the target with the arrow, it gets huge damage (probably the sum of all these canceled arrows). How should I solve this problem? |
| 09-21-2007, 05:17 AM | #9 |
Add an Start timer Damaged with duration of 1 second (need to modify it most likely to as small a value as possible it will be the max time an attack will take) wait (till damaged = true) OR (timer expires Damaged) checking every .1 seconds if damaged = false then skip remaining actions Just remember to clean the leaks afterwords EDIT heh sry didn't think about that problem :P also this wouldnt be foolproof I will try to think of a better fix :/ EDIT2: I GOT IT ok forget everything above just ad an "Turn off this trigger" at the beginning of the trigger and an "Turn on this trigger" at the end that should work ^.^ EDIT3 ok well ya... that could add to a lotta lag eventually so I recommend doing what I first mentioned as well as the turn on turn off thing just make the time like 10 seconds and make the "if damaged = false then skip remaining actions" into "if damaged = false then skip remaining actions AND turn on this trigger" |
| 09-22-2007, 09:37 PM | #10 |
ah I missunderstood your post thought you were talking of a bug that made the site go to a blank page whenever you used GUI tag. It is meant to be used with copy as text. I guess that if you don't know the syntax of GUI well it is better not to mimic it and just use psuedo code... |
| 09-27-2007, 11:10 AM | #11 |
@botanic: Well I'm kinda confused... In fact I prefer looking at JASS... could you please just write the JASS code? It will be greatly appreciated. |
| 09-27-2007, 09:59 PM | #12 |
Zomigod that is a first.... Can I Please Have JASS... nice ^.^ give me a few mins :P |
| 09-27-2007, 10:37 PM | #13 |
well thats a first... "can I please have JASS" ^.^ JASS:function ouch takes unit u unit a integer i returns integer if UnitHasBuffBJ(u, 'buff') == true then call UnitDamageTargetBJ(a, u, ect...) return 10 endif return i endfunction function actions takes nothing returns nothing local unit a = getattackingunit() local unit u = get targetunit() local integer i = 0 loop exitwhen i = 10 set i = i+1 set i = ouch(u, a, i) call polledwait(.1) endloop endfunction Its not optimized with timers ect but you should get the idea. Just remove the BJ's and use a timer instade of a wait and it should be good to go ^.^ |
| 09-29-2007, 11:12 AM | #14 | |
Quote:
|
| 09-29-2007, 11:20 AM | #15 |
Personally if it was me I would keep the wait not worth the trouble and timers bug me as well so... shhh don't tell anyone tho they will flog us, and burn us at the stake. ^.^ Honestly one 1 second wait wont effect anything overall in your map, Polledwait is the same wait that the GUI uses and I have used a LOT more then that before The main thing for me at least about timers are that they are more accurate. |
