Doug
New Member
- Reaction score
- 1
Dougleton Alliance System
version 1.5
by Doug
This is a vJASS player alliance system easy to implement as long as you have JASS New Gen Pack. Even if you're only experienced with GUI, you can easily implement this system into your map. The system allows players to ally or unally each other in game via -ally color and -unally color (-ally/unally player name or -ally number/-unally number even) chat messages.
The Code
version 1.5
by Doug
This is a vJASS player alliance system easy to implement as long as you have JASS New Gen Pack. Even if you're only experienced with GUI, you can easily implement this system into your map. The system allows players to ally or unally each other in game via -ally color and -unally color (-ally/unally player name or -ally number/-unally number even) chat messages.
Features
+ Extremely easy to implement.+ You can type out the full color name or abreviations when using -ally or -unally. Some examples: -ally lightblue -ally lb -unally orange -ally oj. Player numbers can also be use to ally. For example: -ally 4 You can now even use -ally player name!
+ You can toggle the Alliance system on or off for certain players.
+ A message displays saying who allied who or vise versa. You can toggle this message on or off and easily edit the string "has allied" or "has unallied."
+ You can toggle the Alliance system on or off for certain players.
+ A message displays saying who allied who or vise versa. You can toggle this message on or off and easily edit the string "has allied" or "has unallied."
The Code
JASS:
//
// .^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^.
// /| Dougleton Alliance System v1.5 |\
// /^^^^^^/ | Made by Dougleton@Azeroth | \^^^^^^^^\
// / \_.________________________________._/ \
// | |
// |Simple system that allows players to ally or unally |
// |one another using -ally/unally color, number, |
// |or player name. |
// |You can toggle ally message display on or off in |
// |the globals. To toggle the system on or off for |
// |certain players edit struct DAS in the function |
// |LoadDougletonAllianceSystem() |
// | |
// |Go to map.ruthlessreign.com for help with this system |
// <______________________________________________________>
// | Change log |
// <______________________________________________________>
// |v1.5 *Rewrote entire code. |
// <______________________________________________________>
library DougletonAllianceSystem initializer InitDougletonAlly
globals
//Set this to false if you do not want
//the system displaying a message who
//allied who, etc.
private constant boolean Dougleton_Alliance_Messages_On = true
//Change the Ally or Unally message
// ex. "Player 1 has unallied Player 2"
private constant string AllyMessage = "has allied"
private constant string UnallyMessage = "has unallied"
endglobals
struct DAS extends array
string col //Player's color code example "|cffFF8000"
string sub1 //Substring1 example "orange"
string sub2 //Substring2 example "oj"
string num1 //Player Number example "5"
string name //Player Name
boolean on //Player able to ally and be allied with?
endstruct
private function LoadDougletonAllianceSystem takes nothing returns nothing
local integer i = 0
set DAS[0].col = "|cffFF0000"
set DAS[0].sub1 = "red"
set DAS[0].sub2 = ""
set DAS[1].col = "|cff0000FF"
set DAS[1].sub1 = "blue"
set DAS[1].sub2 = ""
set DAS[2].col = "|cff00FFFF"
set DAS[2].sub1 = "teal"
set DAS[2].sub2 = ""
set DAS[3].col = "|cff800080"
set DAS[3].sub1 = "purple"
set DAS[3].sub2 = "purp"
set DAS[4].col = "|cffFFFF00"
set DAS[4].sub1 = "yellow"
set DAS[4].sub2 = "yel"
set DAS[5].col = "|cffFF8000"
set DAS[5].sub1 = "orange"
set DAS[5].sub2 = "oj"
set DAS[6].col = "|cff00FF00"
set DAS[6].sub1 = "green"
set DAS[6].sub2 = ""
set DAS[7].col = "|cffFF00FF"
set DAS[7].sub1 = "pink"
set DAS[7].sub2 = ""
set DAS[8].col = "|cff808080"
set DAS[8].sub1 = "gray"
set DAS[8].sub2 = "grey"
set DAS[9].col = "|cff80FFFF"
set DAS[9].sub1 = "lightblue"
set DAS[9].sub2 = "lb"
set DAS[10].col = "|cff008040"
set DAS[10].sub1 = "darkgreen"
set DAS[10].sub2 = "dg"
set DAS[11].col = "|cff804000"
set DAS[11].sub1 = "brown"
set DAS[11].sub2 = ""
loop
exitwhen i > 11
set DAS<i>.on = true
set DAS<i>.num1 = I2S(GetPlayerId(Player(i))+1)
set DAS<i>.name = GetPlayerName(Player(i))
set i = i+1
endloop
// If you want to turn the alliance system off for specific players
// below this comment is a good place to do it. ex set DAS[1].on=false
// Turns it off for Player 2 Blue
endfunction
private function Dougleton_Ally_Or_Unally takes nothing returns nothing
local string s = SubString(GetEventPlayerChatString(), 0, 50)
local integer p = 11
local boolean allying
local integer state
if DAS[GetPlayerId(GetTriggerPlayer())].on then
if SubString(s, 0, 2) == "-u" then
set s = SubString(s, 8, 50)
set allying = false
set state = bj_ALLIANCE_UNALLIED
else
set s = SubString(s, 6, 50)
set allying = true
set state = bj_ALLIANCE_ALLIED_VISION
endif
loop
exitwhen p < 0
if s == DAS[p].sub1 or s == DAS[p].sub2 or s == DAS[p].num1 or s == DAS[p].name then
if DAS[p].on then
call SetPlayerAllianceStateBJ( GetTriggerPlayer(), Player(p), state )
if Dougleton_Alliance_Messages_On then
if allying then
set s = AllyMessage
else
set s = UnallyMessage
endif
call BJDebugMsg( DAS[GetPlayerId(GetTriggerPlayer())].col + DAS[GetPlayerId(GetTriggerPlayer())].name + "|r|cffFFFFFF " + s + " |r" + DAS[p].col + DAS[p].name)
endif
endif
set p = -1
else
set p = p-1
endif
endloop
endif
endfunction
private function InitDougletonAlly takes nothing returns nothing
local integer i = 0
local trigger t = CreateTrigger( )
call LoadDougletonAllianceSystem()
loop
exitwhen i > 11
call TriggerRegisterPlayerChatEvent( t, Player(i), "-ally", false )
call TriggerRegisterPlayerChatEvent( t, Player(i), "-unally", false )
set i = i+1
endloop
call TriggerAddAction( t, function Dougleton_Ally_Or_Unally)
endfunction
endlibrary
</i></i></i>
Quick Implement
If you're experienced with JASS all you need to do is copy this code into your map header or a trigger box and it is ready to use! If you're not very experienced with JASS, but know the basics of GUI here is a simple process to implement this system:
1. Download the system map file by clicking here.
2. Copy the trigger Dougleton Alliance System and then paste it into your map. Remember this is coded in vJASS so you will need Jass New Gen Pack for this to work.
If you're experienced with JASS all you need to do is copy this code into your map header or a trigger box and it is ready to use! If you're not very experienced with JASS, but know the basics of GUI here is a simple process to implement this system:
1. Download the system map file by clicking here.
2. Copy the trigger Dougleton Alliance System and then paste it into your map. Remember this is coded in vJASS so you will need Jass New Gen Pack for this to work.