| 01-16-2005, 01:28 PM | #1 |
Firstly id like to start off by saying i already know how to get the keyboard to work. i have 9 triggers and it works alright. my problem is that my map has 10 players and this walking trigger only works with 1 player. This means that i would have to make 90 triggers. Here is the code, i got it off of a tutorial section here and changed it a bit. Make Guys Action Time - Elapsed game time is 0.10 seconds Event For each (Integer A) from 1 to 10, do (Actions) Loop - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions ((Player((Integer A))) slot status) Equal to Is playing Then - Actions Unit - Create 1 STARS member (barretta) for (Player((Integer A))) at ((Player((Integer A))) start location) facing Default building facing degrees Set keeptrackunits[(Integer A)] = (Last created unit) Else - Actions Do nothing Wait 0.10 seconds Trigger - Turn on CamLock <gen> This trigger just creates guys and give a variable to them if they are playing. Here is the actualy pushing of a button part. Hitleft Event Player - Player 1 (Red) Presses the Left Arrow key Action Set Left[1] = True Trigger - Run TurnLeft <gen> (checking conditions) Trigger - Run TurnRight <gen> (checking conditions) Trigger - Run MoveForward <gen> (checking conditions) this just sets the variable left to true saying that its being pressed. here is the one that realese it. RealeaseLeft Event Player - Player 1 (Red) Releases the Left Arrow key Action Set Left[1] = False Now for both those triggers there are 3 of them one for left, right and up all changing the variable names. here are the 3 other triggers that move TurnLeft Events Time - Every 0.20 seconds of game time Conditions Left[1] Equal to True Right[1] Equal to False Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions Up[1] Equal to True Then - Actions Unit - Order keeptrackunits[1] to Move To ((Position of keeptrackunits[1]) offset by 100.00 towards ((Facing of keeptrackunits[1]) + 10.00) degrees) Else - Actions Unit - Make keeptrackunits[1] face ((Position of keeptrackunits[1]) offset by 12.00 towards ((Facing of keeptrackunits[1]) + 15.00) degrees) over 0.10 seconds You can see that if right isnt being pushed and left is it will do a IF/Then/Else saying if the variable 'Up' is being pushed it will move a different position with an angular offset. My question again is how do i make this so that all players can use this instead of making 90 triggers |
| 01-16-2005, 01:56 PM | #2 |
well, since u'r in need of anything, i can give you some ideas.... altho i never liked that arrow key movement idea..... no, scratch that idea, i'll just spam you with this and warn you - i think that map is gonna lag like hell...... with 10 players changing the variables all the time every 0.2 seconds and moving like what.... 20 units in all directions five times a second ? i don't know...... the only thing that crosses my mind is code recycling.... which means that u make a general trigger which will be checking the trigger that called it, and then direct it to another trigger that coresponds with the callin trigger..... something like this Player 1 presses the keys - set boolean player1called player 2 presses the keys - set boolean player2 called ......... the moving trigger: if this trigger was called by player1keys and player1called = true then do stuff and run player1movement trigger else do nothing and so on....... but somehow i don't think that WE has the "trigger was called by <trigger>" condition, nor that it could be done thru jass (not sure on that one tho) so that will minimize your code to like..... 20 triggs ? maybe 30..... you're free to consider this spam, or just ignore it, as im not very skilled in the arrowkeys movement tehniques/mechanisms :) EDIT: ok, ok, i got something...... the third trigger you posted, look at the indexes..... if Left[1] equals to true if Right[1] equals to false if you do For integer A equals 1 to 10 and put the whole third trigger into that, changing the [1] (indexes of 1) into [Integer A] (indexes of integer A) it will run the check for all 10 players...... For Integer A equals 1 to 10 if left[integer A] equals to true If right[integer A] equals to false ..... i hope you get the picture :) at least its recycling :) but i still stick with the previous post (before the EDIT part)...... EDIT 2: hmmm...... if you can make a trigger like this E: a Player presses a key C: key-pressed equals to Left Key A: if triggering player equals to player 1, then set Left[1] to true ..... or E: Player 1 presses a key A: if pressed key equals left then set Left[1] to true and Right[1] to false else nothing A: if pressed key queals right then set Right[1] to true and Left[1] to false else nothing but the ideal one would be either this one vv E: A Player presses a key A: if pressed key equals left then set Left[player index of (triggering player)] to TRUE and right[player index of (triggering player)] to FALSE else do nothing (this way you would have 4 lines, left1-right0; left0-right1; up1-down0; up0-down1) OR a player presses a left key, with the Pressing Player comparison eg - A left key is pressed, if the player pressing the key is 1, then set Left[1] if the player pressing the key is 2, then set Left[2] a player1 presses a key, with the pressing key comparison... if the key_being_pressed is Left, then set Left[1] if the key being pressed is Right, then set Right[1] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ the more generic the trigger, the better - because it is more reusable and flexible... imagine it as a "something happens" and then applying filters like "if this happened to this guy" because the triggers you are using are "this happened to this guy" and thats it ! you can't reuse it because it fires only when that happens to that guy..... but if u use a triger like "something happens" or even better -> "anything happens" you can apply the IFs or IFFs to shape it to your liking.... something like taking a piece of clay and shaping it.... you have to adjust to its primary package (is it a cube ? a poliedar ? a ball ? a lump) and then do the comparisons...... if its a cube, you hit it 10 times, if its a ball, you just roll it thin.... but the event would be " I found clay " not "i found 5 pounds of cubic-pakaged red clay" because that is already specificaly-defined and cannot be reused in the code.... well, i just hope i didn't confused you..... try to use generic triggers and then shape them (if u really have to) because its easier for the computer to run one thing and check what happened and then to do the other instead of trying to do 20 things at once (at least, thats the way i think of it) :))) |
| 01-16-2005, 02:21 PM | #3 |
the variables Left Right and Up are all indexes. my problem is that the conditions have no way on doing loops. Ill try to do what u said. I also will take into consideration of the lag. I only got 3 computers that i can use to test if all the keybord functions would cause anylag Edit: Your second edit was kinda like over my head but i still got the vastmajority of it. thanks for your help ill try to do waht u said. |
| 01-16-2005, 02:37 PM | #4 |
I think i got it actually. In the map initialization i told it to add the moveforward, turnright, turnleft triggers to 3 different trigger arrays. Ill have to make 10 of each for each play. Then for calling them i can change the hitleft to this HitLeft Events Player - Player 1 (Red) Presses the Left Arrow key Player - Player 2 (Blue) Presses the Left Arrow key Player - Player 3 (Teal) Presses the Left Arrow key Player - Player 4 (Purple) Presses the Left Arrow key Player - Player 5 (Yellow) Presses the Left Arrow key Player - Player 6 (Orange) Presses the Left Arrow key Player - Player 7 (Green) Presses the Left Arrow key Player - Player 8 (Pink) Presses the Left Arrow key Player - Player 9 (Gray) Presses the Left Arrow key Player - Player 10 (Light Blue) Presses the Left Arrow key Conditions Actions Set Left[(Player number of (Triggering player))] = True Trigger - Run Turnleftvar[(Player number of (Triggering player))] (checking conditions) Trigger - Run Turnrightvar[(Player number of (Triggering player))] (checking conditions) Trigger - Run Movefarwardvar[(Player number of (Triggering player))] (checking conditions) And the same thing for the other 2. Instead of like 90 triggers it can be like maybe only 30-40 |
| 01-16-2005, 02:39 PM | #5 |
well, u'r tesing it on a 3player ethernet.... imagine a 10 player broad-band (BNet) game :)) and i hope i helped..... |
| 01-16-2005, 03:15 PM | #6 |
ethernet is such a funny word lol. and it didnt really help cause i already knew that. maybe playing on my old comps from like 98 will give a more accurate gameplay. those things are like dinasaurs. my dad has like a dozen of them |
| 01-16-2005, 05:12 PM | #7 |
well, u'r getting somewhere....... i totaly forgot that u can use multiple events and that the trigger will fire for each of them :))))) good job :) @testing....... why don't u just test it out on BNet ?:))) |
| 01-17-2005, 03:09 AM | #8 |
Becasue i have a little something called a router :( my dad wont open up ports. and he cant disable it becasue the router allows all dozens of our comps to be on the net at once. Currently i got 3 in my room hooked up to the internet. like 5 or 6 in my dads office and my mom has 1. so we all have to share the internet. Pluse for testing i got absolutely nothing to test. the main plot isnt even down. im having trouble with the weapon/reloading system. I prolly want to have someting like in the map 'we were snipers' however its entirely in JASS and i got lost. |
