| 02-05-2007, 05:07 AM | #1 | |||
For lack of a better name, here is my On Attack Template 1.2 Basically this is a system that allows GUI users to easily use an attack detect engine type system for attacks and abilities. It also allows JASS users, from the novice to the the expert, to detect attacks w/o using orbs, or for every unit on the map at all times, and do whatever you want to them w/o having to manually detect it each time yourself. Quote:
This is easily abusable, using an attack/stop series of orders, to get your ability to fire over and over w/o actually ever attacking the unit. Also, for ranged units, the previous would do your effects when the target is attacked, which is before it actually takes damage, thus it would look odd, casting a spell on the target, or creating a text tag or something, while your attackers projectile is still flying through the air at its target. Quote:
I am not too sure. I like it, and I do not like using attack detect engines, since it removes orbs from your game, and it detects damage for all units on your map at all times. This only does so when you want it to, and I personally find it no harder to use this system with the On_Attack_Template_Function call then it is to add your function to a damage que used by damage detection engines. Is this way better? Maybe, maybe not, but this is how I like do it :). Quote:
Well, for GUI and JASS users alike, it gives you the option to detect the damage from an attack, and , using the first two functions, cast an ability on the target at a specified level, or deal extra damage to the target, using any functions you want to get a real amount. For users with sufficient JASS knowledge enabling them to write their own functions, it allows you to do basically whatever you want to the target once they take damage from the attack. You can even check for the buff of an activatable orb effect, such as poison arrows, and only deal effects when the unit is hit by said attack. In any case, I think it may be a neat, unique system, that could very well help people with their map creation efforts. Included is what I consider a very thorough read me, which covers all the functions, and a sample ability for each. Version History:
system code:library OnAttackTemplate needs CSSafety, CSCache //=====On Attack Template 1.2=====\\ //Configure these two options how you wish globals private constant real Time = 2. //Timer after the attacj to disreguard effects private constant integer Caster = 'n000' //Rawcode of your dummy caster unit endglobals //No more touching past this point //========================================================================================== //Needed struct private struct data unit atkr timer t trigger trig string type integer abilid integer lvl string order real dam boolean show string func method onDestroy takes nothing returns nothing call ReleaseTimer(.t) call DestroyTrigger(.trig) endmethod endstruct //Main effects function private function On_Attack_Template_Effects takes nothing returns boolean local data d = GetCSData(GetTriggeringTrigger()) local unit targ = GetTriggerUnit() local unit dum local texttag t if GetEventDamageSource()==d.atkr and GetEventDamage()>.01 then call DisableTrigger(d.trig) if d.type=="spell" then set dum = CreateUnit(GetOwningPlayer(d.atkr),Caster,GetUnitX(d.atkr),GetUnitY(d.atkr),0.) call UnitAddAbility(dum,d.abilid) call UnitApplyTimedLife(dum,'BTLF',2.) call SetUnitAbilityLevel(dum,d.abilid,d.lvl) call IssueTargetOrder(dum,d.order,targ) set dum = null elseif d.type=="damage" then call UnitDamageTarget(d.atkr,targ,d.dam,false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null) if d.show then set t = CreateTextTag() call SetTextTagText(t, "+"+I2S(R2I(d.dam))+"!", 0.025) call SetTextTagPosUnit(t, targ,15) call SetTextTagColor(t, 255, 0, 0, 255) call SetTextTagVelocity(t, 0, .03) call SetTextTagVisibility(t, true) call SetTextTagFadepoint(t, 2.) call SetTextTagLifespan(t, 2.) call SetTextTagPermanent(t, false) set t = null endif else call ExecuteFunc(d.func) endif endif set targ = null return false endfunction //To remove the stored trigger if needed private function On_Attack_Template_End takes nothing returns nothing local data d = GetCSData(GetExpiredTimer()) call d.destroy() endfunction //Functions you can call and do things with function On_Attack_Template_Function takes unit attacker, unit target, string func returns nothing local data d = data.create() set d.trig = CreateTrigger() call TriggerRegisterUnitEvent(d.trig,target,EVENT_UNIT_DAMAGED) call TriggerAddCondition(d.trig,Condition(function On_Attack_Template_Effects)) call SetCSData(d.trig,d) set d.atkr = attacker set d.func = func set d.type = "function" set d.t = NewTimer() call SetCSData(d.t,d) call TimerStart(d.t,Time,false,function On_Attack_Template_End) endfunction function On_Attack_Template_Damage takes unit attacker, unit target, real damage, boolean show returns nothing local data d = data.create() set d.trig = CreateTrigger() call TriggerRegisterUnitEvent(d.trig,target,EVENT_UNIT_DAMAGED) call TriggerAddCondition(d.trig,Condition(function On_Attack_Template_Effects)) call SetCSData(d.trig,d) set d.atkr = attacker set d.dam = damage set d.show = show set d.type = "damage" set d.t = NewTimer() call SetCSData(d.t,d) call TimerStart(d.t,Time,false,function On_Attack_Template_End) endfunction function On_Attack_Template_Spell takes unit attacker, unit target, integer abil, integer lvl, string order returns nothing local data d = data.create() set d.trig = CreateTrigger() call TriggerRegisterUnitEvent(d.trig,target,EVENT_UNIT_DAMAGED) call TriggerAddCondition(d.trig,Condition(function On_Attack_Template_Effects)) call SetCSData(d.trig,d) set d.atkr = attacker set d.abilid = abil set d.lvl = lvl set d.order = order set d.type = "spell" set d.t = NewTimer() call SetCSData(d.t,d) call TimerStart(d.t,Time,false,function On_Attack_Template_End) endfunction endlibrary Enjoy! |
| 02-05-2007, 06:14 AM | #2 |
Handy. This is the first Attack Detect system i've seen that didn't require any JASS knoweledge to use and\or implement. |
| 02-05-2007, 12:37 PM | #3 |
This system falters if you cast a damaging spell on the target within the window of attack. It's neat though, it functions the same as the orb system just lacks the spell/attack differentiation the orb system has. So... It might be useful for a select few people. |
| 02-05-2007, 12:45 PM | #4 |
Old attackdetect engine used this method instead of the orb one, I am not sure which one is better |
| 02-05-2007, 01:39 PM | #5 | |||
Quote:
that was my intent, allowing GUI users to be able to detect attacks, as well as JASS users to be able to do so as well easily Quote:
agreed, note the name, On Attack Template, heh, I chose my words with that in mind. I would like to do some tests with that, since there is a 2 second window there, to see if I could get a spell cast off in that frame time, which does damage, however I think it may be more of a problem if you are actually trying to do that, o well **I could however, create another local trigger with the event EVENT_UNIT_SPELL_CAST, since if the unit is casting a spell, even not the effect, its clearly not attacking, and disable the damage trigger through that, but then that may screw up ranged attackers..so... Quote:
I figured as much. The new method would probably be better if you have a need to detect all damage done to every unit on your map at all times, and be able to discern between it being spell or attack. However, for what I believe most maps to have, is a need for a few abilities, or there abouts, to be able to detect those attacks, and this enables both JASS and GUI users to do so. |
| 02-05-2007, 02:10 PM | #6 |
I was talking about not using orbs. |
| 02-05-2007, 02:36 PM | #7 | |
Quote:
Just a note, this also applies to all manner of DoT spells etc. I don't, however, have time to actually check anything tonight >.< (essays ftl). |
| 02-06-2007, 02:57 PM | #8 |
Well I just played around with this. Something in the test map itself does show the flaw with this (for example, a throat-cut-thing'd tauren chieftan was running towards by hero, I started an attack and then he was damaged by the DoT. The mass-damage-based-on-life-lost thing triggered and instantly killed him, without my attack even firing). [edit - ignore this, I forget that you need a new event each time you attack] |
| 02-06-2007, 09:28 PM | #9 | |
Quote:
yea it makes sense what you are saying, that is my fault I could easily have made a dummy unit that did the damage, and removed him later, to remove the chance of that happening, but I do get what you are saying |
| 02-10-2007, 05:23 PM | #10 |
ok well just a bump, it has been a few days here :) |
| 02-11-2007, 05:58 PM | #11 |
This still has a major bug, in that stop spamming will create many detection triggers and a subsequent attack will fire all of these at once. We can't have a system with a major flaw in its basic operation. |
| 02-11-2007, 06:52 PM | #12 | ||
Quote:
Quote:
Post deleted. |
| 02-11-2007, 07:32 PM | #13 |
o well, better luck next time, I created this as a more GUI type deal anyway, so they can have a system as well, and there are not man GUIers here anyhow to the graveyard she goes |
| 02-11-2007, 09:42 PM | #14 |
Really? You just give up? How hard might it be to fix the bug? Is "GUI type deal" really an excuse to have this bug? |
| 02-12-2007, 12:45 AM | #15 |
is it an excuse... well this the only other method I can think of to make an attack detect engine work(other then orbs, and I was trying to stay away from those, which was also another purpose), and with GUI at that, where the current orb method will not work, unless I made this compatible with the current orb effect ones, and thus making it not stand alone, and using orbs with that said, i cannot think of a way to work around that bug using this method I am, maybe I am not thinking outside the box, or maybe i am just missing something obvious, or maybe there is none, whatever the case may be, i am not sure what you want me to do |
