| 02-08-2009, 04:51 AM | #1 |
JASS:// +------------------------------------------------------------+ // | | // | -=-=- Knockback -=-=- | // | Requires Jass NewGen | // | | // +------------------------------------------------------------+ // | | // | Blinks onto a target enemy, dealing damage. | // | After a period of time, your Hero blinks back | // | to their original position, dealing damage in | // | a 450 AoE around where he lands. Casting | // | range improves per level. | // | | // +------------------------------------------------------------+ // | | // | -=-=- How To Implement -=-=- | // | 1. Create a trigger named Knockback | // | 2. Copy the text from this map's trigger | // | 3. Copy/paste it into your map's Knockback trigger | // | 4. Copy all the abilities to your map. | // | 5. Copy all the units to your map. | // | 6. Enjoy! | // | | // +------------------------------------------------------------+ // | | // | -=-=- Credits -=-=- | // | Credits are not needed, but appreciated | // | Just don't claim this as yours | // | | // +------------------------------------------------------------+ scope Knockback initializer KBInit // +-------------------------------------+ // | -=-=- MODIFY HERE -=-=- | // | -=-=- MODIFY HERE -=-=- | // | -=-=- MODIFY HERE -=-=- | // +-------------------------------------+ globals private constant integer KBID = 'BOLT' // Rawcode of dummy spell private constant real SLIDE_SPEED = 700 // Slide speed private constant string KBEFFECT = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl" // SFX of the targeted spell unit private constant boolean KillTrees = true // Kill trees or not? private constant string BLOOD = "Objects\\Spawnmodels\\Human\\HumanLargeDeathExplode\\HumanLargeDeathExplode.mdl" // SFX when unit comes within the targeted spell unit who got hit private constant real TreeRADIUS = 200 // Range needed for a tree to be beside targeted unit before tree dies private constant real UnitRADIUS = 200 // Range needed for a unit to be beside targeted unit before they take damage private boolexpr KBDAMGER endglobals private function KBDISTANCES takes integer level returns integer return level * 300 // How far the unit will get knocked backed endfunction private function KBDAMAGE takes integer level returns integer return level * 5 // Damage the targeted unit takes endfunction // +------------------------------------------------+ // | -=-=- DO NOT TOUCH PAST HERE -=-=- | // | -=-=- DO NOT TOUCH PAST HERE -=-=- | // | -=-=- DO NOT TOUCH PAST HERE -=-=- | // +------------------------------------------------+ private function KBConditions takes nothing returns boolean return GetSpellAbilityId() == KBID // the ID of dummy spell endfunction private function KillTree takes nothing returns nothing call KillDestructable(GetEnumDestructable()) endfunction struct Knock unit target unit caster real x1 real y1 real cos real sin real DISTANCE real angle endstruct private function KBFilters takes nothing returns boolean return true endfunction private function KBKnockback takes nothing returns boolean local Knock data = TT_GetData() local unit t local real x = GetUnitX(data.target) local real y = GetUnitY(data.target) local location CasterLoc = GetUnitLoc(data.target) //local group g = GetUnitsInRangeOfLocMatching(UnitRADIUS, CasterLoc, DAMGER) // Start of what I added local group g = CreateGroup() call GroupEnumUnitsInRangeOfLoc(g, CasterLoc, UnitRADIUS, KBDAMGER) call DestroyBoolExpr(KBDAMGER) // End of what I added set x = x + data.cos * TT_PERIOD * SLIDE_SPEED set y = y + data.sin * TT_PERIOD * SLIDE_SPEED loop set t = FirstOfGroup(g) exitwhen t == null call GroupRemoveUnit(g, t) if IsUnitEnemy(data.caster, GetOwningPlayer(t)) then call UnitDamageTarget(data.caster, t, KBDAMAGE(GetUnitAbilityLevel(data.caster, KBID)), false, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS) call DestroyEffect(AddSpecialEffect(BLOOD,GetUnitX(t),GetUnitY(t))) endif endloop if KillTrees == true then call EnumDestructablesInCircleBJ(TreeRADIUS, CasterLoc, function KillTree) endif call SetUnitPosition (data.target, x, y) set data.DISTANCE = data.DISTANCE - TT_PERIOD * SLIDE_SPEED call RemoveLocation(CasterLoc) call DestroyGroup(g) set g = null set CasterLoc = null set t = null if data.DISTANCE <= 0 then call data.destroy () return true endif return false endfunction private function KBActions takes nothing returns nothing local Knock data = Knock.create() local real x1 local real y1 local real x2 local real y2 local real angle local integer stomp = 7 set data.caster = GetTriggerUnit() set data.target = GetSpellTargetUnit() set x1 = GetUnitX (data.caster) set y1 = GetUnitY (data.caster) set x2 = GetUnitX (data.target) set y2 = GetUnitY (data.target) set angle = Atan2 (y2 - y1, x2 - x1) set data.DISTANCE = KBDISTANCES(GetUnitAbilityLevel(GetTriggerUnit(), KBID)) set data.cos = Cos (angle) set data.sin = Sin (angle) call TT_Start (function KBKnockback, data) loop exitwhen stomp == 0 call TriggerSleepAction(GetRandomReal(0.1,0.15)) call DestroyEffect(AddSpecialEffect(KBEFFECT,GetUnitX(data.target),GetUnitY(data.target))) set stomp = stomp - 1 endloop endfunction //=========================================================================== private function KBInit takes nothing returns nothing local trigger t = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT) call TriggerAddCondition(t, Condition(function KBConditions)) call TriggerAddAction(t, function KBActions) set KBDAMGER = Filter(function KBFilters) endfunction endscope So, Restricting the amount of blood / sfx created on a 0.03 second timer? How would I be able to do that? JASS:call DestroyEffect(AddSpecialEffect(BLOOD,GetUnitX(t),GetUnitY(t))) |
| 02-08-2009, 04:58 AM | #2 |
Could you explain what you want to have happen in a bit more detail. I'm not entirely sure how to aproach this without knowing what you actually need. |
| 02-08-2009, 05:03 AM | #3 |
What I mean is how do I limit the amount of blood sfx , since 0.03 second units within the targeted unit will create a sfx meaning 100+ sfx which will lag, I want to limit each unit's number of blood sfx to 3. |
| 02-08-2009, 05:14 AM | #4 |
The most simple way is random roll. this will do best ever if you dont know jass. JASS:if GetRandomInt(1,10) == 1 then call DestroyEffect(AddSpecialEffect(BLOOD,GetUnitX(t),GetUnitY(t))) endif |
| 02-08-2009, 05:19 AM | #5 |
That post wasn't so helpful.. |
| 02-08-2009, 05:21 AM | #6 |
Okay first save a value which is one third the maximum dist; JASS:real OneThirdMaximumDist if(ModuloReal(CurrentDistance, OneThirdMaximumDistance) == 1))then //do endif Should work. |
| 02-08-2009, 05:50 AM | #7 |
What I want is that when the spell target unit gets knocked back , enemy units who are in the range beside the spell target unit , will get damaged which is done, the SFX is done but there is too many as 0.03 second creates really huge sfx, i want to limit the sfx to 3 per unit. |
| 02-08-2009, 06:03 AM | #8 |
0.03 is 33 FX per second, 10x roll make it 3.3FX per second. Where is problem? |
| 02-08-2009, 06:13 AM | #9 |
Ok works fine now + REP |
| 02-08-2009, 05:57 PM | #10 |
I think wraith just had trouble understanding you. From the sentences he was making I could barely understand what he wanted. |
| 02-08-2009, 11:29 PM | #11 | |
Quote:
|
