Player Snippets

Status
Not open for further replies.
L

Ling_Lover

Guest
Race selection
Allows you to select a race in a melee game (random start location and melee defeat condition/starting resources) using dialogs. Set up to use Human, Orc, Undead, Night Elves, Naga.
 

Attachments

  • Select Race (Dialogs).w3x
    202.9 KB · Views: 636

D.K.

New Member
Reaction score
11
Full Share Control

I dont know if this is posted but here it goes Full Shared Control

Code:
Full Shared Unit
    Events
        Time - Every 2.00 seconds of game time
    Conditions
    Actions
        Player Group - Pick every player in (All players) and do (If (((Picked player) is giving Player 1 (Red) Shared units) Equal to True) then do (Player - For (Picked player), turn Full shared units On toward Player 1 (Red)) else do (Do nothing))
        Player Group - Pick every player in (All players) and do (If (((Picked player) is giving Player 2 (Blue) Shared units) Equal to True) then do (Player - For (Picked player), turn Full shared units On toward Player 2 (Blue)) else do (Do nothing))
        Player Group - Pick every player in (All players) and do (If (((Picked player) is giving Player 3 (Teal) Shared units) Equal to True) then do (Player - For (Picked player), turn Full shared units On toward Player 3 (Teal)) else do (Do nothing))
        Player Group - Pick every player in (All players) and do (If (((Picked player) is giving Player 4 (Purple) Shared units) Equal to True) then do (Player - For (Picked player), turn Full shared units On toward Player 4 (Purple)) else do (Do nothing))
        Player Group - Pick every player in (All players) and do (If (((Picked player) is giving Player 5 (Yellow) Shared units) Equal to True) then do (Player - For (Picked player), turn Full shared units On toward Player 5 (Yellow)) else do (Do nothing))
        Player Group - Pick every player in (All players) and do (If (((Picked player) is giving Player 6 (Orange) Shared units) Equal to True) then do (Player - For (Picked player), turn Full shared units On toward Player 6 (Orange)) else do (Do nothing))
        Player Group - Pick every player in (All players) and do (If (((Picked player) is giving Player 7 (Green) Shared units) Equal to True) then do (Player - For (Picked player), turn Full shared units On toward Player 7 (Green)) else do (Do nothing))
        Player Group - Pick every player in (All players) and do (If (((Picked player) is giving Player 8 (Pink) Shared units) Equal to True) then do (Player - For (Picked player), turn Full shared units On toward Player 8 (Pink)) else do (Do nothing))
        Player Group - Pick every player in (All players) and do (If (((Picked player) is giving Player 9 (Gray) Shared units) Equal to True) then do (Player - For (Picked player), turn Full shared units On toward Player 9 (Gray)) else do (Do nothing))
        Player Group - Pick every player in (All players) and do (If (((Picked player) is giving Player 10 (Light Blue) Shared units) Equal to True) then do (Player - For (Picked player), turn Full shared units On toward Player 10 (Light Blue)) else do (Do nothing))
        Player Group - Pick every player in (All players) and do (If (((Picked player) is giving Player 11 (Dark Green) Shared units) Equal to True) then do (Player - For (Picked player), turn Full shared units On toward Player 11 (Dark Green)) else do (Do nothing))
        Player Group - Pick every player in (All players) and do (If (((Picked player) is giving Player 12 (Brown) Shared units) Equal to True) then do (Player - For (Picked player), turn Full shared units On toward Player 12 (Brown)) else do (Do nothing))
 
D

dividedx

Guest
1 Trigger Kick System

Well I made this for the map i'm working on. It uses intergers and substrings instead of having to make 1 trigger for each player(-kick blue, -kick teal, -kick purple, etc). So it's just -kick 'Player #' eg. -kick 2(for blue)

Code:
Kick
    Events
        Player - Player 1 (Red) types a chat message containing -kick as A substring
    Conditions
    Actions
        For each (Integer A) from 1 to 11, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Substring((Entered chat string), 7, 8)) Not equal to (String((Player number of (Player((Integer A))))))
                    Then - Actions
                        *Game - Display to (Player group((Triggering player))) for 5.00 seconds the text: Must enter a player number.
|cffffcc00Ex.|r "-kick 2" For Player 2 (Blue)
                    Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                ((Player((Integer((Substring((Entered chat string), 7, 8)))))) slot status) Equal to Is playing
                            Then - Actions
                                *Unit Group - Pick every unit in (Units owned by (Player((Integer((Substring((Entered chat string), 7, 8))))))) and do (Unit - Remove (Picked unit) from the game)
                                *Player Group - Remove (Player((Integer((Substring((Entered chat string), 7, 8)))))) from (All players)
                                *Game - Display to (All players) for 5.00 seconds the text: (Colors[(Player number of (Player((Integer((Substring((Entered chat string), 7, 8)))))))] + ((Name of (Player((Integer((Substring((Entered chat string), 7, 8))))))) + |r has been kicked.))
                                Game - Defeat (Player((Integer((Substring((Entered chat string), 7, 8)))))) with the message: You have been kicked
                            Else - Actions
                                *Game - Display to (Player group((Triggering player))) for 5.00 seconds the text: The person has to be in the game to kick them.

Note: The items with the * next to them are not required. They just spice it up. Although the player group and unit group functions are recommended, unless u want to share the units between the other players.

Cheers.
 

SomeGuy333

New Member
Reaction score
6
kic system for red, dialog based.
hides all units owned by player can be easily changed to just end them in defeat.
Code:
Untitled Trigger 003
    Events
        Player - Player 1 (Red) types a chat message containing -kick as An exact match
    Conditions
    Actions
        Dialog - Clear REDKICKdialog
        Dialog - Change the title of REDKICKdialog to Kick who?
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Player 2 (Blue) controller) Equal to User
                (Player 2 (Blue) slot status) Equal to Is playing
            Then - Actions
                Dialog - Create a dialog button for REDKICKdialog labelled ((|cff0000FF + (Name of Player 2 (Blue))) + |r)
                Set kickplayercolorname[1] = (Last created dialog Button)
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Player 3 (Teal) controller) Equal to User
                (Player 3 (Teal) slot status) Equal to Is playing
            Then - Actions
                Dialog - Create a dialog button for REDKICKdialog labelled ((|cff00FFFF + (Name of Player 3 (Teal))) + |r)
                Set kickplayercolorname[2] = (Last created dialog Button)
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Player 4 (Purple) slot status) Equal to Is playing
                (Player 4 (Purple) controller) Equal to User
            Then - Actions
                Dialog - Create a dialog button for REDKICKdialog labelled ((|cffA020F0 + (Name of Player 4 (Purple))) + |r)
                Set kickplayercolorname[3] = (Last created dialog Button)
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Player 5 (Yellow) controller) Equal to User
                (Player 5 (Yellow) slot status) Equal to Is playing
            Then - Actions
                Dialog - Create a dialog button for REDKICKdialog labelled ((|cffFFFF00 + (Name of Player 5 (Yellow))) + |r)
                Set kickplayercolorname[4] = (Last created dialog Button)
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Player 6 (Orange) controller) Equal to User
                (Player 6 (Orange) slot status) Equal to Is playing
            Then - Actions
                Dialog - Create a dialog button for REDKICKdialog labelled ((|cffFFA500 + (Name of Player 6 (Orange))) + |r)
                Set kickplayercolorname[5] = (Last created dialog Button)
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Player 7 (Green) slot status) Equal to Is playing
                (Player 7 (Green) controller) Equal to User
            Then - Actions
                Dialog - Create a dialog button for REDKICKdialog labelled ((|cff00FF00 + (Name of Player 7 (Green))) + |r)
                Set kickplayercolorname[6] = (Last created dialog Button)
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Player 8 (Pink) slot status) Equal to Is playing
                (Player 8 (Pink) controller) Equal to User
            Then - Actions
                Dialog - Create a dialog button for REDKICKdialog labelled ((|cffFFC0CB + (Name of Player 8 (Pink))) + |r)
                Set kickplayercolorname[8] = (Last created dialog Button)
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Player 9 (Gray) slot status) Equal to Is playing
                (Player 9 (Gray) controller) Equal to User
            Then - Actions
                Dialog - Create a dialog button for REDKICKdialog labelled ((|cffA9A9A9 + (Name of Player 9 (Gray))) + |r)
                Set kickplayercolorname[9] = (Last created dialog Button)
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Player 10 (Light Blue) slot status) Equal to Is playing
                (Player 10 (Light Blue) controller) Equal to User
            Then - Actions
                Dialog - Create a dialog button for REDKICKdialog labelled ((|cff00BFFF + (Name of Player 10 (Light Blue))) + |r)
                Set kickplayercolorname[10] = (Last created dialog Button)
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Player 11 (Dark Green) slot status) Equal to Is playing
                (Player 11 (Dark Green) controller) Equal to User
            Then - Actions
                Dialog - Create a dialog button for REDKICKdialog labelled ((|cff006400 + (Name of Player 11 (Dark Green))) + |r)
                Set kickplayercolorname[11] = (Last created dialog Button)
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Player 12 (Brown) slot status) Equal to Is playing
                (Player 12 (Brown) controller) Equal to User
            Then - Actions
                Dialog - Create a dialog button for REDKICKdialog labelled ((|cffA52A2A + (Name of Player 12 (Brown))) + |r)
                Set kickplayercolorname[6] = (Last created dialog Button)
            Else - Actions
        Dialog - Create a dialog button for REDKICKdialog labelled never mind
        Dialog - Show REDKICKdialog for Player 1 (Red)


Code:
Untitled Trigger 004
    Events
        Dialog - A dialog button is clicked for REDKICKdialog
    Conditions
    Actions
        If ((Clicked dialog button) Equal to kickplayercolorname[1]) then do (Unit Group - Pick every unit in (Units owned by Player 2 (Blue)) and do (Unit - Hide (Picked unit))) else do (Do nothing)
        If ((Clicked dialog button) Equal to kickplayercolorname[2]) then do (Unit Group - Pick every unit in (Units owned by Player 3 (Teal)) and do (Unit - Hide (Picked unit))) else do (Do nothing)
        If ((Clicked dialog button) Equal to kickplayercolorname[3]) then do (Unit Group - Pick every unit in (Units owned by Player 4 (Purple)) and do (Unit - Hide (Picked unit))) else do (Do nothing)
        If ((Clicked dialog button) Equal to kickplayercolorname[4]) then do (Unit Group - Pick every unit in (Units owned by Player 5 (Yellow)) and do (Unit - Hide (Picked unit))) else do (Do nothing)
        If ((Clicked dialog button) Equal to kickplayercolorname[5]) then do (Unit Group - Pick every unit in (Units owned by Player 6 (Orange)) and do (Unit - Hide (Picked unit))) else do (Do nothing)
        If ((Clicked dialog button) Equal to kickplayercolorname[6]) then do (Unit Group - Pick every unit in (Units owned by Player 7 (Green)) and do (Unit - Hide (Picked unit))) else do (Do nothing)
        If ((Clicked dialog button) Equal to kickplayercolorname[7]) then do (Unit Group - Pick every unit in (Units owned by Player 8 (Pink)) and do (Unit - Hide (Picked unit))) else do (Do nothing)
        If ((Clicked dialog button) Equal to kickplayercolorname[8]) then do (Unit Group - Pick every unit in (Units owned by Player 9 (Gray)) and do (Unit - Hide (Picked unit))) else do (Do nothing)
        If ((Clicked dialog button) Equal to kickplayercolorname[9]) then do (Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue)) and do (Unit - Hide (Picked unit))) else do (Do nothing)
        If ((Clicked dialog button) Equal to kickplayercolorname[10]) then do (Unit Group - Pick every unit in (Units owned by Player 11 (Dark Green)) and do (Unit - Hide (Picked unit))) else do (Do nothing)
        If ((Clicked dialog button) Equal to kickplayercolorname[11]) then do (Unit Group - Pick every unit in (Units owned by Player 12 (Brown)) and do (Unit - Hide (Picked unit))) else do (Do nothing)
 

Attachments

  • kicker system.w3x
    10.8 KB · Views: 545

Rad

...
Reaction score
228
Working Player-Owned Item system

Code:
Item Keeps
    Events
        Unit - A unit Acquires an item
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Owner of (Hero manipulating item)) controller) Equal to User
                Or - Any (Conditions) are true
                    Conditions
                        (Custom value of (Item being manipulated)) Equal to 0
                        (Custom value of (Item being manipulated)) Greater than 12
            Then - Actions
                Item - Set the custom value of (Item being manipulated) to (Player number of (Owner of (Hero manipulating item)))
            Else - Actions
                Hero - Drop (Item being manipulated) from (Hero manipulating item)
                Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: This item does not ...

Works for all players 1-12 (USERS). If any player between 1-12 are computers then add them to the OR. Items will drop from computer owned heroes when acquired!
 

Cloak_Master

Active Member
Reaction score
41
I did some looking around and noticed that there was already a vote-kick trigger, but I also realized that mine works much differently and it's streamlined for it's task. It includes an admin list, where you can fill in admins, which will be the people who can't be booted. You can set admin power to true, which makes there vote automatically kick the player. And there also is a banlist, which will immidiately kick the player even if there are no votes aganist him. Once you type -kick, it will open up a list asking who you want to kick, the list is color coded and done by name. Once you select somebody, it asks everyone else to vote. The same player cannot use this twice in a row. You can, however, cancel out with the cancel button. More details of updates and such are included in notes. This can be immediately implemented into any map, works for all USER players 1-12, omitting computers. Uses three triggers to accomplish all this.

(NOTE: The trigger stucture and execution is done from scratch. I did not copy anyone, you may look for yourself. Thank you.)
 

mase

____ ___ ____ __
Reaction score
154
Improved release of the previous kick-vote system.

With sample map and dialog based.
 

Attachments

  • VK.w3x
    20.8 KB · Views: 558

U are a noob

Mega Super Ultra Cool Member
Reaction score
152
Anti Team Attack

This will stop team mates from attacking each other.

Code:
Anti Team Attack
    Events
        Unit - A unit Is attacked
    Conditions
        ((Attacking unit) belongs to an ally of (Owner of (Attacked unit))) Equal to True
        ((Attacking unit) is A Hero) Equal to True
    Actions
        Unit - Order (Attacking unit) to Stop

This is great for AoSs.
 

Grundy

Ultra Cool Member
Reaction score
35
Preventing Map Leaks on Battle.net

if you're like me, you dont have a group of people to test your map with, but you still want to test it with other people. so you gotta play a public game on bnet. but also, you don't want incomplete/test versions of your map leaking around. so heres how you prevent that:

Code:
Check For Tester
    Events
        Time - Elapsed game time is 2.00 seconds
    Conditions
    Actions
        Game - Display to (All players) the text: (This is a |cff00aa00test version|r of the game. To prevent it from leaking, you can ONLY play a test version when |cffff0000 + (STR_Tester + (|r is in the game with you. You can try give |cffff0000 + (STR_Tester + |r a whisper on Battle.net if you want to try to get a public version of the map.))))
        Player Group - Pick every player in (All players) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (String((Name of (Picked player))) as Lower case) Equal to (String(STR_Tester) as Lower case)
                    Then - Actions
                        Set BOOL_TesterInGame = True
                    Else - Actions
                        Do Nothing
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                BOOL_TesterInGame Equal to False
            Then - Actions
                Unit - Pause all units
                Wait 5.00 seconds
                Game - Display to (All players) for 20.00 seconds the text: ============================================================
                Game - Display to (All players) for 20.00 seconds the text: (|cffff0000 + (STR_Tester + |r was not found in game.))
                Game - Display to (All players) for 20.00 seconds the text: Game ending in |cff0000ff15|r seconds....
                Wait 15.00 seconds
                Player Group - Pick every player in (All players) and do (Actions)
                    Loop - Actions
                        Game - Defeat (Picked player) with the message: Bye!
            Else - Actions
                Do Nothing

2 things to make note of:
1. variables - you need 2 variables for this trigger, a string variable that i have named STR_Tester initialized to my name on battle.net and a boolean variable that i called BOOL_TesterInGame initialized to false. you do not NEED to use the string variable, you could just type in the name when you do the string comparision, but then you would also have to change it in all of the game messages too, if you just use a variable you can simply change the variable once instead of changing the name in each action.

2. if you want to test your map from the world editor (File -> Test Map) then you need to make sure you set your Player Profile in WE to your the same name you put in the STR_Tester variable. (File -> Preferences -> Test Map -> Player Profile)

3. if you're really worried about a couple of name spoofers then all you have to do is change your battle.net name in the Game Message to "the map creator" or whatever and then no one will even know what name you have to spoof with
 

jpres

New Member
Reaction score
15
D&D - Making it so DMs can make their own quests.

IF YOU WANT TO, YOU CAN DOWNLOAD THE TRIGGERS INSTEAD OF WORKING THEM ALL OUT. THEY ARE ATTACHED TO THE POST.


I bet some of you have been wondering.. How can I make it so in my game I can have a certain player create quests? Well, with this tutorial you will be able to have a player or player(s) create up to 9 quests total with no bugs(as far as I know).
The players can set the quests name, description, delete quests, and even add more text to the quests. Remember, this is only 9 total quests, not 9 each.

So here's how it works.
First-Create 3 Variables and have them all have arrays.

Create a Quest variable with an array, and label the variable 'Quest'.
Create a String variable with an array, and label the variable 'QuestAvailable'.
Create a String variable with an array, and label the variable 'QuestScription'.

Now for your first trigger, put this in.
Code:
CreateQuest
    Events
        Player - Player 1 (Red) types a chat message containing CQ as A substring
    Conditions
        (Substring((Entered chat string), 1, 2)) Equal to CQ
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                QuestAvailable[(Integer((Substring((Entered chat string), 3, 3))))] Equal to taken
            Then - Actions
                Game - Display to (Player group((Triggering player))) the text: Sorry, but that que...
                Skip remaining actions
            Else - Actions
        Set QuestAvailable[(Integer((Substring((Entered chat string), 3, 3))))] = taken
        Quest - Create a Required quest titled (Substring((Entered chat string), 5, (Length of (Entered chat string)))) with the description <Empty String>, using icon path ReplaceableTextures\CommandButtons\BTNAmbush.blp
        Set Quest[(Integer((Substring((Entered chat string), 3, 3))))] = (Last created quest)

For your second trigger, use this.
Code:
QuestDescription
    Events
        Player - Player 1 (Red) types a chat message containing CD as A substring
    Conditions
        (Substring((Entered chat string), 1, 2)) Equal to CD
    Actions
        Quest - Change the description of Quest[(Integer((Substring((Entered chat string), 3, 3))))] to (Substring((Entered chat string), 5, (Length of (Entered chat string))))
        Set QuestScription[(Integer((Substring((Entered chat string), 3, 3))))] = (Substring((Entered chat string), 5, (Length of (Entered chat string))))

For your third trigger, use this.
Code:
AddtoQuest
    Events
        Player - Player 1 (Red) types a chat message containing AD as A substring
    Conditions
        (Substring((Entered chat string), 1, 2)) Equal to AD
    Actions
        Set QuestScription[(Integer((Substring((Entered chat string), 3, 3))))] = (QuestScription[(Integer((Substring((Entered chat string), 3, 3))))] + (Substring((Entered chat string), 5, (Length of (Entered chat string)))))
        Quest - Change the description of Quest[(Integer((Substring((Entered chat string), 3, 3))))] to QuestScription[(Integer((Substring((Entered chat string), 3, 3))))]

For your fourth trigger, use this.
Code:
DeleteQuest
    Events
        Player - Player 1 (Red) types a chat message containing DQ as A substring
    Conditions
        (Substring((Entered chat string), 1, 2)) Equal to DQ
    Actions
        Quest - Destroy Quest[(Integer((Substring((Entered chat string), 3, 3))))]
        Set QuestAvailable[(Integer((Substring((Entered chat string), 3, 3))))] = <Empty String>

And there ya go! Player 1 can now create/add info to/set the description for a quest.

Here are the commands.

AQ# (QuestName) -- Replace the # sign with the number for quest. Replace (QuestName) with the title of the quest.

DQ# -- Replace the # sign with the number for quest. This will delete that quest.

CD# (QuestInfo) -- Replace the # sign with the number for quest. Replace (QuestInfo) with the description desired for that quest.

AD# (ExtraQuestInfo) - Replace the # sign with the number for quest. Replace (ExtraQuestInfo) with the extra info you would like added to your quest.


I hope you someone can put this to good use in your map! :) - Jpres
 

Tonks

New Member
Reaction score
160
Your Personal Kicking Trigger:

This is a trigger to make it so that you, and only you can kick. NOTE: I will include a map with the trigger on it, and I will also tell you how to make a generic Kick function for Player 1 (Red). *The kick function for Red that I will be showing you will be disabled if you are in the game, neat, eh? :D*

Code:
[B][U]Kick Function[/U]-[/B]
[B]Events-[/B]
Player 1 (Red) types a chat message containing -kick as A substring
[I]*Repeat for all player slots available in-game.*[/I]
[B]Condition-[/B]
((Name of (Triggering player)) equal to [U][I]TimmyTonks[/I][/U])
[B]Action-[/B]
If ((Substring((Entered chat string), 7, 8)) Equal to [B][U]1[/U][/B]) then do (Game- Defeat Player 1 (Red) with the message: You have been kicked...) else do (Do nothing)
[I]*Repeat this procedure for Blue to Brown. The function would be -kick 1 to kick red, -kick 2 to kick blue, -kick 3 for teal, and so on. The number after "If ((Substring((Entered chat string), 7, 8)) Equal to" is the number you would type to kick a player, so if you put a 2 in that spot, you would make it then do (Game- Defeat Player 2 (Blue)... Got it? Good. :)*[/I]

Now for the Generic "Red Kick Function".

Code:
[B][U]Red Kick Function[/U][/B]-
[B]Events-[/B]
Player 1 (Red) types a chat message containing -kick as A substring
[I]*Do NOT repeat for all players this time.*[/I]
[B]Conditions-[/B]
((Name of (Player 1 (Red))) Not equal to [U]TimmyTonks[/U])
[I]*Repeat for all players. NOTE: ONLY put this condition IF you want it so Red cannot kick while you are in the game. This will make it so that Red's kick function will not work at all, but you will still be able to kick.*[/I]
[B]Actions-[/B]
If ((Substring((Entered chat string), 7, 8)) Equal to 1) then do (Game- Defeat Player 1 (Red) with the message: You have been kicked...) else do (Do nothing)
Repeat this procedure for Blue to Dark Green. The function would be -kick 1 to kick red, -kick 2 to kick blue, -kick 3 for teal, and so on. The number after "If ((Substring((Entered chat string), 7, 8)) Equal to" is the number you would type to kick a player, so if you put a 2 in that spot, you would make it then do (Game- Defeat Player 2 (Blue)...

Attached below is a sample map with the Kick functions. If you decide to use those triggers, please put my name in the map somewhere, just a little mention. Also, if you do use them, you will have to change the name from TimmyTonks to (Your name). Good luck :)
I reserve the right to remove or reattach the abovementioned map for any reason at any given time.
 

Attachments

  • Example Kicking Triggers.w3m
    18.1 KB · Views: 418

Tonks

New Member
Reaction score
160
Gold Distribution on Leaving

NOTE: I made this for ROC editor. There may be simpler ways on TFT, but seeing as not all of us have it, I figured some ROC editor people might want it.
I recently created this trigger for TheRat, but I figured it might help others, as well. What it does is it checks which players are in the game, checks how much gold the leaving player had, then it distributes said gold evenly among the remaining players. This could come in very handy in a TD or a Footman Wars. (Or anything where gold is extremely useful)
First, you will need two variables. One will be called Player_Gold and one will be called Players. Both will be Integer variables and both will have 0 value as default.
Code:
[B]Event-[/B]
Time- Every [U]5.00[/U] seconds of game time
[B]Condition-[/B]
(Player 1 (Red) slot status) Equal to Has left the game
[B]Action-[/B]
Trigger- Turn off (This trigger)
Set [I]Player_Gold[/I] = (Player 1 (Red) Current Gold)
Set [I]Players[/I] = (Number of players in (All players matching (((Matching player) slot status) Equal to Is playing)))
Player Group- Pick every player in (All players matching (((Matching player) slot status) Equal to Is playing)) and do (Player- (Add [I]Player_Gold[/I] / [I]Players[/I]) to (Picked player) Current Gold)
NOTE: Underline = Change-able. Italics = Variable. Repeat this trigger for all players that can play in your map.
I hope this works for everyone. :)
Below is attached an example map with the trigger on it. (In case you're too lazy to make it yourself :p)
I reserve the right to remove or reattach the abovementioned map for any reason at any given time.
 

Attachments

  • Distribute_Gold_Example_Map.w3m
    16.3 KB · Views: 386

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
If you have ever wondered how to play a certain sound for only one player, but haven't figured it out/found the answer, then wonder no more!

These 3 functions allow you to play sounds to a certain player (Who is the only one, who hears the played sound).


Copy&Paste the JASS functions into your maps header.

Plays a regular sound for 1 player.
JASS:
function PlaySoundForPlayer takes player WhichPlayer, sound WhichSound returns nothing
    if ( GetLocalPlayer() == WhichPlayer ) then
        call PlaySoundBJ( WhichSound )
    endif
endfunction


Example:

Code:
Play Sound For Player
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Play Sound For Player
    Actions
        Set TmpSound = Credits <gen>
        Set TmpPlayer = (Owner of (Triggering unit))
        Custom script:   call PlaySoundForPlayer( udg_TmpPlayer, udg_TmpSound )

Plays a 3D sounds for 1 player at a location.
JASS:
function PlaySoundForPlayerAtLoc takes player WhichPlayer, sound WhichSound, location WhichLocation, real Volume returns nothing
    local real x = GetLocationX(WhichLocation)
    local real y = GetLocationY(WhichLocation)
    
    if ( GetLocalPlayer() == WhichPlayer ) then
        call SetSoundPosition( WhichSound, x, y, 0.00 )
        call SetSoundVolumeBJ( WhichSound, Volume )
        call PlaySoundBJ(WhichSound)
    endif
endfunction


Example:


Code:
Play Sound For Player At Loc
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Play Sound For Player At Loc
    Actions
        Set TmpSound = Credits <gen>
        Set TmpPlayer = (Owner of (Triggering unit))
        Set TmpPoint = (Position of (Triggering unit))
        Custom script:   call PlaySoundForPlayerAtLoc( udg_TmpPlayer, udg_TmpSound, udg_TmpPoint, 100.00 )

Plays a 3D sound for 1 player on an unit.
JASS:
function PlaySoundForPlayerOnUnit takes player WhichPlayer, sound WhichSound, unit WhichUnit, real Volume returns nothing
    if ( GetLocalPlayer() == WhichPlayer ) then
        call AttachSoundToUnit( WhichSound, WhichUnit )
        call SetSoundVolumeBJ( WhichSound, Volume )
        call PlaySoundBJ(WhichSound)  
    endif
endfunction


Example:

Code:
Play Sound For Player On Unit
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Play Sound For Player On Unit
    Actions
        Set TmpSound = Credits <gen>
        Set TmpUnit = (Triggering unit)
        Set TmpPlayer = (Owner of TmpUnit)
        Custom script:   call PlaySoundForPlayerOnUnit( udg_TmpPlayer, udg_TmpSound, udg_TmpUnit, 100.00 )
 

BlueSin

New Member
Reaction score
37
[System] JASS KeyisDown Function

Ever wanted a KeyisDown function that will return true or false for a player and key? Well I just made that per request of a friend. Keep in mind, however, I haven't played warcraft in a very long time and no longer have it installed, so this might not be up to date in terms of Jass (I don't know if anything new was added and such) and it hasn't been tested, but it should work, I don't see why it wouldn't.

Simply add this to the header of your map:

JASS:
//**************************
//         JASS KeyisDown
//            BlueSin with help from Pyrogasm
//**************************

globals
    trigger gg_trg_KeyDetect
    boolean array KeyDown
    integer left = 0
    integer right = 1
    integer down = 2
    integer up = 3
endglobals

function KeyisDown takes integer key, integer pnum returns boolean
    return KeyDown[4*pnum+key]
endfunction

function KeyDetect takes nothing returns boolean
    local eventid Event = GetTriggerEventId()
    if Event == EVENT_PLAYER_ARROW_RIGHT_DOWN then
        set KeyDown[4*GetPlayerId(GetTriggerPlayer())+right]=true
    elseif Event == EVENT_PLAYER_ARROW_RIGHT_UP
        set KeyDown[4*GetPlayerId(GetTriggerPlayer())+right]=false
    elseif Event == EVENT_PLAYER_ARROW_LEFT_DOWN
        set KeyDown[4*GetPlayerId(GetTriggerPlayer())+left]=true
    elseif Event == EVENT_PLAYER_ARROW_LEFT_UP
        set KeyDown[4*GetPlayerId(GetTriggerPlayer())+left]=false
    elseif Event == EVENT_PLAYER_ARROW_DOWN_DOWN
        set KeyDown[4*GetPlayerId(GetTriggerPlayer())+down]=true
    elseif Event == EVENT_PLAYER_ARROW_DOWN_UP
        set KeyDown[4*GetPlayerId(GetTriggerPlayer())+down]=false
    elseif Event == EVENT_PLAYER_ARROW_UP_DOWN 
        set KeyDown[4*GetPlayerId(GetTriggerPlayer())+up]=true
    elseif Event == EVENT_PLAYER_ARROW_UP_UP
        set KeyDown[4*GetPlayerId(GetTriggerPlayer())+up]=false
    endif  
    set Event = null
    return false
endfunction

function InitTrig_KeyDetect takes nothing returns nothing
    local integer i = 0
    set gg_trg_KeyDetect = CreateTrigger(  )
    loop
        call TriggerRegisterPlayerEvent( gg_trg_KeyDetect, Player(i), EVENT_PLAYER_ARROW_RIGHT_DOWN )
        call TriggerRegisterPlayerEvent( gg_trg_KeyDetect, Player(i), EVENT_PLAYER_ARROW_RIGHT_UP )
        call TriggerRegisterPlayerEvent( gg_trg_KeyDetect, Player(i), EVENT_PLAYER_ARROW_LEFT_DOWN )
        call TriggerRegisterPlayerEvent( gg_trg_KeyDetect, Player(i), EVENT_PLAYER_ARROW_LEFT_UP )
        call TriggerRegisterPlayerEvent( gg_trg_KeyDetect, Player(i), EVENT_PLAYER_ARROW_DOWN_DOWN )
        call TriggerRegisterPlayerEvent( gg_trg_KeyDetect, Player(i), EVENT_PLAYER_ARROW_DOWN_UP )
        call TriggerRegisterPlayerEvent( gg_trg_KeyDetect, Player(i), EVENT_PLAYER_ARROW_UP_DOWN )
        call TriggerRegisterPlayerEvent( gg_trg_KeyDetect, Player(i), EVENT_PLAYER_ARROW_UP_UP )
        set i = i +1
        exitwhen i &gt; 11
    endloop
    call TriggerAddCondition( gg_trg_KeyDetect, function KeyDetect )
endfunction


Then you can call the function in jass or with GUI custom script like this, for example:

JASS:
if KeyisDown(left, 0) then
//do stuff, like move something left
endif


Where left is the key (notice you can use the defined keywords left, right, down, & up) and 0 is the player number.

I think it'd be useful in use for many different event scenarios, like timers or when something in particular happens, whatever. If these functions are deprecated in any way (I've been out of the game as I said) just say so.
 
Status
Not open for further replies.
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top