• 🏆 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 Spell Help...

Status
Not open for further replies.
Level 6
Joined
Oct 10, 2009
Messages
1,425
Dang, I hate asking for help..., but I'm fairly new to jass and I really need help with a spell I'm making.

Okay, the spell I'm making pretty much get a random unit within 512 range of the caster and attacks him, whether he's allied or not.

Once I get this to work, I'm going to make the unit uncontrollable for X amount of seconds depending on the level of the spell,
but I still can't get the first part complete.
All it does now is he plays he resets his stand anim.

If one of you pro jassers out there could help out, I'd be very grateful. :)

Let me know if you need any additional info.
JASS:
      function Condition takes nothing returns boolean
        if  GetSpellAbilityId() == 'ZZZZ' then
        else
        return false
        endif
        return true
    endfunction
        
        function UnitPick takes nothing returns nothing
            local unit caster = GetTriggerUnit()
            call GroupAddUnit(udg_T, GroupPickRandomUnit(GetUnitsInRangeOfLocAll(512, GetUnitLoc(caster))))
            set udg_target = FirstOfGroup(udg_T)
            call IssueTargetOrder(caster,"attack",udg_target)
            set caster = null
            set udg_target = null
            call GroupRemoveUnit(udg_T,FirstOfGroup(udg_T))
        endfunction

//===========================================================================
function InitTrig_SpellJass takes nothing returns nothing
        local trigger t=CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_CAST)
        call TriggerAddCondition(t,Condition(function Condition))
        call TriggerAddAction(t,function UnitPick)
endfunction
 
JASS:
function SpellJass_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'AHds' //Remember to change this ID; I used Devine Shield for testing purposes.
endfunction
        
function UnitPick takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local group g = CreateGroup()
    local real x = GetUnitX (caster)
    local real y = GetUnitY (caster)
    local unit u
    call GroupEnumUnitsInRange (g, x, y, 512, null)
    set u = GroupPickRandomUnit(g)
    call IssueTargetOrder(caster,"attack",u)
    set caster = null
    set u = null
    call DestroyGroup (g)
    set g = null
endfunction

//===========================================================================
function InitTrig_SpellJass takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(t,Condition(function SpellJass_Conditions))
        call TriggerAddAction(t,function UnitPick)
endfunction
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
The options are
1) stunning the caster.
2) pausing the caster. However, this isn't really recommended since you cannot issue orders to the caster while it's paused and the duration of buffs also get paused. (In other word, there are more side effects to pausing then just stunning it)


You could try forcing the caster to keep attacking the unit through triggers. Pharaoh_ provides a good example of this somewhere in a thread.
Edit: The fourth trigger Pharaoh_ gives in this thread is similar to the the trigger I was talking about.
Basically, catch whenever the caster is issued an order and make it attack the target. (You'll need a form of hashtables/Table for this to be MUI.)

By the way, this spell will make the caster attempt to attack dead units as well because of the null filter. You should add a filter just to check if the caster will be able to attack the unit.
 
Good notice, Dark_Axl.
JASS:
function SpellJass_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'AHds' //Remember to change this ID; I used Devine Shield for testing purposes.
endfunction

function SpellJass_CondOne takes nothing returns boolean
    return GetFilterUnit() != GetTriggerUnit() and
endfunction

function UnitPick takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local group g = CreateGroup()
    local real x = GetUnitX (caster)
    local real y = GetUnitY (caster)
    local unit u
    call GroupEnumUnitsInRange (g, x, y, 512, Filter(function SpellJass_CondOne))
    set u = GroupPickRandomUnit(g)
    call IssueTargetOrder(caster,"attack",u)
    set caster = null
    set u = null
    call DestroyGroup (g)
    set g = null
endfunction

//===========================================================================
function InitTrig_SpellJass takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(t,Condition(function SpellJass_Conditions))
        call TriggerAddAction(t,function UnitPick)
endfunction
 
Level 6
Joined
Oct 10, 2009
Messages
1,425
Sorry to do this to you pharaoh, but
JASS:
function SpellJass_CondOne takes nothing returns boolean
    return GetFilterUnit() != GetTriggerUnit() and
endfunction

Gives me the error;
Missing expression for logical and

I've never had this error, so I've no idea how to fix it. (or even what it wants from me)
 
Level 6
Joined
Oct 10, 2009
Messages
1,425
Still doesn't work.
And syntax check simply says "parse successful" :/ so I don't know the problem.
Here's the code
JASS:
unction SpellJass_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'AHds' //Remember to change this ID; I used Devine Shield for testing purposes.
endfunction

function SpellJass_CondOne takes nothing returns boolean
    return GetFilterUnit() != GetTriggerUnit()
endfunction

function UnitPick takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local group g = CreateGroup()
    local real x = GetUnitX (caster)
    local real y = GetUnitY (caster)
    local unit u
    call GroupEnumUnitsInRange (g, x, y, 512, Filter(function SpellJass_CondOne))
    set u = GroupPickRandomUnit(g)
    call IssueTargetOrder(caster,"attack",u)
    set caster = null
    set u = null
    call DestroyGroup (g)
    set g = null
endfunction

//===========================================================================
function InitTrig_SpellJass takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(t,Condition(function SpellJass_Conditions))
        call TriggerAddAction(t,function UnitPick)
endfunction
 
Level 9
Joined
Aug 21, 2008
Messages
533
JASS:
globals
unit castergl
endglobals

function SpellJass_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'AHds' //Remember to change this ID; I used Devine Shield for testing purposes.
endfunction

function SpellJass_CondOne takes nothing returns boolean
    return GetFilterUnit() !=castergl
endfunction

function UnitPick takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local group g = CreateGroup()
    local real x = GetUnitX (caster)
    local real y = GetUnitY (caster)
    local unit u
    set castergl=caster
    call GroupEnumUnitsInRange (g, x, y, 512, Filter(function SpellJass_CondOne))
    set u = GroupPickRandomUnit(g)
    call IssueTargetOrder(caster,"attack",u)
    set caster = null
    set u = null
    call DestroyGroup (g)
    set g = null
    set caster=null
endfunction

//===========================================================================
function InitTrig_SpellJass takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(t,Condition(function SpellJass_Conditions))
        call TriggerAddAction(t,function UnitPick)
endfunction


The filter cant know who the trigger unit is =/
 
Still doesn't work.
And syntax check simply says "parse successful" :/ so I don't know the problem.
Here's the code
JASS:
unction SpellJass_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'AHds' //Remember to change this ID; I used Devine Shield for testing purposes.
endfunction

function SpellJass_CondOne takes nothing returns boolean
    return GetFilterUnit() != GetTriggerUnit()
endfunction

function UnitPick takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local group g = CreateGroup()
    local real x = GetUnitX (caster)
    local real y = GetUnitY (caster)
    local unit u
    call GroupEnumUnitsInRange (g, x, y, 512, Filter(function SpellJass_CondOne))
    set u = GroupPickRandomUnit(g)
    call IssueTargetOrder(caster,"attack",u)
    set caster = null
    set u = null
    call DestroyGroup (g)
    set g = null
endfunction

//===========================================================================
function InitTrig_SpellJass takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(t,Condition(function SpellJass_Conditions))
        call TriggerAddAction(t,function UnitPick)
endfunction
Your first "function" misses the "f":
JASS:
unction SpellJass_Conditions takes nothing returns boolean
See? It's "unction".

Finally, like I said before, this spell was made to be tested with Devine Shield, of which the Order Id is 'AHds'.
In the following function (which is in the code already)
JASS:
function SpellJass_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'AHds' //Remember to change this ID; I used Devine Shield for testing purposes.
endfunction
Notice that "Remember to change this ID;" You must change that ID (the 'AHds') to the ID of your spell, to make it work.

Go to your Object Editor, Abilities tab and press "Ctrl+D". Find your ability's rawcode; it should be something like 'A000', if you are using a custom ability.
 
What do you mean by "it doesn't work"?

You have to elaborate a bit more. Also, add these debug messages, test it out in game, and see what happens. =)
JASS:
globals
    unit SpellJass_cast
endglobals

function SpellJass_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'AHds' //Remember to change this ID; I used Devine Shield for testing purposes.
endfunction

function SpellJass_CondOne takes nothing returns boolean
    return GetFilterUnit() != SpellJass_cast
endfunction

function UnitPick takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local group g = CreateGroup()
    local real x = GetUnitX (caster)
    local real y = GetUnitY (caster)
    local unit u
    set SpellJass_cast = caster
    call GroupEnumUnitsInRange (g, x, y, 512, Filter(function SpellJass_CondOne))
    set u = GroupPickRandomUnit(g)
    if IssueTargetOrder(caster,"attack",u) then
        call BJDebugMsg(GetObjectName(GetUnitTypeId(caster))+" is now attacking "+GetObjectName(GetUnitTypeId(u)))
    endif
    set u = null
    call DestroyGroup (g)
    set g = null
    set caster=null //fixed :P
endfunction

//===========================================================================
function InitTrig_SpellJass takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(t,Condition(function SpellJass_Conditions))
        call TriggerAddAction(t,function UnitPick)
endfunction
 
Last edited:
Level 6
Joined
Oct 10, 2009
Messages
1,425
Well, by "it doesn't work"
I meant the syntax was off or something somewhere.
(sorry, I thought I posted it)
It worked before the filter was placed, but now I can't open the map in Warcraft...
So debugs would be uneffective >.>
 
Level 6
Joined
Oct 10, 2009
Messages
1,425
No, no error. I go to test the map and it just takes me to the wc3 main menu. the i go in-game and try to from there and when I start the game it just takes me back to the custom game menu.
(sorry, if this confused you :p)

No, normal maps don't test in NewGen and I've been to several tutorials looking for a reason (and found it) but I cannot fix it.

EDIT, Slayer, I will try that.
 
Level 6
Joined
Oct 10, 2009
Messages
1,425
I know:p that's why there must be a syntax error but all JNPG will tell me is "parse successful" nothing more. no help. :/

EDIT: also, Purge, I noticed you set caster = null twice. any reason? or just a mistake? :p
 
Level 6
Joined
Oct 10, 2009
Messages
1,425
I can't. That's got a lot to do with the fact I can't test maps, I'm fairly certain it's windows 7's fault...

Bad circle :p,but yeah, you know it's supposed to be in that area.
74467716.jpg

 
Status
Not open for further replies.
Top