• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Fatal Sword

  • Like
Reactions: Losam
9avOF.png


Changelog:
• Code fixed
• Movement model changed


JASS:
//*************************************************************
//TEST THE SPELL FIRST TO CONFIGURE ANYTHING BELOW THIS
//*************************************************************

function FS_Ability takes nothing returns integer
    return 'A000'
//Raw code of the ability
endfunction
function FS_Animation takes nothing returns integer
    return 2
//Animation index
endfunction
function FS_ChargeTime takes nothing returns real
    return 0.2
//Time to charge the attack
endfunction
function FS_DistanceM takes nothing returns real
    return 150.
//Distance after the attack
endfunction
function FS_Effect1 takes nothing returns string
    return "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl"
//Weapon effect
endfunction
function FS_Effect1AP takes nothing returns string
    return "weapon"
//Weapon attach point
endfunction
function FS_Effect2 takes nothing returns string
    return "Abilities\\Spells\\Undead\\OrbOfDeath\\OrbOfDeathMissile.mdl"
//Movement effect
endfunction
function FS_Effect3 takes nothing returns string
    return "Objects\\Spawnmodels\\Undead\\UndeadBlood\\UndeadBloodNecromancer.mdl"
//Blood effect
endfunction
function FS_Velocity takes nothing returns real
    return 1600.
//Movement speed
endfunction
function FS_Range takes nothing returns real
    return 125.
//Attack range
endfunction
function FS_AttackType takes nothing returns attacktype
    return ATTACK_TYPE_NORMAL
//Attack type
endfunction
function FS_DamageType takes nothing returns damagetype
    return DAMAGE_TYPE_NORMAL
//Damage type
endfunction
function FS_WeaponType takes nothing returns weapontype
    return WEAPON_TYPE_METAL_MEDIUM_SLICE
//Weapon type
endfunction
function FS_Damage takes integer level returns real
    return 175. * level
//Damage per level
endfunction
function FS_RechargeEnergy takes nothing returns real
    return 2.
//Time to recharge the energy
endfunction
function FS_TimerInterval takes nothing returns real
    return 0.025
//FPS || Default = 0.025 (1 / 0.025 = 40 FPS)
endfunction


//*************************************************************
//TOUCH ANYTHING BELOW THIS ONLY IF YOU KNOW JASS
//*************************************************************


function FS_Distance takes unit c, unit tar returns real
    return SquareRoot((GetUnitX(tar) - GetUnitX(c)) * (GetUnitX(tar) - GetUnitX(c)) + (GetUnitY(tar) - GetUnitY(c)) * (GetUnitY(tar) - GetUnitY(c)))
endfunction

function FS_Loop takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer i = GetHandleId(t)
    local unit c = LoadUnitHandle(udg_FS_HashTable, i, 0)
    local unit tar = LoadUnitHandle(udg_FS_HashTable, i, 1)
    local integer level = LoadInteger(udg_FS_HashTable, i, 2)
    local real ready = LoadReal(udg_FS_HashTable, i, 3)
    local real distance = LoadReal(udg_FS_HashTable, i, 4)
    local real angle = LoadReal(udg_FS_HashTable, i, 5)
    local boolean finish = LoadBoolean(udg_FS_HashTable, i, 6)
    local boolean attack = LoadBoolean(udg_FS_HashTable, i, 7)
    local real interval = LoadReal(udg_FS_HashTable, i, 9)
    local real wait = LoadReal(udg_FS_HashTable, i, 10)
    local real x
    local real y
    local real int = FS_TimerInterval()
    if distance < FS_DistanceM() and not IsTerrainPathable(GetUnitX(c), GetUnitY(c), PATHING_TYPE_WALKABILITY) == true then
        if ready > int and not finish and not IsUnitType(c, UNIT_TYPE_DEAD) then
            call SaveReal(udg_FS_HashTable, i, 3, ready - int)
        else
            call SaveBoolean(udg_FS_HashTable, i, 6, true)
        endif
        if finish then
            set x = GetUnitX(c) + FS_Velocity() * int * Cos(angle * bj_DEGTORAD)
            set y = GetUnitY(c) + FS_Velocity() * int * Sin(angle * bj_DEGTORAD)
            call DestroyEffect(AddSpecialEffect(FS_Effect2(), x, y))
            if distance > (0. - 10.) and not attack then
                if FS_Distance(c, tar) <= FS_Range() then
                    call DestroyEffect(LoadEffectHandle(udg_FS_HashTable, i, 8))
                    call UnitDamageTarget(c, tar, FS_Damage(level), true, false, FS_AttackType(), FS_DamageType(), FS_WeaponType())
                    call SetUnitTimeScale(c, 0)
                    call SaveBoolean(udg_FS_HashTable, i, 7, true)
                else
                    call LoadEffectHandle(udg_FS_HashTable, i, 8)
                    call SaveBoolean(udg_FS_HashTable, i, 7, true)
                endif
            endif
            if attack then
                call DestroyEffect(AddSpecialEffectTarget(FS_Effect3(), tar, "chest"))
                call DestroyEffect(AddSpecialEffectTarget(FS_Effect3(), c, "weapon"))
            endif
            call SetUnitX(c, x)
            call SetUnitY(c, y)
            call SaveReal(udg_FS_HashTable, i, 4, distance + FS_Velocity() * int)
        endif
    else
        if wait > int and attack then
            call SaveReal(udg_FS_HashTable, i, 10, wait - int)
        else
            call SetUnitPathing(c, true)
            call SetUnitTimeScale(c, 1)
            call SetUnitAnimation(c, "stand")
            call PauseUnit(c, false)
            call PauseTimer(t)
            call FlushChildHashtable(udg_FS_HashTable, i)
            call DestroyTimer(t)
        endif
    endif
    set c = null
    set tar = null
    set t = null
endfunction

function FS_Actions takes nothing returns boolean
    local unit c
    local unit tar
    local integer level
    local timer t
    local integer i
    local real int = FS_TimerInterval()
    if GetSpellAbilityId() == FS_Ability() then
        set c = GetTriggerUnit()
        set tar = GetSpellTargetUnit()
        set level = GetUnitAbilityLevel(c, FS_Ability())
        set t = CreateTimer()
        set i = GetHandleId(t)
        call SaveAgentHandle(udg_FS_HashTable, i, 0, c)
        call SaveAgentHandle(udg_FS_HashTable, i, 1, tar)
        call SaveInteger(udg_FS_HashTable, i, 2, level)
        call SaveReal(udg_FS_HashTable, i, 3, FS_ChargeTime())
        call SaveReal(udg_FS_HashTable, i, 4, 0 - FS_Distance(c, tar))
        call SaveReal(udg_FS_HashTable, i, 5, bj_RADTODEG * Atan2(GetUnitY(tar) - GetUnitY(c), GetUnitX(tar) - GetUnitX(c)))
        call SaveBoolean(udg_FS_HashTable, i, 6, false)
        call SaveBoolean(udg_FS_HashTable, i, 7, false)
        call SaveAgentHandle(udg_FS_HashTable, i, 8, AddSpecialEffectTarget(FS_Effect1(), c, FS_Effect1AP()))
        call SaveReal(udg_FS_HashTable, i, 9, 0)
        call SaveReal(udg_FS_HashTable, i, 10, FS_RechargeEnergy())
        call TimerStart(t, int, true, function FS_Loop)
        call PauseUnit(c, true)
        call SetUnitPathing(c, false)
        call SetUnitAnimation(c, "stand")
        call SetUnitAnimationByIndex(c, FS_Animation())
        set c = null
        set tar = null
        set t = null
    endif
    return false
endfunction

function InitTrig_FS takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function FS_Actions))
    set udg_FS_HashTable = InitHashtable()
    set t = null
endfunction


Keywords:
sword, fatal, fatal sword, jass, spell in jass, hiveworkshop, ability, sword ability, towars, comes, damages, really, attack, type, damage, weapon, to
Contents

Fatal sword (Map)

Reviews
15 Feb 2012 Bribe: Decent spell. I enjoyed the demo map as well. You can definitely improve on efficiency and improve the importing instructions (for example the user needs to copy the hashtable). 3/5.

Moderator

M

Moderator

15 Feb 2012
Bribe: Decent spell. I enjoyed the demo map as well. You can definitely improve on efficiency and improve the importing instructions (for example the user needs to copy the hashtable). 3/5.
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
- StringHash is slow, so normal integers will do...
- HandleId of something, if used a lot should be saved in an integer...
- You dont need to create locals if you only referenced it for once, like >>> wait, finish, attack, etc...
- I didnt test this but Im not sure if you can unpause the unit after the timer with this kind of setup >>> PauseUnit(c,true)
- Load only the hashtables values if TriggerUnit is alive and distance < FS_DistanceM()
- You really dont need the FS_Angle & FS_Distance, just put them as locals...
 
Level 14
Joined
Aug 8, 2010
Messages
1,022
The spell is good, but i want to point something. When i tested your map, i have encountered a problem - when i cast the spell and there is a cliff between the caster and the target - the caster does no damage and doesn't move, but he plays his animations and gets a special effect on his weapon that never disappears. You should check if there is a cliff before you execute the remaining actions of your spell. ;)

I give it 4/5. :)
 
Level 11
Joined
Mar 27, 2011
Messages
293
Someone tell me how to solve the following problem:

The times I do I open the World Map with the Edit and Active Functions When I type vJASS Edit the World What's Speech Serious Errors In these functions, Soon Triggers are disabled and IS IMPOSSIBLE THAT I ACTIVATE THEM.

Appreciate if anyone could help me.
Have A Good Day and Stay with GOD!
 
Level 8
Joined
Aug 8, 2011
Messages
297
How to import this spell ? Do i need to import all the triggers ? or just the trigger called: FS ?

From the map: "To import this spell into your map you have to copy the ability named "Fatal sword" and the triggers named "HS Creation" and "FS", then test the map and enjoy!!!"

but where are HS Creation trigger ?

i got theese 3 problems when saving map: Line: 15943, 16016 and 16043. when i imported "FS" Trigger and the Fatal Sword Ability. what have i done wrong ?
 
Top