• 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.

Unit Won't Be Created

Status
Not open for further replies.
Level 5
Joined
Feb 22, 2013
Messages
161
Is there something wrong here?

JASS:
local real x = GetRectCenterX(gg_rct_Dummy_Trigger_Create)
local real y = GetRectCenterY(gg_rct_Dummy_Trigger_Create)
local location loc = Location(x, y)

set udg_DummyTriggerUnit = CreateUnitAtLoc(Player(5), 'du00', loc, 270)
call RemoveLocation(loc)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
What's the event?
Are conditions met?
Why create unit at loc? using x/y is always better.

JASS:
set udg_DummyTriggerUnit = CreateUnit(Player(5), 'du00', GetRectCenterX(gg_rct_Dummy_Trigger_Create), GetRectCenterY(gg_rct_Dummy_Trigger_Create), 270)
 
Level 5
Joined
Feb 22, 2013
Messages
161
What's the event?
Are conditions met?
Why create unit at loc? using x/y is always better.

JASS:
set udg_DummyTriggerUnit = CreateUnit(Player(5), 'du00', GetRectCenterX(gg_rct_Dummy_Trigger_Create), GetRectCenterY(gg_rct_Dummy_Trigger_Create), 270)

The trigger is running at map initialization, and I will try it without using at loc.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Maybe Player(5) is returning "null" if it doesn't have an start position, or the rect hasn't been declared yet, or the global variable hasn't been created, or 'du00' isn't any valid object, so it returns null.
 
Level 5
Joined
Feb 22, 2013
Messages
161
Maybe Player(5) is returning "null" if it doesn't have an start position, or the rect hasn't been declared yet, or the global variable hasn't been created, or 'du00' isn't any valid object, so it returns null.

Why do I have to declare the rect if the region is already placed for the unit to spawn, the global for what, and 'du00' is the raw data of the Dummy Trigger Unit
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I dunno, i was just saying. Wc3 automatically declares rects and regions before map initialization. Are you sure it's "du00" maybbe its "duo0 or du0o" try creating "hfoo" (footman)
 
Level 5
Joined
Feb 22, 2013
Messages
161
I dunno, i was just saying. Wc3 automatically declares rects and regions before map initialization. Are you sure it's "du00" maybbe its "duo0 or du0o" try creating "hfoo" (footman)

Sorry if I sounded snappy there, and I will try that, I'm currently trying to create the unit somewhere besides map init.
 
Level 5
Joined
Feb 22, 2013
Messages
161
The Dummy is supposed to be invisible, what it's supposed to do it when two units get near it, it triggers a cinematic, and unfortunately nothing is working.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Try posting the whole triggers involved with the dummy.

Don't make the dummy invisible, and give it a model, give vision of the dummy to all players, display a debug message after creation, and after a unit comes near to it. Just to check that everything is working.
 
Level 5
Joined
Feb 22, 2013
Messages
161
Try posting the whole triggers involved with the dummy.

Don't make the dummy invisible, and give it a model, give vision of the dummy to all players, display a debug message after creation, and after a unit comes near to it. Just to check that everything is working.

Here ya go:

JASS:
function AmbushTRangeCheck takes group g, unit u returns boolean
	local unit v
	local unit array w
	local integer i = 0
	local boolean b = true
	// Enum the group
	loop
		set v = FirstOfGroup (g)
		exitwhen v == null
		if not IsUnitInRange (u, v, 543.05801) then
			if ( IsPlayerInForce(GetLocalPlayer(), udg_UserForce) ) then
				call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, "All active heroes must be within the area to proceed.")
			endif
			if b then
				set b = false
			endif
		endif
	set w[i]= v
	set i = i + 1
	call GroupRemoveUnit (g, v)
	endloop

	// Read units to group
	loop
		exitwhen i < 0
		call GroupAddUnit (g, w[i])
		set w[i] = null
		set i = i - 1
	endloop

return b
endfunction

function TriggerAmbush takes nothing returns nothing
	if AmbushTRangeCheck(udg_UserUnitGroup, udg_DummyTriggerUnit) == true then
        if TriggerEvaluate(gg_trg_Ambush_Cine) then
            call DisableTrigger(GetTriggeringTrigger())
            call TriggerExecute(gg_trg_Ambush_Cine)
			call RemoveUnit(udg_DummyTriggerUnit)
        endif
    endif
endfunction

//===========================================================================
function InitTrig_Ambush_Trigger takes nothing returns nothing
	local trigger tri = CreateTrigger()
	
	call TriggerAddAction(tri, function TriggerAmbush)
	call TriggerRegisterUnitInRange(tri, udg_DummyTriggerUnit, 543.05801, null)
	
	set tri = null
endfunction

JASS:
function Trig_Intro_Cleanup_Actions takes nothing returns nothing
    local real x = GetRectCenterX(gg_rct_Dummy_Trigger_Create)
    local real y = GetRectCenterY(gg_rct_Dummy_Trigger_Create)
    
    if (GetLocalPlayer() == Player(1)) then
        call ClearSelection()
        call SelectUnit(udg_Paladin, true)
    endif
    if (GetLocalPlayer() == Player(3)) then
        call ClearSelection()
        call SelectUnit(udg_Warrior, true)
    endif
    if (GetLocalPlayer() == Player(4)) then
        call ClearSelection()
        call SelectUnit(udg_Mage, true)
    endif
    if (GetLocalPlayer() == Player(9)) then
        call ClearSelection()
        call SelectUnit(udg_Priest, true)
    endif
    
    if (GetLocalPlayer() == Player(1)) then
        call ResetToGameCamera(0.00)
    endif
    if (GetLocalPlayer() == Player(3)) then
        call ResetToGameCamera(0.00)
    endif
    if (GetLocalPlayer() == Player(4)) then
        call ResetToGameCamera(0.00)
    endif
    if (GetLocalPlayer() == Player(9)) then
        call ResetToGameCamera(0.00)
    endif
    
    if (GetLocalPlayer() == Player(1)) then
        call PanCameraToTimed(GetRectCenterX(gg_rct_Paladin_End), GetRectCenterY(gg_rct_Paladin_End), 0.00)
    endif
    if (GetLocalPlayer() == Player(3)) then
        call PanCameraToTimed(GetRectCenterX(gg_rct_Warrior_End), GetRectCenterY(gg_rct_Warrior_End), 0.00)
    endif
    if (GetLocalPlayer() == Player(4)) then
        call PanCameraToTimed(GetRectCenterX(gg_rct_Mage_End), GetRectCenterY(gg_rct_Mage_End), 0.00)
    endif
    if (GetLocalPlayer() == Player(9)) then
        call PanCameraToTimed(GetRectCenterX(gg_rct_Priest_End), GetRectCenterY(gg_rct_Priest_End), 0.00)
    endif
    
    set udg_DummyTriggerUnit = CreateUnit(Player(6), 'du00', x, y, 270.00)
endfunction

//===========================================================================
function InitTrig_Intro_Cleanup takes nothing returns nothing
    set gg_trg_Intro_Cleanup = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Intro_Cleanup, function Trig_Intro_Cleanup_Actions )
endfunction
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Why don't you just create a Region and check if the number of units in the region are all the units? I think "A unit enters region" and check the other units in the region is a bit better than creating a dummy and checking periodically if there are other units near...
 
Level 5
Joined
Feb 22, 2013
Messages
161
The first one does yes, TriggerRegisterUnitInRange(), and the other one doesn't because another trigger is running the trigger at the end of the intro cinematic
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
JASS:
            if b then // This should display an error. If be == true or == false must be added.
                set b = false
            endif

Again, why don't you just check the number of units around the dummy when they come at range, instead of having a trigger linked to a function that checks a boolean, etc. You could have all that in the same function.

JASS:
    if (GetLocalPlayer() == Player(1)) then
        call ResetToGameCamera(0.00)
    endif
    if (GetLocalPlayer() == Player(3)) then
        call ResetToGameCamera(0.00)
    endif
    if (GetLocalPlayer() == Player(4)) then
        call ResetToGameCamera(0.00)
    endif

// Equal to
local player p = GetLocalPlayer()
if P == Player(1) or p == Player(3) or p == Player(4) or p == Player(9) then
    call ResetToGamecamera(0.00)
endif
set p = null
 
Level 16
Joined
Dec 15, 2011
Messages
1,423
JASS:
            if b then // This should display an error. If be == true or == false must be added.
                set b = false
            endif

It will compile. == true can be shortened like that. Conversely, ==false can also be shortened into if not b then. This applies to all things that return a boolean. Yes I know what I am saying. I wrote that function myself in a separate thread.

@ OP: try display the x and y of the rect and the unit after creation. See what you've got.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
He's not picking the unit with locust. He's picking the heroes around the dummy when someone comes at range. The dummy is just for the event.

Again, I repeat, you should use a region. It's easier.
 
Status
Not open for further replies.
Top