HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Vote Dialog Help

04-18-2007, 08:58 PM#1
Lord of Ketchup
Alright I'm pretty new to the coding style of the campaign editor but not to coding entirely but I've been very stumped with this dumb vote dialog that wont work. Maybe someone could tell me what's wrong?
Here's the first section

Here's the second part


Please excuse me if the coding looks horrendous =[
and if you really need it, here is a link to the map itself.
http://www.megaupload.com/?d=G5NUE0PU


What it's supposed to do is display a dialog that says Allow uber heroes? with yes and no choices. If no wins the vote, then it removes 4 buildings in-game that sell tomes, so no uber heroes are able to be built.
04-18-2007, 10:02 PM#2
Vexorian
Next time use [trigger] tags It takes less time for you (you don't have to take screenshots/upload anything) and it takes less time for us (we don't have to download big images)

--
what's happening now?

I can notice that you may be waiting for every click so you do the actions after the waits many repeated times. It would be better to have an if after assigning yes/no instead of waiting (seems the only way for yes and no to change value is with a click, so a wait is not needed)
04-18-2007, 11:16 PM#3
Zwan
what's not happening? the tome shops not being removed or is there a problem with the dialog buttons?

It seems ok on the surface, but I assume there is more to it as I dont see where you are using the number_voted variable. If you are using that to count the total number of votes then you might want to change the wait to wait till number_voted = number of players.

*edit

I would probably break it up myself. Using the click button event for setting yes and no. And a timer for the vote, performing your if/then's on expiration. Then you avoid the wait entirely.

*edit

here ya go, works now. I just have a thing about avoiding If/then's when possible so I split it up. the number_voted was not needed so I got rid of it.

Trigger:
Vote
Collapse Events
Time - Elapsed game time is 0.02 seconds
Conditions
Collapse Actions
Collapse Player Group - Pick every player in (All players) and do (Actions)
Collapse Loop - Actions
Dialog - Clear vote_dialog
Dialog - Change the title of vote_dialog to Allow Uber Heroes?
Dialog - Create a dialog button for vote_dialog labelled Yes
Set yes_vote = (Last created dialog Button)
Dialog - Create a dialog button for vote_dialog labelled No
Set no_vote = (Last created dialog Button)
Dialog - Show vote_dialog for (Picked player)
-------- // Added timer // --------
Countdown Timer - Start vote_timer as a One-shot timer that will expire in 10.00 seconds
Set vote_timer = (Last started timer)


Trigger:
Yes
Collapse Events
Dialog - A dialog button is clicked for vote_dialog
Collapse Conditions
(Clicked dialog button) Equal to yes_vote
Collapse Actions
Set yes = (yes + 1)

Trigger:
No
Collapse Events
Dialog - A dialog button is clicked for vote_dialog
Collapse Conditions
(Clicked dialog button) Equal to no_vote
Collapse Actions
Set no = (no + 1)

Trigger:
Remove Tome Shops
Collapse Events
Time - vote_timer expires
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
yes Greater than no
Collapse Then - Actions
Game - Display to (All players) the text: (Uber heroes allowed. + ((People who voted yes: + (String(yes))) + (People who voted no: + (String(no)))))
Collapse Else - Actions
Game - Display to (All players) the text: (Uber heroes not allowed. + ((People who voted yes: + (String(yes))) + (People who voted no: + (String(no)))))
Unit - Remove Tome Shop 0051 <gen> from the game
Unit - Remove Tome Shop 0041 <gen> from the game
Unit - Remove Tome Shop 0036 <gen> from the game
Unit - Remove Tome Shop 0045 <gen> from the game
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
yes Equal to no
Collapse Then - Actions
Game - Display to (All players) the text: The vote was a tie....
Unit - Remove Tome Shop 0051 <gen> from the game
Unit - Remove Tome Shop 0041 <gen> from the game
Unit - Remove Tome Shop 0036 <gen> from the game
Unit - Remove Tome Shop 0045 <gen> from the game
Else - Actions
Countdown Timer - Destroy vote_timer
Game - Display to (All players) for 5.00 seconds the text: ((String((yes + no))) + (/ + (String((Number of players in (All players controlled by a User player))))))


I turned off the victory triggers so I could test in WE, and left them off so you can test it.
Attached Files
File type: w3xBuyers and Sellers Resurrected.w3x (112.4 KB)
04-19-2007, 03:10 AM#4
Lord of Ketchup
Alright I'll try replacing some stuff with your code provided tomorrow because I don't have the time tonight, but I did try to open your attached file, and it crashed world edit after giving me a bunch of errors saying "function does not exist" and listed a bunch of functions like DestroyTimer =\
04-19-2007, 05:41 AM#5
Funness
Lok, you are setting the no +1 twice in your trigger, fyi.
04-19-2007, 09:40 AM#6
Zwan
hm, sorry about that Lok, I forgot destroy timer was an added function, here's the map without it. it works fine without destroying the timer, just force of habit for me.
Attached Files
File type: w3xBuyers and Sellers Resurrected.w3x (112.3 KB)
04-19-2007, 11:58 PM#7
Lord of Ketchup
Wow thanks bro I really appreciate all the work and time you guys spent on this.