On a Grand Scale

Ark'u'roth

New Member
Reaction score
0
Hey there.

Would anyone know how to make this function

call SetUnitAnimationByIndex(unit,1)

apply to all units on the map? I'd greatly appreciate some help.

Thanks
 

Builder Bob

Live free or don't
Reaction score
249
create a group.
set a global variable to your index of choice.
call GroupEnumUnitsInRect() for the rect bj_mapInitialPlayableArea and call SetUnitAnimationByIndex(GetFilterUnit(), GlobalInteger) in the filter function.
destroy the group.
 

Ark'u'roth

New Member
Reaction score
0
You'll have to dumb that down, I'm afraid. :( Sorry.

Do I define the group as GetUnitsInRectAll(GetPlayableMapRect())
then put in call GroupEnumUnitsInRect(rect bj_mapInitialPlayableArea)?
What's the filter unit/function?
 

Builder Bob

Live free or don't
Reaction score
249
sure.

Make an integer variable in any way you know how. If you make it in the variable editor, remember to add the prefix udg_ before the variable name. In my example the variable is called Index in the variable editor.

JASS:
//filter functions are usually meant to decide which units to put in the group and which to filter out.
//However, there's nothing stopping us from doing other things in here.
function UnitAnimationFilter takes nothing returns boolean
	call SetUnitAnimationByIndex(GetFilterUnit(), udg_Index) //access the global variable
	return false //I return false here to filter out every unit from the group since we're not going to keep the group anyway.
endfunction

//call this function to set all units' animation
function SetAllUnitsAnimationByIndex takes integer index returns nothing
	local group g = CreateGroup() //create group
	set udg_Index = index //set the global variable
	call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, Condition(function UnitAnimationFilter)) //this function adds units to the group g if the filter function returns true.
	call DestroyGroup(g) //discard group
	set g = null //setting the variable g to null to avoid a memory leak
endfunction
 

Ark'u'roth

New Member
Reaction score
0
K, I've tried the above both in its own trigger and inside a pre-existing one, and it looks fine in the editor but gives me a "FATAL ERROR" when I try to test play it and closes Warcraft down. Does anyone know what's going on? :confused:
 

saw792

Is known to say things. That is all.
Reaction score
280
Indices of animations vary with the models. Quite possibly you are trying to play an animation for a model that does not have an animation at that index, or a model with a corrupt animation at that index or something. In the first case I am unsure whether that can crash warcraft, however.
 

Ark'u'roth

New Member
Reaction score
0
JASS:
function Trig_Side_Look_Conditions takes nothing returns boolean
    if ( not ( udg_Walkforward == true ) ) then
        return false
    endif
    return true
endfunction

function UnitAnimationFilter takes nothing returns boolean
        call SetUnitAnimationByIndex(GetFilterUnit(), udg_Index)
        return false
endfunction

function Trig_Side_Look_Actions takes integer index returns nothing
    local group g = CreateGroup()
    call SetUnitTimeScalePercent( gg_unit_Hapm_0002, 100 )
    call TriggerSleepAction( 1.20 )
    call SetUnitAnimationByIndex(gg_unit_hcth_0001,0)
    call SetUnitAnimationByIndex(gg_unit_hcth_0004,0)
    call SetUnitAnimationByIndex(gg_unit_Hapm_0002,2)
    call TriggerSleepAction( 6.66 )
    call SetUnitAnimationByIndex(gg_unit_Hapm_0002,1)
    set udg_Index = 0
    call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, Condition(function UnitAnimationFilter))
    call DestroyGroup(g)
    set g = null
    set udg_Walkforward = false
endfunction



untitled.png
 

Builder Bob

Live free or don't
Reaction score
249
Are you able to save the map at all without getting the fatal error? If you aren't then I think it is because you do not have an Init function in your trigger.

You know, you could download NewGen to always be sure that you can save your code without the editor crashing. You'll get compile errors instead, telling you what's wrong in your code. I highly recommend it no matter how new you are to Jass. It has only advantages and no disadvantages.
 

Builder Bob

Live free or don't
Reaction score
249
@Builder Bob

Warcraft III crashed, not worldedit.exe.

I'm quite sure you're right. I just want to make sure. I don't even think the world editor makes fatal errors.

The reason I want to make sure is because in my tests SetUnitAnimationByIndex() does not crash the game, even for indexes in the hundreds.
 

Exide

I am amazingly focused right now!
Reaction score
448
JASS:

function Trig_Side_Look_Conditions takes nothing returns boolean
    if ( not ( udg_Walkforward == true ) ) then
        return false
    endif
    return true
endfunction

function UnitAnimationFilter takes nothing returns boolean
        call SetUnitAnimationByIndex(GetFilterUnit(), udg_Index)
        return false
endfunction

function Trig_Side_Look_Actions takes integer index returns nothing
    local group g = CreateGroup()
    call SetUnitTimeScalePercent( gg_unit_Hapm_0002, 100 )
    call TriggerSleepAction( 1.20 )
    call SetUnitAnimationByIndex(gg_unit_hcth_0001,0)
    call SetUnitAnimationByIndex(gg_unit_hcth_0004,0)
    call SetUnitAnimationByIndex(gg_unit_Hapm_0002,2)
    call TriggerSleepAction( 6.66 )
    call SetUnitAnimationByIndex(gg_unit_Hapm_0002,1)
    set udg_Index = 0
    call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, Condition(function UnitAnimationFilter))
    call DestroyGroup(g)
    set g = null
    set udg_Walkforward = false
endfunction


-If that's your complete trigger, then you are missing some things..


When you convert a trigger from GUI to JASS it turns out like this:

GUI:
Code:
Test Trigger
    Events
    Conditions
    Actions

=

JASS:
JASS:

function Trig_Test_Trigger_Actions takes nothing returns nothing
endfunction

//===========================================================================
function InitTrig_Test_Trigger takes nothing returns nothing
    set gg_trg_Test_Trigger = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Test_Trigger, function Trig_Test_Trigger_Actions )
endfunction


*Notice the name of the trigger: gg_trg_Test_Trigger

So, in your case it would look like this:

JASS:

function Trig_Side_Look_Conditions takes nothing returns boolean
    return ( udg_Walkforward == true )
endfunction

function UnitAnimationFilter takes nothing returns boolean
    call SetUnitAnimationByIndex(GetFilterUnit(), udg_Index)
    return false
endfunction

function Trig_Side_Look_Actions takes integer index returns nothing
    local group g = CreateGroup()
    call SetUnitTimeScalePercent( gg_unit_Hapm_0002, 100 )
    call TriggerSleepAction( 1.20 )
    call SetUnitAnimationByIndex(gg_unit_hcth_0001,0)
    call SetUnitAnimationByIndex(gg_unit_hcth_0004,0)
    call SetUnitAnimationByIndex(gg_unit_Hapm_0002,2)
    call TriggerSleepAction( 6.66 )
    call SetUnitAnimationByIndex(gg_unit_Hapm_0002,1)
    set udg_Index = 0
    call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, Condition(function UnitAnimationFilter))
    call DestroyGroup(g)
    set g = null
    set udg_Walkforward = false
endfunction

//===========================================================================
function InitTrig_Side_Look takes nothing returns nothing
    set gg_trg_Side_Look = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Side_Look, function Trig_Side_Look_Actions )
endfunction


-Should work..
 

Ark'u'roth

New Member
Reaction score
0
I'm sorry, I didn't think that piece would be important.
It ends with

JASS:
//===========================================================================
function InitTrig_c takes nothing returns nothing
    set gg_trg_c = CreateTrigger(  )
    call TriggerRegisterUnitEvent( gg_trg_c, gg_unit_hcth_0001, EVENT_UNIT_ISSUED_POINT_ORDER )
    call TriggerAddCondition( gg_trg_c, Condition( function Trig_Side_Look_Conditions ) )
    call TriggerAddAction( gg_trg_c, function Trig_Side_Look_Actions )
endfunction


Would it help if we selected a group other than 'in the playable area'?
 

Exide

I am amazingly focused right now!
Reaction score
448
According to JassCraft, if you've got this:
JASS:

globals
   boolean udg_Walkforward
   integer udg_Index
   unit gg_unit_Hapm_0002
   unit gg_unit_hcth_0001
   unit gg_unit_hcth_0004
endglobals

function Trig_Side_Look_Conditions takes nothing returns boolean
    return ( udg_Walkforward == true )
endfunction

function UnitAnimationFilter takes nothing returns boolean
    call SetUnitAnimationByIndex(GetFilterUnit(), udg_Index)
    return false
endfunction

function Trig_Side_Look_Actions takes integer index returns nothing
    local group g = CreateGroup()
    call SetUnitTimeScalePercent( gg_unit_Hapm_0002, 100 )
    call TriggerSleepAction( 1.20 )
    call SetUnitAnimationByIndex(gg_unit_hcth_0001,0)
    call SetUnitAnimationByIndex(gg_unit_hcth_0004,0)
    call SetUnitAnimationByIndex(gg_unit_Hapm_0002,2)
    call TriggerSleepAction( 6.66 )
    call SetUnitAnimationByIndex(gg_unit_Hapm_0002,1)
    set udg_Index = 0
    call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, Condition(function UnitAnimationFilter))
    call DestroyGroup(g)
    set g = null
    set udg_Walkforward = false
endfunction

//===========================================================================
function InitTrig_c takes nothing returns nothing
    set gg_trg_c = CreateTrigger(  )
    call TriggerRegisterUnitEvent( gg_trg_c, gg_unit_hcth_0001, EVENT_UNIT_ISSUED_POINT_ORDER )
    call TriggerAddCondition( gg_trg_c, Condition( function Trig_Side_Look_Conditions ) )
    call TriggerAddAction( gg_trg_c, function Trig_Side_Look_Actions )
endfunction
Then there should be no problem.
(globals = your global variables.)

I don't know what you're doing with that unit grup, though.
Also, if one of your pre-placed units dies this trigger won't run properly.

What are you trying to do with this trigger, and why can't you do it in GUI?
 

Ark'u'roth

New Member
Reaction score
0
GUI doesn't have support for a lot of units' specific animations - such as stand 2, which I need in this cinematic. The animation index 0 is to keep the units from fidgeting and looking around when I want them acting serious, although I realize now I really should use groups according to type instead of 'all in playable area.'

Edit:

Sorry, still comes up with a Fatal Error. I tried getting rid of any units that might not have an animation index 0, but it didn't change anything.
 

Ark'u'roth

New Member
Reaction score
0
Hey, I figured out a simpler way. But thanks to all that helped! I appreciate you stooping down to assist a lowly noob. Rep all around!
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top