• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Omnislash, my Try

Status
Not open for further replies.
Level 2
Joined
Apr 15, 2007
Messages
18
Hi, I was thinking of creating a Omnislash skill on my own after i read some tutorials. So I made all this by my self but it wont work -.-' He wont even "jump" to the enemies. Check this code and see whats wrong please ;o

JASS:
function OmniSlashCondition takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

function OmniSlashAction takes nothing returns nothing
    local unit h = GetSpellAbilityUnit()
    local group eg = CreateGroup()
    local unit temp 
    local location hloc = GetUnitLoc(h)
    local location eloc
    local integer times = 8
        call DisplayTextToForce(GetPlayersAll(), "Test1")
        call GroupEnumUnitsInRangeOfLoc(eg, hloc, 800.00, null)
        loop
            set temp = FirstOfGroup(eg)
            exitwhen times == 0
            if IsUnitEnemy(temp, GetOwningPlayer(h)) then
                call DisplayTextToForce(GetPlayersAll(), "Test2")
                set times = times - 1
                set eloc = GetUnitLoc(e)
                call SetUnitPositionLoc(h, eloc)
                call IssueTargetOrder(h, "attack", e)
                call PolledWait(0.5)
            endif
        endloop
    call DisplayTextToForce(GetPlayersAll(), "Test3")    
    set h = null
    set eg = null
    set e = null
    set hloc = null
    set eloc = null
    set times = 0
endfunction

function InitTrig_OmniSlash takes nothing returns nothing
    local trigger T
    set T = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(T, EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerAddCondition(T, Condition(function OmniSlashCondition))
    call TriggerAddAction(T, function OmniSlashAction)
endfunction
 
Level 17
Joined
Apr 13, 2008
Messages
1,608
What the hell is e?
There is no such variable here. Your temp unit's var name is temp.
Don't forget to make the unit invulnerable since it would look hilarous is he would jump around stunned .. or dead.

I can't believe this problem slipped through a syntax checker. I don't know original WE's syntax checker since I used NewGen amost since day 1 of my war3modding carrier, but download NewGen. It's waaaaaay much better than the default WE.
Be sure to read the documentation first.
http://www.wc3campaigns.net/showthread.php?t=90999

I think you are aware of the fact that it is going to attack only one unit? You could clear the group and repick the units around the blademaster at the end of the loop.
 
Level 2
Joined
Apr 15, 2007
Messages
18
AH! Thx :p Well im kinda new to this ;o I tried JASS a while ago, but I didnt understand back then, now I do understand more =) And Thanks for the resulotion to the "attack one guy" problem :p
 
Level 2
Joined
Apr 15, 2007
Messages
18
Well still problem -.-' As you can see I did put 3 text messages to notify where the problem is. The text "Test2" and "Test3" doesnt show, I think the If condition doesnt come out true.

Therefore, I think no units is selected to the unit group "eg". Because when I remove the If condition it shows the text "test2" "test3" but the hero doesnt jump to any unit... Is there any more problem in this code? :S Please help again :p
 
Level 2
Joined
Apr 15, 2007
Messages
18
Ok I tried it in NewGen 5a (I think) ;o and the syntax didnt notice any problems. But I get FATAL error :/ this is the JASS code:

JASS:
function OmniSlashCondition takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

function OmniSlashAction takes nothing returns nothing
    local unit h = GetSpellAbilityUnit()
    local group eg = CreateGroup()
    local unit temp 
    local location hloc = GetUnitLoc(h)
    local location eloc
    local integer times = 8
        call DisplayTextToForce(GetPlayersAll(), "Test1")
        call GroupEnumUnitsInRangeOfLoc(eg, hloc, 800.00, null)
        loop
            set temp = FirstOfGroup(eg)
            exitwhen times == 0
            if IsUnitEnemy(temp, GetOwningPlayer(h)) then
                call DisplayTextToForce(GetPlayersAll(), "Test2")
                set times = times - 1
                set eloc = GetUnitLoc(temp)
                call SetUnitPositionLoc(h, eloc)
                call IssueTargetOrder(h, "attack", temp)
                call PolledWait(0.5)
            endif
        endloop
    call DisplayTextToForce(GetPlayersAll(), "Test3")    
    set h = null
    set eg = null
    set temp = null
    set hloc = null
    set eloc = null
    set times = 0
endfunction

function InitTrig_OmniSlash takes nothing returns nothing
    local trigger T
    set T = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(T, EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerAddCondition(T, Condition(function OmniSlashCondition))
    call TriggerAddAction(T, function OmniSlashAction)
endfunction

I cant find whats wrong :S But thanks for helping me : )
 
Level 17
Joined
Apr 13, 2008
Messages
1,608
JASS:
    local unit h = GetSpellAbilityUnit()
    local group eg = CreateGroup()
    local unit temp
    local location hloc
    local location eloc
    local integer times = 8
        
        loop
        exitwhen times == 0
        
    set hloc = GetUnitLoc(h)
    call GroupEnumUnitsInRangeOfLoc(eg, hloc, 800.00, null)
    set temp = GroupPickRandomUnit(eg)
    
    loop 
    exitwhen IsUnitEnemy(temp, GetOwningPlayer(h)) == true
    exitwhen eg == null
    call GroupRemoveUnit(eg, temp)
    set temp = GroupPickRandomUnit(eg)
    endloop
            if IsUnitEnemy(temp, GetOwningPlayer(h)) then
                call DisplayTextToForce(GetPlayersAll(), "Test2")
                set eloc = GetUnitLoc(temp)
                call SetUnitPositionLoc(h, eloc)
                call IssueTargetOrder(h, "attack", temp)
                call PolledWait(0.5)
            endif
            
            set times = times - 1
        endloop
        
    call DisplayTextToForce(GetPlayersAll(), "Test3")
    set h = null
    set eg = null
    set temp = null
    set hloc = null
    set eloc = null

Erm, here, it's working now but I did not clear or optimized your code. I would have done the whole thing differently but that wouldn't have been your spell.
There were a few errors but I don't feel like writing an error report so see for yourself by comparing the codes.
 
Level 11
Joined
Apr 6, 2008
Messages
760
JASS:
local real angle // need this coz we cant call GetRandomReal in x and y can be 2 diffrent numbers :o

//in the loop
set angle = GetRandomReal(1,360)
call SetUnitX(h,GetUnitX(temp)+50*Cos(angle*3.14159/180)) //will get the unit's x toward angle
call SetUnitY(h,GetUnitY(temp)+50*Sin(angle*3.14159/180)) //and this will the same with y

this like PolarProjectionBJ, a faster 1
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
JASS:
local real angle // need this coz we cant call GetRandomReal in x and y can be 2 diffrent numbers :o

//in the loop
set angle = GetRandomReal(1,360)
call SetUnitX(h,GetUnitX(temp)+50*Cos(angle*3.14159/180)) //will get the unit's x toward angle
call SetUnitY(h,GetUnitY(temp)+50*Sin(angle*3.14159/180)) //and this will the same with y

this like PolarProjectionBJ, a faster 1

That was REALLY on-topic. Might want to read what's the thread about next time ? -.-
 
Level 2
Joined
Apr 15, 2007
Messages
18
Thx emperor_d3st, Ill give you rep+ for that code solution. I changed it for my needs but with this code the hero does jump, that was my problem.

Any mod can close this thread now, if it makes a difference :p
 
Status
Not open for further replies.
Top