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

Fan Of Knives

Status
Not open for further replies.
Level 9
Joined
Jan 23, 2008
Messages
310
JASS:
 Fan Of Knives Help![/b]

Hello.
My name is Chris, and i'we decided to make a spell for my warden which  will throw Knives around her and then damage units that get too close to the knives using Level*HeroAgility. With 4 Total Levels. The problem is i can't seem to get it working it is creating the Knives and they walk their way but they don't damage any creature, please help me.
[code=jass]scope FanofKnifes initializer onInit

    globals
        private trigger FokTrigger = CreateTrigger()
        private unit FokKnife
        private unit FokCaster
        private unit FokTarget
        private xedamage xed
        private group g = null
    endglobals

    private function Conditions_Dummy takes nothing returns boolean
        return GetSpellAbilityId() == 'A004'
    endfunction

    private function Actions_Dummy takes nothing returns nothing
        local location FokLocation1 
        local location FokLocation2
        local location FokLocation3
        local real FokSpeed = 15.00
        local real FokDistance = 500.00
        local real FokAngle
        local real FokFacing
        local integer FokKnives = 18
        local player FokPlayer
        set FokCaster = GetTriggerUnit()
        set FokLocation1 = GetUnitLoc(FokCaster)
        set FokPlayer = GetOwningPlayer(FokCaster)
        set bj_forLoopAIndex = 1
        set bj_forLoopAIndexEnd = FokKnives
           loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                set FokAngle = ( ( 360.00 / I2R(FokKnives) ) * I2R(bj_forLoopAIndex) )
                set FokLocation2 = Location(GetLocationX(FokLocation1) + 50.00 * Cos(FokAngle * bj_DEGTORAD), GetLocationY(FokLocation1) + 50.00 * Sin(FokAngle * bj_DEGTORAD))
                set FokKnife = CreateUnitAtLoc( FokPlayer, 'h000', FokLocation2, FokAngle )
                call UnitApplyTimedLife(FokKnife,'BTLF', 1.30)
                set FokFacing = ( GetUnitFacing(FokKnife) + FokAngle )
                set FokLocation3 = Location(GetLocationX(FokLocation2) + FokDistance * Cos(FokFacing * bj_DEGTORAD), GetLocationY(FokLocation2) + FokDistance * Sin(FokFacing * bj_DEGTORAD))
                call SetUnitFacing(FokKnife, FokFacing)
                call IssuePointOrderLoc( FokKnife, "move", FokLocation3 )
                set bj_forLoopAIndex = bj_forLoopAIndex + 1
            endloop
            call TriggerRegisterUnitInRange(FokTrigger, FokKnife, 100.00, null)//Condition(IsUnitEnemy(GetTriggerUnit(), FokPlayer)))
            call RemoveLocation(FokLocation1)
            call RemoveLocation(FokLocation2)
            call RemoveLocation(FokLocation3)
            set FokPlayer = null
    endfunction


    private function Actions_Damage takes nothing returns nothing
        local real x = GetUnitX(FokKnife)
        local real y = GetUnitY(FokKnife)
        set FokTarget = GetFilterUnit()
        call KillUnit(FokKnife)
        call GroupEnumUnitsInRange(g, x, y, 100.0 + XE_MAX_COLLISION_SIZE , null)
        call xed.damageGroup(FokCaster, g, GetHeroAgi(FokCaster, true) * (1 * GetUnitAbilityLevel(FokCaster, 'A004')))
        set FokKnife = null
        set FokCaster = null
        call DestroyGroup(g)
    endfunction
    
 //  private function Conditions_Damage takes nothing returns boolean
 //   local unit u = GetFilterUnit()
 //   return GetUnitState(u, UNIT_STATE_LIFE) >= 0
 //   set u = null
// endfunction
   
    private function onInit takes nothing returns nothing
        local trigger tr = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ( tr, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddCondition( tr, Condition( function Conditions_Dummy ) )
        call TriggerAddAction( tr, function Actions_Dummy )
        call TriggerAddAction( FokTrigger, function Actions_Damage) 
    endfunction

endscope
 
Last edited:
Level 9
Joined
Jan 23, 2008
Messages
310
I would like my spell to be Jass (because i am trying to learn it) and be MUI in one trigger, also i need it to damage based on hero's agility so i can't use shockwawes.
And i would like to know what is wrong and how to fix it so i don't make that mistakes ever again.
 
Last edited:
I would like my spell to be Jass (because i am trying to learn it) and be MUI in one trigger, also i need it to damage based on hero's agility so i can't use shockwawes.
And i would like to know what is wrong and how to fix it so i don't make that mistakes ever again.

I think he's saying that there is already a spell like this in the spells section of the hive or else maybe he did not read your post...

I guess the problem lies in the trigger for the damage part... btw, your action will only work for the current FokKnife since you set x,y to be the x,y of the global FokKnife... basically from what I see in your trigger, it will only deal damage to units near the last created FoKKnife...

also, using the move command to move the knives is a pretty bad idea...

my suggestion: use a missile system...
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
You didn't set g to CreateGroup() when you declared it. This is probably the reason why no damage is occurring.

It's best to use a missile system like Adiktuz suggested. Since you're using the xe system you could also use xe collider for the missile if you don't want to import another system.

What I'm saying here isn't related to your problem but it might help you out in other Jassing:

  • Since you're using Jass, you don't need to use locations except for GetLocationZ. Use coordinates instead.
  • You should probably loop with a local integer variable to avoid conflicting.
  • If you're using a global group variable, you don't need to destroy it if it's going to be reused.
  • Use GetWidgetLife instead of GetUnitState as it's faster.
 
Status
Not open for further replies.
Top