Player Help

Do you need World Editor help? Ask here!
Forum rules
Before making a new topic:
First, check if your question has already been answered in the Tutorials section.
If you didn't find a solution, use the search function.
If searching didn't help either, you can make a new topic.

Topic title & content:
You must use a descriptive title. (Help plz is not good) (Need help with Dialog buttons is good)
Go into much detail when posting. You should post attachments. Like screenshots of the problem, the map you are making, replays of the error. Or you could even make a screencast (video) of your problem and upload it here.

Spelling:
Grammar seems to be a serious problem amongst teenagers, so use a spell checker or you will get no love.
Read your posts twice, before pressing the reply button.
And do not use profanity. Chatspeak (y r u nub) and Leetspeak (1 C4N S33 H4X) are not welcome here either.

Only World Editor related questions are allowed here!
(Click for Battle.net help) (Click for World Editor help)
Race
Posts: 3
Joined: Thu Apr 21, 2011 4:05 pm

Player Help

Unread post by Race »

i have a maze, and i decided to make brown a player too, and when i make the enemy units any of these (neutral hostile/passive/extra or victim), my square patrols act up. (if you need to see how they fuck up i can show you.) it works when i change it back to any player 0-11, but none of the neutral players work. everything else on the map works except for the square patrols. this is one of my square patrol functions...

function CheckUnit1 takes nothing returns boolean
if ( GetUnitTypeId(GetTriggerUnit()) == udg_UnitType[1]) then
return true
else
return false
endif
endfunction

function Move1 takes nothing returns nothing
call IssuePointOrder( GetTriggerUnit(), "move", GetRectCenterX( udg_NextRegion[1] ), GetRectCenterY( udg_NextRegion[1] ))
endfunction
function Move2 takes nothing returns nothing
call IssuePointOrder( GetTriggerUnit(), "move", GetRectCenterX( udg_NextRegion[2] ), GetRectCenterY( udg_NextRegion[2] ))
endfunction
function Move3 takes nothing returns nothing
call IssuePointOrder( GetTriggerUnit(), "move", GetRectCenterX( udg_NextRegion[3] ), GetRectCenterY( udg_NextRegion[3] ))
endfunction
function Move4 takes nothing returns nothing
call IssuePointOrder( GetTriggerUnit(), "move", GetRectCenterX( udg_NextRegion[4] ), GetRectCenterY( udg_NextRegion[4] ))
endfunction

function Square1 takes integer i, rect a, rect b, rect c, rect d returns nothing

local integer y = 1
local integer z = 4
set udg_UnitType[1] = i

loop
exitwhen y > z
set udg_Trigger[y] = CreateTrigger()
call TriggerAddCondition( udg_Trigger[y], Condition( function CheckUnit1 ) )
set y = y + 1
endloop

call TriggerRegisterEnterRectSimple( udg_Trigger[1], a)
call TriggerRegisterEnterRectSimple( udg_Trigger[2], b)
call TriggerRegisterEnterRectSimple( udg_Trigger[3], c)
call TriggerRegisterEnterRectSimple( udg_Trigger[4], d)

set udg_NextRegion[1] = b
set udg_NextRegion[2] = c
set udg_NextRegion[3] = d
set udg_NextRegion[4] = a

call TriggerAddAction( udg_Trigger[1], function Move1 )
call TriggerAddAction( udg_Trigger[2], function Move2 )
call TriggerAddAction( udg_Trigger[3], function Move3 )
call TriggerAddAction( udg_Trigger[4], function Move4 )

endfunction

not sure why changing the player to a neutral player would fuck anything up but i guess it does...

User avatar
3ICE
Admin
Posts: 2629
Joined: Sat Mar 01, 2008 11:34 pm
Realm: Europe
Account: 3ICE
Clan: 3ICE
Location: Hungary
Contact:

Re: Player Help

Unread post by 3ICE »

Why does it look so GUI-ish?
Use proper JASS, converted triggers are so unreadable and ugly.

EDIT1: For example this entire useless function:

Code: Select all

function CheckUnit1 takes nothing returns boolean
if ( GetUnitTypeId(GetTriggerUnit()) == udg_UnitType[1]) then
return true
else
return false
endif
endfunction
and this condition referencing it

Code: Select all

call TriggerAddCondition( udg_Trigger[y], Condition( function CheckUnit1 ) )
Should really be just an if-check at the beginning of Move1 Move2 etc:

Code: Select all

if GetUnitTypeId(GetTriggerUnit()) == udg_UnitType[1]then
EDIT2: I remember reading about similar issues years ago. In all solutions I saw, the effort required to turn off the neutral AI or make it obey triggered orders was too much. This is why everyone sticks to brown-controlled enemies instead of debugging why neutral won't do what it is told.

EDIT3: Bad topic title. I'd have used "Neutral player won't take orders".

EDIT4: Use points instead of regions as the argument. Recalculating the center of the region all the time is a waste of CPU power. Calculate it once at map init if you must, but the best solution would be just using the x and y coordinates and deleting those useless regions.

Code: Select all

function Square1 takes integer i, rect a, rect b, rect c, rect d returns nothing
to

Code: Select all

function Square takes integer u, point a, point b, point c, point d returns nothing
EDIT5: With StarCraft 2 we finally have access to points in the terrain editor, not just regions. This is a huge improvement. Be gone, t_reg Center of Region!

EDIT6: Why is udg_UnitType an array when all you ever use is the second index: udg_UnitType[1] (udg_UnitType[0] would be the first index)

EDIT7: Realized you can't use point arguments as the rects are actually needed for the t_uni unit enters region event. But you should still only calculate the center of those regions once (when the Square function is called) and store the results in a variable for later use.

EDIT8: the parameter "integer i" should really be "integer u" as it references a unit-type, not an index / counter.
ImageImageImageImageImage
Image
ImageImage

Post Reply

Who is online

Users browsing this forum: No registered users and 122 guests