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

[JASS] Need Help, Various Problems

Status
Not open for further replies.
Level 3
Joined
Feb 28, 2012
Messages
19
Hello everyone, i have run into a nasty script/trigger problem and i need your help.
Let me explain what i have and what i am trying to do:
I have a leaderboard, it tracks kills for a North Team and a South Team in a Fight of Characters type map, its title is set and it is created at the beginning of the map in an INIT function

JASS:
function INIT takes nothing returns nothing
set KILLSMENU=DialogCreate()
call DialogSetMessageBJ(KILLSMENU,"Select Goal Kills:")
call DialogAddButtonBJ(KILLSMENU,"20")
set button20=GetLastCreatedButtonBJ()
call DialogAddButtonBJ(KILLSMENU,"40")
set button40=GetLastCreatedButtonBJ()
call DialogAddButtonBJ(KILLSMENU,"60")
set button60=GetLastCreatedButtonBJ()
call DialogAddButtonBJ(KILLSMENU,"80")
set button80=GetLastCreatedButtonBJ()
call DialogAddButtonBJ(KILLSMENU,"100")
set button100=GetLastCreatedButtonBJ()
call DialogDisplayBJ(true,KILLSMENU,Player(0))
call ForGroupBJ(IB(bj_mapInitialPlayableArea),function Xd)
call CreateQuestBJ(0,"General Info","TRIGSTR_1457","generalinfo.blp")
call CreateQuestBJ(0,"Guide","TRIGSTR_1464","guide.blp")
call CreateQuestBJ(0,"Commands","TRIGSTR_1047","generalinfo.blp")
call CreateQuestBJ(0,"Credits","TRIGSTR_1458","credits.blp")
call CreateQuestBJ(0,"Known Bugs","TRIGSTR_1460","bugs.blp")
call CreateQuestBJ(2,"Changelog Part 1","TRIGSTR_1459","changelog.blp")
call CreateQuestBJ(2,"Changelog Part 2","TRIGSTR_9860","changelog.blp")
call CreateQuestBJ(2,"Changelog Part 3","TRIGSTR_9861","changelog.blp")
call CreateQuestBJ(2,"Changelog Part 4","TRIGSTR_9862","changelog.blp")
call CreateQuestBJ(2,"Changelog Part 5","TRIGSTR_9863","changelog.blp")
call DisplayTimedTextToForce(bj_FORCE_PLAYER[0],10.,"TRIGSTR_1465")
call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,10.,"TRIGSTR_1466")
call DisplayTimedTextToForce(bj_FORCE_PLAYER[10],10.,"TRIGSTR_522")
call DisplayTimedTextToForce(bj_FORCE_PLAYER[11],10.,"TRIGSTR_522")
call StopMusic(false)
call SetPlayerStateBJ(Player(0),PLAYER_STATE_RESOURCE_GOLD,175)
call SetPlayerStateBJ(Player(1),PLAYER_STATE_RESOURCE_GOLD,175)
call SetPlayerStateBJ(Player(2),PLAYER_STATE_RESOURCE_GOLD,175)
call SetPlayerStateBJ(Player(3),PLAYER_STATE_RESOURCE_GOLD,175)
call SetPlayerStateBJ(Player(4),PLAYER_STATE_RESOURCE_GOLD,175)
call SetPlayerStateBJ(Player(5),PLAYER_STATE_RESOURCE_GOLD,175)
call SetPlayerStateBJ(Player(6),PLAYER_STATE_RESOURCE_GOLD,175)
call SetPlayerStateBJ(Player(7),PLAYER_STATE_RESOURCE_GOLD,175)
call SetPlayerStateBJ(Player(8),PLAYER_STATE_RESOURCE_GOLD,175)
call SetPlayerStateBJ(Player(9),PLAYER_STATE_RESOURCE_GOLD,175)
call SetPlayerStateBJ(Player(0),PLAYER_STATE_RESOURCE_LUMBER,100000)
call SetPlayerStateBJ(Player(1),PLAYER_STATE_RESOURCE_LUMBER,100000)
call SetPlayerStateBJ(Player(2),PLAYER_STATE_RESOURCE_LUMBER,100000)
call SetPlayerStateBJ(Player(3),PLAYER_STATE_RESOURCE_LUMBER,100000)
call SetPlayerStateBJ(Player(4),PLAYER_STATE_RESOURCE_LUMBER,100000)
call SetPlayerStateBJ(Player(5),PLAYER_STATE_RESOURCE_LUMBER,100000)
call SetPlayerStateBJ(Player(6),PLAYER_STATE_RESOURCE_LUMBER,100000)
call SetPlayerStateBJ(Player(7),PLAYER_STATE_RESOURCE_LUMBER,100000)
call SetPlayerStateBJ(Player(8),PLAYER_STATE_RESOURCE_LUMBER,100000)
call SetPlayerStateBJ(Player(9),PLAYER_STATE_RESOURCE_LUMBER,100000)
call CreateLeaderboardBJ(bj_FORCE_ALL_PLAYERS,"FOCS English 2.7")
set o=bj_lastCreatedLeaderboard
call LeaderboardAddItemBJ(Player(10),o,"|c00ff0000North Team kills :|r",0)
call LeaderboardAddItemBJ(Player(11),o,"|c000000ffSouth Team kills :|r",0)
call LeaderboardDisplayBJ(true,o)
endfunction
The init function also sets various other things and as you can see it creates a dialog to select the number of kills too (which appears and seems to work with no issues), one of the buttons should do this:
JASS:
function BTN20CLK takes nothing returns boolean
if(not(GetClickedButtonBJ()==button20))then
return false
endif
return true
endfunction
function BTN20ACT takes nothing returns nothing
call LeaderboardSetLabel(o, "First to 20 kills wins.")
call EnableTrigger(TRIGVICTORY20)
call DialogDisplayBJ(false,KILLSMENU,Player(0))
endfunction
The TRIGVICTORY20 is a trigger for setting Victory Conditions to 20 kills:
JASS:
set TRIGVICTORY20=CreateTrigger()
call DisableTrigger(TRIGVICTORY20)
call TriggerRegisterAnyUnitEventBJ(TRIGVICTORY20,EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(TRIGVICTORY20,Condition(function HEROCHECK))
call TriggerAddAction(TRIGVICTORY20,function DECVICTORY20)
The HEROCHECK checks if the unit that died is a hero, and the DECVICTORY20 functions checks if the conditions for victory have been fullfilled and if they were it declares victory:
JASS:
function DECVICTORY20 takes nothing returns nothing
set a[(1+GetPlayerId(GetOwningPlayer(GetKillingUnit())))]=(a[(1+GetPlayerId(GetOwningPlayer(GetKillingUnit())))]+1)
set bj_forLoopAIndex=1
set bj_forLoopAIndexEnd=8
loop
exitwhen bj_forLoopAIndex>bj_forLoopAIndexEnd
call LeaderboardSetPlayerItemValueBJ(Player(-1+(bj_forLoopAIndex)),o,a[bj_forLoopAIndex])
set bj_forLoopAIndex=bj_forLoopAIndex+1
endloop
call LeaderboardSetPlayerItemValueBJ(Player(10),o,(GetPlayerScore(Player(0),PLAYER_SCORE_HEROES_KILLED)+(GetPlayerScore(Player(1),PLAYER_SCORE_HEROES_KILLED)+(GetPlayerScore(Player(2),PLAYER_SCORE_HEROES_KILLED)+(GetPlayerScore(Player(3),PLAYER_SCORE_HEROES_KILLED)+GetPlayerScore(Player(4),PLAYER_SCORE_HEROES_KILLED))))))
call LeaderboardSetPlayerItemValueBJ(Player(11),o,(GetPlayerScore(Player(5),PLAYER_SCORE_HEROES_KILLED)+(GetPlayerScore(Player(6),PLAYER_SCORE_HEROES_KILLED)+(GetPlayerScore(Player(7),PLAYER_SCORE_HEROES_KILLED)+(GetPlayerScore(Player(8),PLAYER_SCORE_HEROES_KILLED)+GetPlayerScore(Player(9),PLAYER_SCORE_HEROES_KILLED))))))
if(TNV20())then
call PlaySoundBJ(mapendss)
call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,10.," ")
call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,10.,"North Team has reached |c0000ff0020|r kills !!!")
call TriggerSleepAction(2.0)
call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,10.," ")
call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,10.,"|c00ff0000NORTH TEAM WINS !!!|r")
call TriggerSleepAction(4.6)
call CustomVictoryBJ(Player(0),true,true)
call CustomVictoryBJ(Player(1),true,true)
call CustomVictoryBJ(Player(2),true,true)
call CustomVictoryBJ(Player(3),true,true)
call CustomVictoryBJ(Player(4),true,true)
call CustomVictoryBJ(Player(10),true,true)
call CustomVictoryBJ(Player(11),true,true)
call CustomDefeatBJ(Player(5),"Defeated, shame on you !!!")
call CustomDefeatBJ(Player(6),"Defeated, shame on you !!!")
call CustomDefeatBJ(Player(7),"Defeated, shame on you !!!")
call CustomDefeatBJ(Player(8),"Defeated, shame on you !!!")
call CustomDefeatBJ(Player(9),"Defeated, shame on you !!!")
endif
if(TSV20())then
call PlaySoundBJ(mapendss)
call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,10.," ")
call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,10.,"South Team has reached |c0000ff0020|r kills !!!")
call TriggerSleepAction(2.0)
call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,10.," ")
call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,10.,"|c000000ffSOUTH TEAM WINS !!!|r")
call TriggerSleepAction(4.6)
call CustomVictoryBJ(Player(5),true,true)
call CustomVictoryBJ(Player(6),true,true)
call CustomVictoryBJ(Player(7),true,true)
call CustomVictoryBJ(Player(8),true,true)
call CustomVictoryBJ(Player(9),true,true)
call CustomVictoryBJ(Player(10),true,true)
call CustomVictoryBJ(Player(11),true,true)
call CustomDefeatBJ(Player(0),"Defeated, shame on you !!!")
call CustomDefeatBJ(Player(1),"Defeated, shame on you !!!")
call CustomDefeatBJ(Player(2),"Defeated, shame on you !!!")
call CustomDefeatBJ(Player(3),"Defeated, shame on you !!!")
call CustomDefeatBJ(Player(4),"Defeated, shame on you !!!")
endif
endfunction
The TNV20 and TSV20 functions compare the collective hero kills to a number and return true or false:
JASS:
function TNV20 takes nothing returns boolean
return((GetPlayerScore(Player(0),PLAYER_SCORE_HEROES_KILLED)+(GetPlayerScore(Player(1),PLAYER_SCORE_HEROES_KILLED)+(GetPlayerScore(Player(2),PLAYER_SCORE_HEROES_KILLED)+(GetPlayerScore(Player(3),PLAYER_SCORE_HEROES_KILLED)+GetPlayerScore(Player(4),PLAYER_SCORE_HEROES_KILLED)))))>=20)
endfunction
function TSV20 takes nothing returns boolean
return((GetPlayerScore(Player(5),PLAYER_SCORE_HEROES_KILLED)+(GetPlayerScore(Player(6),PLAYER_SCORE_HEROES_KILLED)+(GetPlayerScore(Player(7),PLAYER_SCORE_HEROES_KILLED)+(GetPlayerScore(Player(8),PLAYER_SCORE_HEROES_KILLED)+GetPlayerScore(Player(9),PLAYER_SCORE_HEROES_KILLED)))))>=20)
endfunction

Now as you can see this doesn't look fundamentally wrong to me, you have a leaderboard and a menu with options for kills, when i press the 20 kills button the leaderboard title should change to the specified one (it doesn't) and the trigger there for counting the score should start counting hero kills to the desired amount and then declare victory once the conditions have been fulfilled, but it does not want to work in any way shape or form (it does not even count the kills).

I lost a full night with this trying all sorts of things like:
1. Create the leaderboard when the button is pressed -> no dice(nothing was created);
2. Using a KILLS=1 integer to set the kill number and not separate functions -> no dice (i was doing set KILLS=20 at the button and the map still finished after 1 kill)
3. I think there were other things but i can't remember now.

Any help would be greatly appreciated since this is the last thing i want to add in the map before i call the FOCS English Project to an end.
Thank you for any help,
The Cl0W

P.S: If i just scrap the menu and the Disable/EnableTrigger stuff setting the number of kills in the TNV and TSV functions works flawlessly, but i want to be able to set it in the game.
 
Level 3
Joined
Feb 28, 2012
Messages
19
hay bro
Could you post the function "Xd" and "HEROCHECK" ?
call ForGroupBJ(IB(bj_mapInitialPlayableArea),function Xd)

HEROCHECK:
JASS:
function HEROCHECK takes nothing returns boolean
return(IsUnitType(GetDyingUnit(),UNIT_TYPE_HERO)!=null)
endfunction

Xd:
JASS:
function Xd takes nothing returns nothing
call TriggerRegisterUnitEvent(lE,GetEnumUnit(),EVENT_UNIT_DAMAGED)
endfunction

Thanks for any help :) .

P.S: If you want i can put the whole script file here if that makes it easier for you to find the problem, i got nothing to hide ;).
 
Level 3
Joined
Feb 28, 2012
Messages
19
Hmmm thanks ill be looking it up now.

L.E: WOW THANKS !!!! Tried the suggestions on the threads that you gave me and it worked flawlessly. <3
You have received +rep and a mention in the credits of the map i am making :) .

A million thanks man.
 
Last edited:
Status
Not open for further replies.
Top