| 10-07-2006, 07:27 AM | #2 |
should work, but it leaks a couple of locations and it won't cause the spell to miss. |
| 10-07-2006, 07:33 AM | #3 |
Of course, JASS and X and Y co-ordinates as well as locals would be far better. Though if you are worried about performance, get rid of the location leaks and have only one call to get the player number (then use a temp global), as that is quite a slow call. If you could, it would also be better to avoid the SquareRoot function in getting the distance. Probably some way of doing it without needing it. |
| 10-07-2006, 09:41 AM | #4 | |
EDIT: Now hits when distance <= 100 JASS:function CheapShot_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'A000' // This is the same as using (Ability being cast) Equal to Cheap Shot // A000 is the rawcode of the Cheap Shot ability in your Object Editor. // You probably know this. endfunction function CheapShot takes nothing returns nothing local unit caster = GetTriggerUnit() local unit target = GetSpellTargetUnit() local real dx = (GetUnitX(target) - GetUnitX(caster)) local real dy = (GetUnitY(target) - GetUnitY(caster)) local real distance = SquareRoot(dx * dx + dy * dy) // sorry, but it's a necessary evil, unless there's some other way local integer rand = GetRandomInt(1, 100) local integer accuracy = ((R2I(distance) - 100) / 4) if ((accuracy >= 1) and (accuracy <= rand)) or (distance <= 100) then // do damage stuff here call UnitDamageTarget(caster, target, 500.0, true, true, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS) else call AddFadingTextTag("Miss!", 9.0, GetUnitX(caster), GetUnitY(caster), 40.0, 3, 255, 0, 0, 255) endif set caster = null set target = null endfunction //=========================================================================== function InitTrig_CheapShot takes nothing returns nothing set gg_trg_CheapShot = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(gg_trg_CheapShot, EVENT_PLAYER_UNIT_SPELL_EFFECT) call TriggerAddCondition(gg_trg_CheapShot, Condition(function CheapShot_Conditions)) call TriggerAddAction(gg_trg_CheapShot, function CheapShot) endfunction This will miss when distance between caster and target is less than 100 (0% accuracy). You can change your accuracy formula though. Also, add this to your custom script section (when using the JASSed CheapShot):
It's made by Blade.dk, though I edited some of it, so give credit to Blade (if you use it). Sorry, can't help you in GUI >_< |
| 10-07-2006, 01:01 PM | #5 | |
Quote:
|
| 10-07-2006, 01:22 PM | #6 | |
Quote:
|
| 10-08-2006, 02:41 AM | #7 |
Thank you for the help! +rep <3 |
