Spell Hammerblow

Trollvottel

never aging title
Reaction score
262
Description:
A fun spell, i made it when i had nothing to do and i wanted to test the timer ticker system
Throws a hammer at the target location. Units in range will be damaged and knockbacked.
GUI/Jass: Jass
vJass: yes (so it requires newgen)
Uses Timer Ticker system.

Hard to take a screenshot...

but here are some screenshots:
Throws the hammer overhead:
neubitmapof2.jpg
Throws it again:
neubitmap2vb9.jpg
Now you see the eruption (or not) and the knockback
neubitmap2ap1.jpg

Now the Code (I hope it is leakless):
JASS:

scope hammerblow
    // //================================================================\\
    // || How to implement:                                              ||
    // || 1. copy the dummy and the spell                                ||
    // || 2. copy the spellcode and if necessary the time ticker system  ||
    // || 3. change the values below and have fun                        ||
    // \\================================================================//
    globals
        private constant integer rawid = 'A000' // spell rawcode
        private constant integer dummyraw = 'h000' // dummy rawcode
        private constant real knockdis = 400 // distance of knockback
        private constant real knockspeed = 20 // knockback speed
        private constant real radius = 400 // radius of damage and knockback
        private constant real damage = 150 // damage per level
    endglobals
    globals 
        private constant string lightningcode = "LEAS"
        //Now the Red/Green/Blue/Alpha values of the lightning. 1.00 = 100%
        private constant real red = 1
        private constant real green = 1
        private constant real blue = 1
        private constant real alpha = 1.00
    endglobals

    private function Trig_Spell_Conditions takes nothing returns boolean
        return GetSpellAbilityId() == rawid
    endfunction


    //Knockback
    private struct s
        unit u
        real dis
        real speed
        real angle
        effect e
    endstruct

    private function knock_child takes nothing returns boolean
        local s dat = TT_GetData()
        set dat.dis = dat.dis - dat.speed
        if dat.dis >= 0 then
            call SetUnitFacing(dat.u, GetUnitFacing(dat.u) + 10 )
            call SetUnitPosition(dat.u, GetUnitX(dat.u) + dat.speed * Cos(dat.angle * bj_DEGTORAD), GetUnitY(dat.u) + dat.speed * Sin(dat.angle * bj_DEGTORAD))
        else
            call DestroyEffect(dat.e)
            call SetUnitPathing(dat.u, true)
            call dat.destroy()
            return true
        endif
        return false
    endfunction

    function knockback takes unit u, real dis, real speed, real angle returns nothing
        local s dat = s.create()
        call SetUnitPathing(u, false)
        set dat.u = u
        set dat.dis = dis
        set dat.speed = speed
        set dat.angle = angle
        set dat.e = AddSpecialEffectTarget("Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl", dat.u, "origin")
        call TT_Start(function knock_child, dat)
    endfunction

    //Spell


    private struct hammer
        unit caster
        unit dummy
        real dis
        real angle
        real targx
        real targy
        real curx
        real cury
        real height    = 0
        real minus     = 0
        real curdis
        lightning light

            method onDestroy takes nothing returns nothing
                call RemoveUnit(this.dummy)
                call DestroyLightning(this.light)
            endmethod
    endstruct


    private function periodic takes nothing returns boolean
        local hammer dat = TT_GetData()
        local group g 
        local unit u
        local terraindeformation t
        set dat.curx = dat.curx + dat.dis / 10 * Cos(dat.angle * bj_DEGTORAD)
        set dat.cury = dat.cury + dat.dis / 10 * Sin(dat.angle * bj_DEGTORAD)

        set dat.minus = dat.minus + 1.00
        if dat.minus > 10 then
            set dat.height = dat.height - dat.curdis / 10
        else
            set dat.height = dat.height + dat.curdis / 10
        endif
        
        call SetUnitPosition(dat.dummy, dat.curx,dat.cury)
        call SetUnitFlyHeight(dat.dummy, dat.height, 0)
        
        call MoveLightningEx(dat.light, false,  GetUnitX(dat.caster), GetUnitY(dat.caster), 40, dat.curx, dat.cury, dat.height)
       
        set dat.curdis = SquareRoot((GetUnitX(dat.caster) - dat.curx ) * (GetUnitX(dat.caster) - dat.curx ) + (GetUnitY(dat.caster) - dat.cury ) * (GetUnitY(dat.caster) - dat.cury ))
        if dat.curdis  >= dat.dis then
        
            call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl", dat.curx, dat.cury))
            set t = TerrainDeformCrater(dat.curx, dat.cury, radius, 80, R2I(200), false)
            
            set g = CreateGroup()
            call GroupEnumUnitsInRange(g, dat.curx, dat.cury, radius, null)
            loop
                set u = FirstOfGroup(g)
                call GroupRemoveUnit(g,u)
                exitwhen u == null
                if GetUnitState(u, UNIT_STATE_LIFE) > 0 and IsUnitEnemy(u, GetOwningPlayer(dat.caster)) then
                    call UnitDamageTarget(dat.caster, u, damage * GetUnitAbilityLevel(dat.caster, rawid), true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
                    call knockback(u, knockdis, knockspeed, bj_RADTODEG * Atan2(GetUnitY(u) - dat.cury, GetUnitX(u) - dat.curx ))
                endif
            endloop
            
            call DestroyGroup(g)
            call dat.destroy()
            set g = null
            set u = null
            set t = null
            return true
        endif
        return false
    endfunction

    private function Trig_Spell_Actions takes nothing returns nothing
        local hammer dat = hammer.create()
        local location loc = GetSpellTargetLoc()
        set dat.targx    = GetLocationX(loc)
        set dat.targy    = GetLocationY(loc)
        call RemoveLocation(loc)
        set dat.caster   = GetTriggerUnit()
        set dat.angle    = bj_RADTODEG * Atan2(dat.targy - GetUnitY(dat.caster), dat.targx - GetUnitX(dat.caster))
        set dat.dis      = SquareRoot((GetUnitX(dat.caster) - dat.targx ) * (GetUnitX(dat.caster) - dat.targx ) + (GetUnitY(dat.caster) - dat.targy ) * (GetUnitY(dat.caster) - dat.targy ))
        set dat.curx     = GetUnitX(dat.caster) - dat.dis  * Cos(dat.angle * bj_DEGTORAD)
        set dat.cury     = GetUnitY(dat.caster) - dat.dis  * Sin(dat.angle * bj_DEGTORAD)
        set dat.light    = AddLightning(lightningcode, false, GetUnitX(dat.caster), GetUnitY(dat.caster), dat.curx, dat.cury)
        call SetLightningColor(dat.light, red, green, blue, alpha)
        set dat.dummy    = CreateUnit(GetOwningPlayer(dat.caster), dummyraw, dat.curx, dat.cury, dat.angle)
        call TT_Start( function periodic, dat)
        set loc = null
    endfunction

    //===========================================================================
    function InitTrig_Spell takes nothing returns nothing
        set gg_trg_Spell = CreateTrigger(  )
        call TriggerRegisterAnyUnitEventBJ( gg_trg_Spell, EVENT_PLAYER_UNIT_SPELL_CHANNEL )
        call TriggerAddCondition( gg_trg_Spell, Condition( function Trig_Spell_Conditions ) )
        call TriggerAddAction( gg_trg_Spell, function Trig_Spell_Actions )
    endfunction


endscope
 

Attachments

  • Spell - Hammer blow.w3x
    23.3 KB · Views: 715

Hatebreeder

So many apples
Reaction score
381
Well...
No Map is attached =)
While looking though your Code, I noticed this:
JASS:
//call DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\Naga\\NagaBlood\\NagaBloodWindserpent.mdl", GetUnitX(dat.u), GetUnitY(dat.u)))


If you don't use this, maybe it's better to remove it completly ;)
Other than that, I can't seem to find any leaks...
Well done =)
 

Cohadar

master of fugue
Reaction score
209
I noticed you declared knockspeed constant but you are not using it.
And the fact that TT_PERIOD is not showing anywhere tells me this is not independent of period, if someone changed their TT to use 0.03 instead of default 0.04 it would change speeds in your spell.

You should learn how to make spells period independent.
 

gref

New Member
Reaction score
33
Couple of comments: A: the name of the map you upoaded is Hammeblow, not Hammer blow.
B: It would be better if you made it easier to stop channeling -- (Ie. turn the disable other abilities bit in the channel spell off).
C: The tooltip needs work. I wanted to just press a key on my keyboard to use it and there wasn't one.
Finally: Maybe for the test you should make the hero level 10, or make a trigger that restores his health to full periodically (Or just make is regen 99999) because he died in about a second... which stopped me testing the spell because I'm lazy.

All in all, it looks pretty good. It would be really cool if you get a model that didn't resize so badly, but obviously that's hard to do. If you just improve those things which make your map easier to test, then people probably will...
 

Trollvottel

never aging title
Reaction score
262
Finally: Maybe for the test you should make the hero level 10, or make a trigger that restores his health to full periodically (Or just make is regen 99999) because he died in about a second... which stopped me testing the spell because I'm lazy.

just press esc... ^^

all in all, it looks pretty good. It would be really cool if you get a model that didn't resize so badly, but obviously that's hard to do.

thank you.
i think everyone has to choose this own hammer model, maybe ill add a function to change the lighnings color and art.
 

Trollvottel

never aging title
Reaction score
262
well in the next release the armor is on 3000 so the unit wont take damage

ok ive edited it a bit
 

The Undaddy

Creating with the power of rage
Reaction score
55
Haven't looked through the code but when you cast the hammer on 'self' it usually stays flying until you move.It's nice,overall.
Also,I don't like spells which pause the unit so that it can always cast the spell
 

gref

New Member
Reaction score
33
Well the effect certainly is better. I see you've changed it from unit target to point target, which is probably a good thing. Also the push back seems bigger.
As far as I can see it's looking pretty good.
Knowing the moderators around here, I'd guess that they'd still want you to make a clone of a normal tootip: Ie. have yellow letter for hotkey instead of [e] or whatever it was.
Good spell.
I don't like channelling spells as a personal thing, but I can almost get past that with this :p.
 

rodead

Active Member
Reaction score
42
well i got a question how can i make your spell damage buildings but not knockback them ( i am not an expirienced Jasser but i can read it)
 

Trollvottel

never aging title
Reaction score
262
no problem.
find this:
JASS:

               if GetUnitState(u, UNIT_STATE_LIFE) > 0 and IsUnitEnemy(u, GetOwningPlayer(dat.caster)) then
                    call UnitDamageTarget(dat.caster, u, damage * GetUnitAbilityLevel(dat.caster, rawid), true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
                    call knockback(u, knockdis, knockspeed, bj_RADTODEG * Atan2(GetUnitY(u) - dat.cury, GetUnitX(u) - dat.curx ))
                endif

and change it to this:
JASS:
                if GetUnitState(u, UNIT_STATE_LIFE) > 0 and IsUnitEnemy(u, GetOwningPlayer(dat.caster)) then
                    call UnitDamageTarget(dat.caster, u, damage * GetUnitAbilityLevel(dat.caster, rawid), true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
                    if IsUnitType(u, UNIT_TYPE_STRUCTURE) != true then
                        call knockback(u, knockdis, knockspeed, bj_RADTODEG * Atan2(GetUnitY(u) - dat.cury, GetUnitX(u) - dat.curx ))
                    endif
                endif
 

Komaqtion

You can change this now in User CP.
Reaction score
469
This spell works with the newest patches, but (This is a very small tweak) it could use the new [ljass]GetSpellTargetX/Y[/ljass] natives, instead of using a location...

Just for some small efficiency gain XD
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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 The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top