Spell Blade Fury

BRUTAL

I'm working
Reaction score
118
Blade Fury

Requires AIDS, Damage, Event, GTrigger, Key Timers 2; all included in the map.

Spell Description: Baraka repeatedly swings his arms in an up-and-down motion 10 times, slashing his opponent.
Levels 1-10, damage is (50+(10*n))+str [n is the level of the spell]

Screen shot:
21091740.png


Code:
JASS:
// Blade Fury by BRUTAL.
// Requires AIDS, Damage, Event, GTrigger, and KT2.
// Credits are welcome but not necessary.
// November 4th 2009.

scope bladefury initializer init

globals
    private constant integer ID='A000' // ID of the blade fury spell.
    private constant integer ID2='A002' // ID of the stun spell to stun the hero.
    private constant integer BUFF='B001' // ID of the stun spell buff.
    private constant integer DUMMY_ID='h000' // ID of the transparent dummy units.
    private constant integer DUMMY_ID2='h001' // ID of DUMMY to cast stun.
    private constant integer MAX_HITS=20 // Maximum number of hits.
    private constant real PERIOD=.02 // Period of the KT2 timer.
    private constant real ALPHA_PERCENT=79. // How transparent the dummies will be.
    private constant real AOE=250. // Area of effect of possible targets.
    private constant string SFX="Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl" 
    // Path of the sfx created on slashed enemies.
    private constant attacktype ATK_TYPE=ATTACK_TYPE_HERO // Attack type.
    private unit DUMMY // The global dummy unit.
    // Setting the values for the below strings can be found in the init function.
    private string array HIT_SOUND // The slice sounds played when an enemy is hit.
    private string array MISS_SOUND // The miss sounds played when there are no enemies.
    private group BFgroup=CreateGroup()
    private integer filter
endglobals

private function DAMAGE takes integer level, unit u returns real
    return 50.+10.*level+I2R(GetHeroStr(u,true))
endfunction

private function Sound takes unit u, string s returns nothing
    if u!=null then
        set bj_lastPlayedSound=CreateSound(s,false,false,false,10,10,"")
        call StartSound(bj_lastPlayedSound)
        call SetSoundVolume(bj_lastPlayedSound,50)
        call AttachSoundToUnit(bj_lastPlayedSound,u)
        call KillSoundWhenDone(bj_lastPlayedSound)
    endif
endfunction

private function Text takes unit u, real damage returns nothing 
    local texttag tt=CreateTextTag() // This creates floating text.
    if u!=null then
        call SetTextTagText(tt,I2S(R2I(damage)),.023)
        call SetTextTagPosUnit(tt,u,-125)
        call SetTextTagColor(tt,255,0,0,255)
        call SetTextTagPermanent(tt,false)
        call SetTextTagVelocity(tt,0,.044)
        call SetTextTagLifespan(tt,3)
        call SetTextTagFadepoint(tt,2)
    else
        call DestroyTextTag(tt)
    endif
    set tt=null
endfunction

private struct Data
    unit caster
    unit target
    unit randomu
    real x
    real y
    real attacktimer
    integer i
    integer hitcount=0
    integer ticks=17*MAX_HITS
    group dummy=CreateGroup()
    
    static method create takes unit u, unit t returns Data
        local Data data=Data.allocate()
        local integer i=0
        local unit d 
        set data.caster=u
        set data.x=GetUnitX(u)
        set data.y=GetUnitY(u)
        set data.target=t
        call SetUnitTimeScale(u,3)
        call IssueTargetOrder(DUMMY,"thunderbolt",u)
        loop
        exitwhen i==2
            set d=CreateUnit(GetOwningPlayer(u),DUMMY_ID,data.x,data.y,GetUnitFacing(u))
            call SetUnitTimeScale(d,1.5)
            call SetUnitVertexColor(d,255,255,255,R2I(2.55*(100.-ALPHA_PERCENT)))
            call GroupAddUnit(data.dummy,d)
            set i=i+1
        endloop
        set d=null
        return data
    endmethod
    
    static method check takes nothing returns boolean
        local Data d=Data(filter)
        if IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(d.caster)) and GetWidgetLife(GetFilterUnit())>.405 then
            set d.i=d.i+1
            if(GetRandomInt(0,d.i)==1) then
                set d.randomu=GetFilterUnit()
            endif
        endif
        return false
    endmethod
    
    static method group takes nothing returns nothing
        local real x=GetUnitX(Data(filter).caster)
        local real y=GetUnitY(Data(filter).caster)
        call SetUnitAnimationByIndex(GetEnumUnit(),GetRandomInt(4,6))
        call SetUnitX(GetEnumUnit(),x)
        call SetUnitY(GetEnumUnit(),y)
        // The x/y parts are only necessary if there is a possibility that the hero could be 
        // knocked back or pushed while in effect. You can get rid of them if this will not 
        // happen, but leave the animation part.
    endmethod
    
    method attack takes nothing returns nothing
        local real dmg=DAMAGE(GetUnitAbilityLevel(.caster,ID),.caster)
        local real x=GetUnitX(.caster)
        local real y=GetUnitY(.caster)
        local real tx=GetUnitX(.target)
        local real ty=GetUnitY(.target)
        set filter=this
        if GetWidgetLife(.caster)>.405 and .hitcount<=MAX_HITS then
            if .attacktimer==.32 then
                set .hitcount=.hitcount+1
                call SetUnitAnimationByIndex(.caster,GetRandomInt(4,6))
                call ForGroup(.dummy,function Data.group)
                if GetWidgetLife(.target)>.405 and tx-x*tx-x+ty-y*ty-y<=AOE*AOE then
                    call DestroyEffect(AddSpecialEffectTarget(SFX,.target,"origin"))
                    call Damage_Physical(.caster,.target,dmg,ATK_TYPE,true,false)
                    call Text(.target,dmg)
                    call Sound(.target,HIT_SOUND[GetRandomInt(0,2)])
                else
                    set .i=0
                    set .randomu=null
                    call GroupEnumUnitsInRange(BFgroup,x,y,AOE,Condition(function Data.check))
                    if .randomu==null then
                        call Sound(.caster,MISS_SOUND[GetRandomInt(0,1)])
                    else
                        call Sound(.randomu,HIT_SOUND[GetRandomInt(0,2)])
                        call DestroyEffect(AddSpecialEffectTarget(SFX,.randomu,"origin"))
                        call Damage_Physical(.caster,.randomu,dmg,ATK_TYPE,true,false)
                        call Text(.randomu,dmg)
                    endif
                endif
                set .attacktimer=0
            endif
            set .attacktimer=.attacktimer+PERIOD
        else
            set .ticks=0
        endif
    endmethod
    
    method end takes nothing returns nothing
        local unit u
        call SetUnitTimeScale(.caster,1)
        if GetWidgetLife(.caster)<.405 then
            call SetUnitAnimationByIndex(.caster,3)
        else
            call SetUnitAnimationByIndex(.caster,0)
        endif
        call UnitRemoveAbility(.caster,BUFF)
        loop
            set u=FirstOfGroup(.dummy)
        exitwhen u==null
            call GroupRemoveUnit(.dummy,u)
            call RemoveUnit(u)
        endloop
        call DestroyGroup(.dummy)
        set u=null
    endmethod
endstruct

private function PeriodicFunc takes nothing returns boolean
    local Data data=KT_GetData()
    set data.ticks=data.ticks-1
    if data.ticks<=0 then  
        call data.end()
        return true
    else
        call data.attack()
        return false
    endif  
endfunction 

private function actions takes nothing returns nothing
    call KT_Add(function PeriodicFunc,Data.create(GetTriggerUnit(),GetSpellTargetUnit()) ,PERIOD)
endfunction

private function init takes nothing returns nothing
    call TriggerAddAction(GT_RegisterStartsEffectEvent(CreateTrigger(),ID),function actions)
    set DUMMY=CreateUnit(Player(13),DUMMY_ID2,0,0,0)
    call UnitAddAbility(DUMMY,ID2)
    set HIT_SOUND[0]="Sound\\Units\\Combat\\MetalMediumSliceFlesh1.wav"
    set HIT_SOUND[1]="Sound\\Units\\Combat\\MetalMediumSliceFlesh2.wav"
    set HIT_SOUND[2]="Sound\\Units\\Combat\\MetalMediumSliceFlesh3.wav"
    set MISS_SOUND[0]="Units\\Orc\\HeroBladeMaster\\HeroBladeMasterAttack1.wav"
    set MISS_SOUND[1]="Units\\Orc\\HeroBladeMaster\\HeroBladeMasterAttack2.wav"
endfunction

endscope


Nothing too special really, its mostly eye-candy, but im sure someone would find this useful in a map like footmen frenzy or something like that
Feedback is welcomed, if you see any bugs or mistakes let me know.
DL the map.
 

Attachments

  • Blade Fury.w3x
    86.2 KB · Views: 276

BlackRose

Forum User
Reaction score
239
// Blade Fury by BRUTAL
// Requires TT, and the texttag library for the floating text
// - copy and past the units 'Baraka/Blade Fury' and 'Dummy'
// make sure to change the variables DUMMY_ID and DUMMY_ID2
// to the raw data of the pasted units
// - copy and paste the buff 'Baraka/Blade Fury' make sure to
// change BUFF to the raw data of the buff
// - copy and paste the spells 'Baraka/Blade Fury' and
// 'Baraka/Blade Fury stun' make sure to change the
// variables ID and ID2 to the raw data of the spells
// - copy and paste the triggers 'Blade Fury', 'Texttag Library'
// and the TT
// Credits are okay, but i dont care if you say you made it cause you didnt ><
// 17/05/09

Just some ' needed, god, no capitals for starting sentence :)

Nice, does it damage AoE if the target dies right? Though maybe you should add a sound for the weapon being striked, not just that blood effect, like light metal armor or something.

JASS:
        if GetUnitState(.caster, UNIT_STATE_LIFE) &gt; 0 then
            if .hitcount &lt;= MAX_HITS then
                if .attacktimer == 0 then

Um.... and
 

BRUTAL

I'm working
Reaction score
118
yes, well spelling isnt that important, you could at least understand what im saying.
if the target dies, or if the target is farther then the aoe from the caster, it will damage random enemy units within the aoe, i did add sounds in my map version, i suppose i'll update that too

i dont get what your trying to say there about the bit of if's
 

BRUTAL

I'm working
Reaction score
118
i put the getuintstate and hitcount part together, but i think it would glitch if i added the attacktimer part
updated, sounds added
 

WolfieeifloW

WEHZ Helper
Reaction score
372
I believe it is.
It's what everyone uses ;) .
Looking over the rest of the code now...

Your naming and spacing is weird, but good job otherwise :p .
 

BRUTAL

I'm working
Reaction score
118
Updated again with the getwidgetlife.

yes i know, but its easy for me.
does anyone know where the sound of a missed attack is in the sound editor? i cant find it

edits:
ops, i forgot to change the naming of the functions and such again because i copy and pasted the trigger from my map, i'll fix it when i find the sound im looking for
 

WolfieeifloW

WEHZ Helper
Reaction score
372
JASS:
IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(Data(filter).caster)) == true

In "check" could be:
JASS:
IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(Data(filter).caster))

-----
JASS:
if GetUnitState(.target, UNIT_STATE_LIFE) &gt; 0 then

In "move" could be:
JASS:
if GetWidgetLife(.target) &gt; 0.405 then

-----
JASS:
if SquareRoot(dx * dx + dy * dy) &lt;= AOE * AOE then

Again in "move".
SquareRoot(a) = b is the same as a = b ^ 2.
I don't know what that equals out to in your equation but it can save you a "SquareRoot()" call.
-----
JASS:
if GetUnitState(.caster, UNIT_STATE_LIFE) &lt;= 0.4125 then

In "onDestroy", again, could be:
JASS:
if GetWidgetLife(.caster) &lt;= 0.405 then
 

BRUTAL

I'm working
Reaction score
118
JASS:
not IsUnitType(whichUnit, UNIT_TYPE_DEAD)

is that really better? i have no idea if it is lol

ah, the parts where i should have put GetWidgetLife are all because i forgot to :p thanks for pointing it out anyways
SquareRoot(a) = b is the same as a = b ^ 2.
i dont get what you mean there, instead of the SquareRoot call, should i make a local real and do b ^ 2?

I'll update soon, still havent found a miss-swing sound T_T
 

WolfieeifloW

WEHZ Helper
Reaction score
372
It was Romek who helped me with the SquareRoot thing.
I personally have no idea :p .

And using "not [...]" is better then "[...] == false".
 

BRUTAL

I'm working
Reaction score
118
well im clueless about that too lol, but i'll see if i can figure it out ><

and howso? is it faster and/or more efficient ;o
 

WolfieeifloW

WEHZ Helper
Reaction score
372
I think it might be more efficient but I'm not sure about that part.
I know it's less code/typing though ;) !

And the SquareRoot thing was like this for me:
JASS:
SqaureRoot(x * x + y * y) &gt;= 10
//Turns into:
(x * x + y * y) &gt;= 100
 

BRUTAL

I'm working
Reaction score
118
i see, i'll start doing that from now on :rolleyes:

hm; i think i get it. you just multiply the end number by itself i suppose

ou you just made me realize an error;
JASS:
if SquareRoot(dx * dx + dy * dy) &lt;= AOE * AOE then

should have just been '<= AOE'
but now, the way you suggested will be
JASS:
dx * dx + dy * dy &lt;= AOE * AOE
 

BRUTAL

I'm working
Reaction score
118
its all good ;o
i think i should make the damage configurable, i still dont understand the purpose of putting it in its own function
anyone care to explain lol
and i would just call this function before the actual damage call right?
 
General chit-chat
Help Users
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top