• 🏆 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!

[JASS] How to make this spell work for non-hero

Status
Not open for further replies.
Level 8
Joined
Nov 21, 2008
Messages
316
I imported the spell omnislash into my map, but it only works for heros wat part of it must i change so it can work for regular units. Keep in mind i already changed the ability from a hero spell to unit.

JASS:
//TESH.scrollpos=0
//TESH.alwaysfold=0

////////////////////////////////////////////////////////////////////////////
// By Barathrum (Dark_Lord_12)                                            //
//                                                                        //
//                                                                        //
// To import the spell:                                                   //
//                                                                        //
// Create a new trigger, convert it and replace the whole code with myne. //
//                                                                        //
// You will also need an ability, you can copy mine or create your own.   //
//                                                                        //
// I used the ID A000, if you use an other, just change it.               //
//////////////////////////////////////////////////////////////////////////// 

function Slash_Condition takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction
function Death takes nothing returns boolean
    return ( GetWidgetLife(GetFilterUnit()) <= 0) == false
endfunction

function Slash_Actions takes nothing returns nothing
 local unit caster = GetSpellAbilityUnit() // casting unit
 local location start_position = GetUnitLoc(caster)  // casting units original location when casted
 local group enemies = CreateGroup() // the group of units that will be hit by the spell
 local unit temp // the current slashed target
 local integer count = GetUnitAbilityLevel (caster, 'A000') * 5 // number of slashes (currently set to do 5 slashes x level of omnislash)
 local location temp_loc //location of temp (current slashed unit)
 local effect blinkEffect // the effect of caster (blink)
 local effect targetEffect // the effect of slashed unit (phoenix misle)
 local real delay = 0.10 // this is the delay between slashes. Currently 0.10
  
    call GroupEnumUnitsInRangeOfLoc(enemies, start_position, 750.0, Condition(function Death)) // the range of caster wich units will be picked for targets (currently 750 )
    
    call DestroyEffect( AddSpecialEffectLoc("Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl", GetUnitLoc (caster)))
        loop
        call TriggerSleepAction (delay)
        set temp = null
        set temp = GroupPickRandomUnit(enemies)
        loop
        if GetWidgetLife(temp) <= 0 then
        set temp = null
        set temp = GroupPickRandomUnit(enemies)
        else
        exitwhen caster != null
        endif
        endloop
        exitwhen temp == null or count <= 0
        if IsUnitEnemy(temp, GetOwningPlayer(caster)) then
            set temp_loc = GetUnitLoc(temp)
            call DestroyEffect( AddSpecialEffectLoc("Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl", GetUnitLoc (caster)))
            call SetUnitPositionLoc(caster, temp_loc)
            call SetUnitAnimation( caster, "attack" )
            call UnitDamageTarget(caster, temp, GetUnitAbilityLevel (caster, 'A000') * 50, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, null) // the demage dealt (currently 75 x level of spell omnislash)
            set targetEffect = AddSpecialEffectTarget("Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile_mini.mdl",temp,"chest")
            call DestroyEffect (targetEffect)
            set count = count - 1
            call RemoveLocation(temp_loc)
        endif
        //call GroupRemoveUnit(enemies, temp)
        endloop
        call RemoveLocation(start_position)
    call DestroyGroup(enemies)
    set caster = null
set start_position = null
set enemies = null
set temp = null
call RemoveLocation (temp_loc)
set temp_loc = null
call DestroyEffect (blinkEffect)
call DestroyEffect (targetEffect)
endfunction
function InitTrig_Slash_Copy takes nothing returns nothing
 set gg_trg_Slash_Copy = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Slash_Copy, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Slash_Copy, Condition(function Slash_Condition))
    call TriggerAddAction(gg_trg_Slash_Copy, function Slash_Actions)
endfunction
 
Level 2
Joined
Jul 17, 2009
Messages
27
JASS:
function Death takes nothing returns boolean
    return ( GetWidgetLife(GetFilterUnit()) <= 0) == false
endfunction

change to:

JASS:
function Death takes nothing returns boolean
    return not ( GetWidgetLife(GetFilterUnit()) <= 0.405 )
endfunction


JASS:
function Slash_Actions takes nothing returns nothing
 // ...
 // code
 // ...
 local integer count = GetUnitAbilityLevel (caster, 'A000') * 5 // number of slashes (currently set to do 5 slashes x level of omnislash)

Make this a constant, like so:

JASS:
function Slash_Actions takes nothing returns nothing
 // ...
 // code
 // ...
 local integer count = 5 // Or however many slashes you want.


JASS:
 local location temp_loc //location of temp (current slashed unit)
 local effect blinkEffect // DELETE - this isn't used, and can be deleted.
 local effect targetEffect // the effect of slashed unit (phoenix misile)
 local real delay = 0.10 // this is the delay between slashes. Currently 0.10

JASS:
set temp_loc = null
call DestroyEffect (blinkEffect) // DELETE - you also need to remove this call.
call DestroyEffect (targetEffect)
endfunction


I really don't see any reason the trigger cannot work as-is, though.
 
Status
Not open for further replies.
Top