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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top