Spell Gentle Fist

D.V.D

Make a wish
Reaction score
73
Gentle Fist

Untitled-135.jpg


The unit hits a target causing the target to slide and lose health. Once the unit stops, the caster fires a beam at him causing a explosion dealing AoE damage.

Thanks to Kenny! for helping me fix a mistake I made.

Read the description of the variables first. The names of the variables don't explain the values that will screw up the spell.

JASS:

//------------------------------------------\\
//             D.V.D Presents:              \\
//------------------------------------------\\
// Description: The caster hits his enemy   \\
// pushing him back and then shooting a     \\
// beam at the target causing AoE dmg.      \\
//------------------------------------------\\
//                                          \\
// Pros:                                    \\
// Easy To Modify                           \\
// Eye Candy Effects                        \\
// Easy To Implement                        \\
//                                          \\
//------------------------------------------\\
// How To Implement:                        \\
// - Copy this trigger into your map        \\
// - Copy the Dummy Units Into Your Map     \\
// - Copy the ability into your map         \\
//------------------------------------------\\
// Requires:                                \\
// - JassNewGenPack(Or a vJass Proccessor)  \\
// - TimerUtils                             \\
//------------------------------------------\\

// atype1 - Modifies the attack type of the damage done while sliding
// atype2 - Modifies the attack type of the damage done after the beams dead
// dtype1 - Modifies the damage type of the damage done while sliding
// dtype2 - Modifies the damage type of the damage done after the beams dead
// AbilId - The rawcode for the ability
// Castrange - Cast range is the maximum range of casting this spell set in the object editor. The value of this variable must be the maximum casting range / movespeed and must be divisible. THat means NO DECIMALS.
// DummyId - The rawcode for the hit dummy
// DummyId2 - The rawcode for the laser dummy
// DummyId3 - The rawcode for the explosion dummy
// Laserarray - This determines the array size of the struct laser. The size of this struct must be atleast movespeedfull / movespeed + Castrange
// dummydist - Distance between dummy hit and caster
// laserdamage - Damage done by the explosion
// laserdmgradius - Radius of the damage explosion
// movedamage - Damage done while enemy is sliding
// movedistance - Distance targets moved for sliding
// movedistancefull - The max distance for sliding. Must be divisible by movetime
// movetime - Time before unit moves again to simulate sliding
// EffectId - Id of the slide effect
// EffectId2 - Id of the effect done after the unit is done sliding
// wtype1 - Modifies the weapon type of the damage done while sliding
// wtype2 - Modifies the weapon type of the damage done after the beams dead

//The struct varialbe unit array laser has a array size of 200. The array size must be atleast
//movespeedfull / movespeed or else the laser won't finish and the spell will be bugged.


JASS:
scope GentleFist initializer Init

    globals
        private constant attacktype atype1 = ATTACK_TYPE_NORMAL
        private constant attacktype atype2 = ATTACK_TYPE_MAGIC
        
        private constant damagetype dtype1 = DAMAGE_TYPE_NORMAL
        private constant damagetype dtype2 = DAMAGE_TYPE_MAGIC
        
        private constant integer AbilId = 'AHtb'
        private constant integer Castrange = 10
        private constant integer DummyId = 'h000'
        private constant integer DummyId2 = 'h001'
        private constant integer DummyId3 = 'h002'
        private constant integer Laserarray = 200
        
        private constant real dummydist = 50.00
        private constant real laserdamage = 500.00
        private constant real laserdmgradius = 200.00
        private constant real laserdistance = 9.00
        private constant real movedamage = 2.00
        private constant real movedistance = 9.00
        private constant real movedistancefull = 360.00
        private constant real movetime = 0.02
        
        private constant string EffectId = "Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl"
        private constant string EffectId2 = "Abilities\\Spells\\Orc\\EarthQuake\\EarthQuakeTarget.mdl"
    
        private constant weapontype wtype1 = WEAPON_TYPE_WHOKNOWS
        private constant weapontype wtype2 = WEAPON_TYPE_WHOKNOWS
    endglobals
    
    //-------------------\\
    // DO NOT EDIT BELOW \\
    //-------------------\\
    
    globals
        private unit Explosion
    endglobals
    
    private struct data
        integer count
        real distance
        real x
        real y
        unit caster
        unit array laser [Laserarray]
        unit target
        
        method onDestroy takes nothing returns nothing
            set .caster = null
            set .target = null
        endmethod
        
    endstruct

    private function Conditions takes nothing returns boolean
        return ( GetSpellAbilityId() == AbilId )
    endfunction
    
    private function Laser takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local data d = GetTimerData(t)
        local real angle = GetUnitFacing(d.caster)
        local real x = GetUnitX(d.caster) + d.distance * Cos(angle * bj_DEGTORAD)
        local real y = GetUnitY(d.caster) + d.distance * Sin(angle * bj_DEGTORAD)
        
        set d.laser[d.count] = CreateUnit( GetOwningPlayer(d.caster), DummyId2, x, y, angle )
        call PauseUnit( d.laser[d.count], true )
        call SetUnitTimeScale( d.laser[d.count], 0.00 )
        
        set d.count = d.count + 1
        set d.distance = d.distance + laserdistance
        
        if ( d.count == movedistancefull / movedistance + Castrange ) then
            set d.count = 0
            loop
                exitwhen d.count > movedistancefull / movedistance + 100.00
                call SetUnitTimeScale( d.laser[d.count], 100.00 )
                call SetUnitAnimation( d.laser[d.count], "death" )
                call KillUnit(d.laser[d.count])
                set d.count = d.count + 1
            endloop
            set Explosion = CreateUnit( GetOwningPlayer(d.caster), DummyId3, x, y, angle )
            call UnitApplyTimedLife( Explosion, 'BTLF', 1.00 )
            call UnitDamagePoint( d.caster, 0.00, laserdmgradius, x, y, laserdamage, true, false, atype2, dtype2, wtype2 )
            call ReleaseTimer(t)
            call d.destroy()
        endif
    endfunction
    
    private function Move takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local data d = GetTimerData(t)
        local real angle = GetUnitFacing(d.caster)
        local real x = GetUnitX(d.target) + movedistance * Cos(angle * bj_DEGTORAD)
        local real y = GetUnitY(d.target) + movedistance * Sin(angle * bj_DEGTORAD)
        
        call DestroyEffect( AddSpecialEffect( EffectId, x, y ) )
        call SetUnitPosition( d.target, x, y )
        call UnitDamageTarget( d.caster, d.target, movedamage, true, false, atype1, dtype1, wtype1 )
        set d.count = d.count + 1
        
        if ( d.count == movedistancefull / movedistance ) then
            call SetUnitAnimation( d.target, "death" )
            call DestroyEffect( AddSpecialEffect( EffectId2, x, y ) )
            set d.count = 1
            set d.distance = 9.00
            set d.x = x
            set d.y = y
            call PauseTimer(t)
            call TimerStart( t, 0.02, true, function Laser )
            set t = null
        endif
        
    endfunction

    private function Actions takes nothing returns nothing
        local data d = data.create()
        local real face = GetUnitFacing(d.caster) + 50.00
        local real x
        local real y
        local timer t = NewTimer()
        local unit dummy
        
        set d.count = 0
        set d.caster = GetTriggerUnit()
        set d.target = GetSpellTargetUnit()
        set x = GetUnitX(d.caster) + dummydist * Cos(face * bj_DEGTORAD)
        set y = GetUnitY(d.caster) + dummydist * Sin(face * bj_DEGTORAD)
        
        call SetTimerData( t, d )
        set dummy = CreateUnit(GetOwningPlayer(d.caster),DummyId,x,y,face)
        call PauseUnit(dummy, true)
        call UnitApplyTimedLife( dummy, 'BTLF', 0.30 )
        call TimerStart( t, movetime, true, function Move )
    endfunction

    //===========================================================================
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger(  )
        call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddCondition( t, Condition( function Conditions ) )
        call TriggerAddAction( t, function Actions )
    endfunction

endscope
 

Attachments

  • Gentle Fist.w3x
    28.3 KB · Views: 228

Viikuna

No Marlo no game.
Reaction score
265
JASS:
unit array laser [8191]


In case that wansnt an accident, you should check what JassHelper manual says about array members.
 

D.V.D

Make a wish
Reaction score
73
I set it that high incase people changed the distance the spell could be casted to a much higher amount causing the laser to be large. Changed it to 200 anyways.
 

Flare

Stops copies me!
Reaction score
662
// Cons: \\
// Requires Imported Data \\
// Uses Dummy Units \\
// The distance between target and caster \\
// must not be a decimal
Ahm...
(1) Requiring imported data isn't really a bad thing (unless there's alot of it)
(2) What's wrong with dummy units?
(3) Getting the distance to be a whole number would be ridiculously hard... me thinks you have phrased that incorrectly, or are just plain wrong :p

// - TimerUtils(Blue Flavor)
It doesn't have to be Blue flavour. The other flavours have identical function names, so TU Red will also be compatible

JASS:
        local real x = GetUnitX(GetTriggerUnit()) + dummydist * Cos(face * bj_DEGTORAD)
        local real y = GetUnitY(GetTriggerUnit()) + dummydist * Sin(face * bj_DEGTORAD)

You set a variable for GetTriggerUnit () so instead of calling it unnecessarily, initialize the x/y variables after setting d.caster, then use d.caster in the GetUnitX/Y call e.g.
JASS:
...
local real x
local real y
set d.caster = GetTriggerUnit ()
set x = GetUnitX (d.caster) + ...
set y = GetUnitY (d.caster) + ...


unit array laser [200]
Make a constant for the array size, and clearly indicate the limits that imposes on the spell e.g. how large your laser can be (in number of dummies, and/or maximum distance it will travel). Or, preferably, let the distance stuff revolve around the array size e.g. if you have array size a, the laser will travel b distance, and if the array size is 2a, the laser will travel 2b distance
a and b being unknown variables :3
 

D.V.D

Make a wish
Reaction score
73
Screen shot please?

I'll upload soon.

Bored spell. :p

If you don't like the spell, than tell me how to improve it please.

Ahm...
(1) Requiring imported data isn't really a bad thing (unless there's alot of it)
(2) What's wrong with dummy units?
(3) Getting the distance to be a whole number would be ridiculously hard... me thinks you have phrased that incorrectly, or are just plain wrong :p


It doesn't have to be Blue flavour. The other flavours have identical function names, so TU Red will also be compatible

JASS:
        local real x = GetUnitX(GetTriggerUnit()) + dummydist * Cos(face * bj_DEGTORAD)
        local real y = GetUnitY(GetTriggerUnit()) + dummydist * Sin(face * bj_DEGTORAD)

You set a variable for GetTriggerUnit () so instead of calling it unnecessarily, initialize the x/y variables after setting d.caster, then use d.caster in the GetUnitX/Y call e.g.
JASS:
...
local real x
local real y
set d.caster = GetTriggerUnit ()
set x = GetUnitX (d.caster) + ...
set y = GetUnitY (d.caster) + ...



Make a constant for the array size, and clearly indicate the limits that imposes on the spell e.g. how large your laser can be (in number of dummies, and/or maximum distance it will travel). Or, preferably, let the distance stuff revolve around the array size e.g. if you have array size a, the laser will travel b distance, and if the array size is 2a, the laser will travel 2b distance
a and b being unknown variables :3

Ok Im done all of that. What I meant by the 3rd Con is that the full sliding distance must be divisible by the movespeed or else it won't work. I write a comment on that so people will now.
 

Flare

Stops copies me!
Reaction score
662
//The struct varialbe unit array laser has a array size of 200. The array size must be atleast
//movespeedfull / movespeed or else the laser won't finish and the spell will be bugged.

JASS:
if ( d.count == movedistancefull / movedistance + 10 ) then

Either remove that +10 or make it a configurable constant and update the documentation of the array size accordingly (and add a constant for the array size >:3) e.g.
JASS:
private constant integer NAME = 10 //appropriate name will be required <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />
private constant integer ARRAY_SIZE = 200

...

//The size of the laser array within the struct (determined by ARRAY_SIZE) must not be less than (movedistancefull / movedistance + NAME)

...

if d.count == (movedistancefull / movedistance + NAME) then
//actions
endif


JASS:
static unit array laser [200]

I can't help but think that you hadn't a notion of what you added the static prefix. You're probably gonna break the spell doing that :p Now, if you'll excuse me, I'm gonna to make sure that the spell does break due to that misuse of static over dynamic struct member :p
 

D.V.D

Make a wish
Reaction score
73
I changed the stuff. I just noticed one thing, the array size and all must have specific values in order to work. Wouldn't it be easier to just do the formuals for the person so they don't have like 4 extra values to do? Added all the global descriptions into the documention.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
If you don't like the spell, than tell me how to improve it please.
Eye candy.... :D
 

D.V.D

Make a wish
Reaction score
73
Bump. Im working on making the eye candy better. Is this spell bad? Is the original concept bad? Please comment.
 

Jesus4Lyf

Good Idea™
Reaction score
397
>Is this spell bad? Is the original concept bad? Please comment.
If I had to describe the concept of this spell in one word, I'd have to select "incoherant".

So melee cast, gives a stun and knockback... And then a random buggy trail of units appears and an explosion...

Hm. You've learned a lot in terms of JASS and such, good work.

The units should use a dummy model with an attached effect instead of having 3 different unit types, the laser should be a linked list really (we have a neat linked list module on site if you need assistance there) and the spell needs...

STYLE.

Personally I'd go try a new spell. Feel free! :p
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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