• 🏆 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!

[Trigger] clearing location array

Status
Not open for further replies.
Level 14
Joined
Nov 23, 2008
Messages
187
Simple as an orange -_-

Clearing specific location:

  • Custom script: call RemoveLocation(udg_TempLoc[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))+1])
Clearing all locations:

  • Actions:
    • For each (Integer A) from 1 to 12, do (Actions)
      • Actions:
        • Custom script: call RemoveLocation(udg_TempLoc[bj_forLoopAIndex])
 
Last edited:
Level 17
Joined
Jun 12, 2007
Messages
1,261
Simple as an orange -_-

Clearing specific location:

  • Actions:
    • Custom script: call RemoveLocation(udg_TempLoc[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))+1])
Clearing all locations:

  • Actions:
    • For each (Integer A) from 1 to 12, do (Actions)
      • Actions:
        • Custom script: call RemoveLocation(udg_TempLoc[bj_forLoopAIndex])

Why did you use that +1 you silly goose.

Just use:
  • Custom script: call RemoveLocation(udg_TempLoc[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
 
Level 17
Joined
Jun 12, 2007
Messages
1,261
I wrapped that function to avoid bj, because most of bj functions are naturally useless evil.
At least I have an ability "BJ evasion" with 100% value =)

What's all this nonsense about BJ thingies...
Cleaning a leak is cleaning a leak as long as you do it the correct way.

Besides +1 will just result cleaning wrong values.
If array 1 needs to be cleaned but you clean 1 + 1 you clean 2. Not 1.
So wtf?
 
Level 17
Joined
Jun 12, 2007
Messages
1,261
No sir, you're wrong. I used GetPlayerId, you used GetConvertedPlayerId. Look at this:

JASS:
function GetConvertedPlayerId takes player whichPlayer returns integer
    return GetPlayerId(whichPlayer) + 1
endfunction

lol I got ownd, meh I get it now.
But I think mine is a more simple way... xD

I just create the variable with the array I want it to have.
Copy it to a new trigger, convert it to custom text (jass) and then copy what the array looks like in jass over into a custom script in the trigger where I want to clean the leak.
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
it still is öhm, thx @ all

does getplayerid(whichplayer) result as 0 if not +1?

then it would be correct

Well, the function will return 0 for Player 1, 1 for Player 2, 2 for Player 3 and so on... So thats why you add +1, because in Gui
  • Set something[Get player number of triggering player]
will result 1 for Player 1, 2 for Player 2...
If you dont add +1 in that custom script it will try to destroy a location which doesnt exist, and forget the last one every time.
 
Level 17
Joined
Jun 12, 2007
Messages
1,261
Well, the function will return 0 for Player 1, 1 for Player 2, 2 for Player 3 and so on... So thats why you add +1, because in Gui
  • Set something[Get player number of triggering player]
will result 1 for Player 1, 2 for Player 2...
If you dont add +1 in that custom script it will try to destroy a location which doesnt exist, and forget the last one every time.

So basically I'm not cleaning my leaks properly?
Well, when I create an array I want to clean, for example:
  • GUI
    • Events
    • Conditions
    • Actions
      • Set TempPoint[(Player number of (Owner of (Triggering unit)))] = (Center of (Playable map area))
When I convert it I just get:

JASS:
function Trig_JASS_Actions takes nothing returns nothing
    set udg_TempPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))] = GetRectCenter(GetPlayableMapRect())
endfunction

//===========================================================================
function InitTrig_JASS takes nothing returns nothing
    set gg_trg_JASS = CreateTrigger(  )
    call TriggerAddAction( gg_trg_JASS, function Trig_JASS_Actions )
endfunction

So basically it returns to me for that variable:

JASS:
udg_TempPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))]

Now I'm a total noob on Jass, but if I put that part in the custom script to clean the leak, it will return the correct value to clean right? =/

EDIT: I have always done it this way.
 
Last edited:
Level 23
Joined
Nov 29, 2006
Messages
2,482
So basically I'm not cleaning my leaks properly?
Well, when I create an array I want to clean, for example:
  • GUI
    • Events
    • Conditions
    • Actions
      • Set TempPoint[(Player number of (Owner of (Triggering unit)))] = (Center of (Playable map area))
When I convert it I just get:

JASS:
function Trig_JASS_Actions takes nothing returns nothing
    set udg_TempPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))] = GetRectCenter(GetPlayableMapRect())
endfunction

//===========================================================================
function InitTrig_JASS takes nothing returns nothing
    set gg_trg_JASS = CreateTrigger(  )
    call TriggerAddAction( gg_trg_JASS, function Trig_JASS_Actions )
endfunction

So basically it returns to me for that variable:

JASS:
udg_TempPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))]

Now I'm a total noob on Jass, but if I put that part in the custom script to clean the leak, it will return the correct value to clean right? =/

EDIT: I have always done it this way.

Indeed, GetConvertedPlayerId will return 1 for Player 1, 2 for Player 2...
I was just speaking on the behalf of using GetPlayerId(whichPlayer) which, in that function, should add +1 like Shadow Daemon said, to make it 'proper Gui'.

Sorry if I confused you:p
 
Level 17
Joined
Jun 12, 2007
Messages
1,261
Indeed, GetConvertedPlayerId will return 1 for Player 1, 2 for Player 2...
I was just speaking on the behalf of using GetPlayerId(whichPlayer) which, in that function, should add +1 like Shadow Daemon said, to make it 'proper Gui'.

Sorry if I confused you:p

It's oke, not confused anymore. ^^
At least I learned something today, but why use GetPlayerId(whichPlayer) instead of GetConvertedPlayerId in gui?
Or is GetConvertedPlayerId something bad? xd
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
GetConvertedPlayerId is simply a BJ function which is unneeded, since it returns GetPlayerId(whichPlayer)+1. In the matter of efficiency it it therefor pointless.

But, I mean, every Gui trigger uses alot of BJ's, so yeah, it doesnt really matter here if you use GetConvertedPlayerId or GetPlayerId(whichPlayer)+1
 
Status
Not open for further replies.
Top