Anyways it should be pretty self explanatory. Place "i_battlegrounds_que_stone" (Que Stones) in each town or w/e you want. These allow players to "que" up for battlegrounds. Once the minimum amount of players are met everyone in the que is shown a menu allowing them to enter the battleground. Each player is then teleported to a location to battle it out. The first player who gets a certain amount of killing blows wins. Once it is over all the players are teleported back to a set point. If you have any questions about the script just ask.
I know there are probably better ways to script this but you guys know more about such ways than I.
You can add some pretty cool features to it such as weekly winners (whoever has the most killing blows in a week) or whatever. Since it store all the kills in a db you can pretty much do whatever you want as far as ranking players, awarding players, etc.
Some things that are controlled:
- Nobody dies (when there health reaches 0, the opponent gains a point and the victim is teleported to the starting spot)
- The kills, karma, and fame is returned to the players once the battleground is over.
- Everyone automatically becomes a murderer once in a battleground. They are returned to normal once they leave.
And that is that. So if you decide to use this in your shard let me know so I can come and play around and see all the cool stuff you do with it
Future enchancements:
- Better Gumps for the menus
- Multiple spawn points to prevent "spawn camping"
- Timers on battlegrounds (10 minute cap on matches)
- w/e you can think of...
Hope you enjoy!
CODE
[DEFNAME BATTLEGROUNDS]
// -----------------------------------
// Here you can control the messages
// used by the battlegrounds system.
// -----------------------------------
BATTLEGROUNDS_MAX_PLAYERS 10
BATTLEGROUNDS_MIN_PLAYERS 1
BATTLEGROUNDS_KILLS_WIN 5
BATTLEGROUNDS_MSG_FULL "There are too many players participating in battlegrounds."
BATTLEGROUNDS_MSG_EMPTY "There are no players participating in battlegrounds."
BATTLEGROUNDS_MSG_QUE "has joined the que for battlegrounds."
BATTLEGROUNDS_MSG_QUETWICE "You may not que twice for the same battleground match."
BATTLEGROUNDS_CONNECT_ERROR "Unable to connect to the battlegrounds database. Please try again."
BATTLEGROUNDS_LEAVE_QUE "has left the que for battlegrounds."
BATTLEGROUNDS_CLEAR_QUE "The que for battlegrounds has been cleared. A new battleground has begun!"
BATTLEGROUNDS_MSG_BEGIN "A new battleground has begun!"
BATTLEGROUNDS_MSG_JOIN "has joined the battlgrounds."
BATTLEGROUNDS_MSG_END "The current battleground match has ended!"
BATTLEGROUNDS_MSG_KILL "You killed: "
BATTLEGROUNDS_MSG_DEATH "You were killed by: "
BATTLEGROUNDS_MSG_KILL_COUNT "Kills: "
BATTLEGROUNDS_MSG_DEATH_COUNT "Deaths: "
BATTLEGROUNDS_MSG_PLAYER_END "is victorious in the battlegrounds!"
BATTLEGROUNDS_MATCH_LOCATION 1397,3742,-21
BATTLEGROUNDS_LEAVE_LOCATION 4442,1173
[FUNCTION F_CREATE_BATTLEGROUND_TABLES]
// -----------------------------------
// Creates the database table used for
// the battlegrouds que/log.
// -----------------------------------
DB.EXECUTE "CREATE TABLE `battlegrounds` (`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,`PlayerName` VARCHAR( 55 ) NOT NULL ,`PlayerID` INT NOT NULL ,`TimeJoined` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,INDEX ( `PlayerName` ) ,UNIQUE (`PlayerID`))"
DB.EXECUTE "CREATE TABLE `battlegrounds-log` (`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,`AccountName` VARCHAR( 55 ) NOT NULL ,`Name` VARCHAR( 55 ) NOT NULL ,`UID` VARCHAR( 15 ) NOT NULL ,`VictimAccountName` VARCHAR( 55 ) NOT NULL ,`VictimName` VARCHAR( 55 ) NOT NULL ,`VictimUID` VARCHAR( 15 ) NOT NULL)"
[FUNCTION F_CHECK_BATTLEGROUNDS_QUE]
DB.QUERY "SELECT `ID`, `PlayerName`, `PlayerID`, `TimeJoined` FROM `battlegrounds` ORDER BY `PlayerName` ASC"
IF (0<DB.ROW.NUMROWS>)
FOR CURRENTROW 0 <eval <DB.ROW.NUMROWS>-1>
IF (<DB.ROW.<eval <LOCAL.CURRENTROW>>.PlayerID> = <SRC.UID>)
SRC.SYSMESSAGE Teammate: <DB.ROW.<eval <LOCAL.CURRENTROW>>.PlayerName>
ELSE
SRC.SYSMESSAGE Opponent: <DB.ROW.<eval <LOCAL.CURRENTROW>>.PlayerName>
ENDIF
END
ELSE
SRC.SYSMESSAGE <DEF0.BATTLEGROUNDS_MSG_EMPTY>
ENDIF
[FUNCTION F_CLEAR_BATTLEGROUNDS_QUE]
DB.EXECUTE "TRUNCATE TABLE `battlegrounds`"
SERV.ALLCLIENTS SYSMESSAGE BG: <DEF0.BATTLEGROUNDS_CLEAR_QUE>
[FUNCTION F_ADD_BATTLEGROUNDS_QUE]
IF (0<SRC.TAG.BATTLEGROUNDS_WAIT> = 1)
MENU MENU_JOIN_BATTLEGROUNDS
ELSE
DB.QUERY "SELECT COUNT(`ID`) AS `PLAYERS` FROM `battlegrounds`"
IF (0<DB.ROW.0.PLAYERS> < 0<DEF0.BATTLEGROUNDS_MAX_PLAYERS>)
DB.QUERY "SELECT COUNT(`ID`) AS `PLAYERS` FROM `battlegrounds` WHERE `PlayerID` = '<SRC.SERIAL>'"
IF (0<SRC.TAG.BATTLEGROUNDS_QUE> = 0)
DB.EXECUTE "INSERT INTO `sphere`.`battlegrounds` (`PlayerName` ,`PlayerID`) VALUES ('<SRC.NAME>', '<SRC.SERIAL>');"
SRC.TAG.BATTLEGROUNDS_QUE 1
SRC.EVENTS +E_BATTLEGROUNDS_LOGOUT
SRC.EVENTS +E_BATTLEGROUNDS_LOGIN
SRC.EVENTS +E_BATTLEGROUNDS
SERV.ALLCLIENTS SYSMESSAGE BG: <SRC.NAME> <DEF0.BATTLEGROUNDS_MSG_QUE>
F_START_BATTLEGROUNDS
ELSE
SRC.SYSMESSAGE <DEF0.BATTLEGROUNDS_MSG_QUETWICE>
ENDIF
ELSE
SRC.SYSMESSAGE <DEF0.BATTLEGROUNDS_MSG_FULL>
ENDIF
ENDIF
[FUNCTION F_LEAVE_BATTLEGROUNDS_QUE]
IF (0<SRC.TAG.BATTLEGROUNDS_QUE> = 0)
ELSE
DB.EXECUTE "DELETE FROM `sphere`.`battlegrounds` WHERE `PlayerName` = '<SRC.NAME>' AND `PlayerID` = '<SRC.SERIAL>'"
SRC.TAG.BATTLEGROUNDS_QUE 0
SERV.ALLCLIENTS SYSMESSAGE BG: <SRC.NAME> <DEF0.BATTLEGROUNDS_LEAVE_QUE>
ENDIF
[FUNCTION F_START_BATTLEGROUNDS]
DB.QUERY "SELECT COUNT(`ID`) AS `PLAYERS` FROM `battlegrounds`"
IF (0<DB.ROW.0.PLAYERS> >= 0<DEF0.BATTLEGROUNDS_MIN_PLAYERS>)
SERV.ALLCLIENTS SYSMESSAGE BG: <DEF0.BATTLEGROUNDS_MSG_BEGIN>
SERV.ALLCLIENTS F_CHECK_JOIN_BATTLEGROUNDS
ENDIF
[FUNCTION F_CHECK_JOIN_BATTLEGROUNDS]
IF (0<SRC.TAG.BATTLEGROUNDS_QUE> = 1)
MENU MENU_JOIN_BATTLEGROUNDS
SRC.TAG.BATTLEGROUNDS_WAIT 1
ENDIF
[FUNCTION F_JOIN_BATTLEGROUNDS]
IF (0<SRC.TAG.BATTLEGROUNDS_QUE> = 1)
SRC.TAG.BATTLEGROUNDS_QUE 0
SRC.TAG.BATTLEGROUNDS_WAIT 0
SRC.TAG.BATTLEGROUNDS_MATCH 1
SRC.TAG.BATTLEGROUNDS_DEATH_COUNT 0
SRC.TAG.BATTLEGROUNDS_KILL_COUNT 0
SRC.TAG.BATTLEGROUNDS_KARMA <SRC.KARMA>
SRC.TAG.BATTLEGROUNDS_FAME <SRC.FAME>
SRC.TAG.BATTLEGROUNDS_KILLS <SRC.KILLS>
SRC.KARMA -9999
SRC.CONSUME I_BATTLEGROUNDS_QUE_TIMER
SERV.ALLCLIENTS SYSMESSAGE BG: <SRC.NAME> <DEF0.BATTLEGROUNDS_MSG_JOIN>
SRC.GO <DEF0.BATTLEGROUNDS_MATCH_LOCATION>
SRC.FIX
ENDIF
[FUNCTION F_LEAVE_BATTLEGROUNDS]
IF (0<SRC.TAG.BATTLEGROUNDS_MATCH> = 1)
SRC.TAG.BATTLEGROUNDS_MATCH 0
SRC.TAG.BATTLEGROUNDS_WAIT 0
SRC.TAG.BATTLEGROUNDS_DEATH_COUNT 0
SRC.TAG.BATTLEGROUNDS_KILL_COUNT 0
SRC.TAG.BATTLEGROUNDS_QUE 0
SRC.FAME <SRC.TAG.BATTLEGROUNDS_KARMA>
SRC.KARMA <SRC.TAG.BATTLEGROUNDS_FAME>
SRC.KILLS <SRC.TAG.BATTLEGROUNDS_KILLS>
SRC.CONSUME I_BATTLEGROUNDS_QUE_TIMER
SRC.EVENTS -E_BATTLEGROUNDS_LOGOUT
SRC.EVENTS -E_BATTLEGROUNDS_LOGIN
SRC.EVENTS -E_BATTLEGROUNDS
SRC.GO <DEF0.BATTLEGROUNDS_LEAVE_LOCATION>
SRC.FIX
ENDIF
[FUNCTION F_BATTLEGROUNDS_RECORD_KILL]
IF (0<SRC.TAG.BATTLEGROUNDS_MATCH> = 1)
SRC.TAG.BATTLEGROUNDS_KILL_COUNT <EVAL <SRC.TAG.BATTLEGROUNDS_KILL_COUNT>>+1
SRC.SYSMESSAGE BG: <DEF0.BATTLEGROUNDS_MSG_KILL> <ACT.NAME>
SRC.SYSMESSAGE BG: <DEF0.BATTLEGROUNDS_MSG_KILL_COUNT> <EVAL <SRC.TAG.BATTLEGROUNDS_KILL_COUNT>>
DB.EXECUTE "INSERT INTO `sphere`.`battlegrounds-log` (`ID` ,`AccountName` ,`Name` ,`UID` ,`VictimAccountName` ,`VictimName` ,`VictimUID`) VALUES (NULL , '<SRC.ACCOUNT>', '<SRC.NAME>', '<SRC.SERIAL>', '<ACT.NAME>', '<ACT.NAME>', '<ACT.SERIAL>');"
IF (0<SRC.TAG.BATTLEGROUNDS_KILL_COUNT> >= <EVAL <DEF0.BATTLEGROUNDS_KILLS_WIN>>)
F_AWARD_BATTLEGROUNDS_WINNER
F_END_BATTLEGROUNDS
ENDIF
ENDIF
[FUNCTION F_BATTLEGROUNDS_RECORD_DEATH]
IF (0<SRC.TAG.BATTLEGROUNDS_MATCH> = 1)
SRC.TAG.BATTLEGROUNDS_DEATH_COUNT <EVAL <SRC.TAG.BATTLEGROUNDS_DEATH_COUNT>>+1
SRC.SYSMESSAGE BG: <DEF0.BATTLEGROUNDS_MSG_DEATH> <ACT.NAME>
SRC.SYSMESSAGE BG: <DEF0.BATTLEGROUNDS_MSG_DEATH_COUNT> <EVAL <SRC.TAG.BATTLEGROUNDS_DEATH_COUNT>>
ENDIF
[FUNCTION F_AWARD_BATTLEGROUNDS_WINNER]
// -----------------------------------
// Here you can award the victor w/e
// you would like for winning the
// battleground.
// -----------------------------------
SERV.ALLCLIENTS SYSMESSAGE BG: <SRC.NAME> <DEF0.BATTLEGROUNDS_MSG_PLAYER_END>
[FUNCTION F_END_BATTLEGROUNDS]
SERV.ALLCLIENTS SYSMESSAGE BG: <DEF0.BATTLEGROUNDS_MSG_END>
SERV.ALLCLIENTS F_LEAVE_BATTLEGROUNDS
F_CLEAR_BATTLEGROUNDS_QUE
[MENU MENU_BATTLEGROUNDS_QUE]
<SERV.NAME> Battlegrounds
ON=0 Enter Battleground: The battleground awaits you! Enter the battleground.
F_ADD_BATTLEGROUNDS_QUE
ON=0 Leave Battlegrounds Que: Leave the que for the next available battlegrounds match.
F_LEAVE_BATTLEGROUNDS_QUE
ON=0 List Participants: List the players currently in que for the next available battlegrounds.
F_CHECK_BATTLEGROUNDS_QUE
[MENU MENU_JOIN_BATTLEGROUNDS]
You are eligible to enter the current Battlegrounds match!
ON=0 Send me to the Battlegrounds!
F_JOIN_BATTLEGROUNDS
ON=0 Leave the battlegrounds que.
F_LEAVE_BATTLEGROUNDS_QUE
[EVENTS E_BATTLEGROUNDS_LOGOUT]
ON=@LOGOUT
F_LEAVE_BATTLEGROUNDS_QUE
F_LEAVE_BATTLEGROUNDS
[EVENTS E_BATTLEGROUNDS_LOGIN]
ON=@LOGOUT
F_LEAVE_BATTLEGROUNDS_QUE
F_LEAVE_BATTLEGROUNDS
[EVENTS E_BATTLEGROUNDS]
ON=@DEATH
F_BATTLEGROUNDS_RECORD_DEATH
SRC.HITS <SRC.MAXHITS>
SRC.MANA <SRC.MAXMANA>
SRC.STAM <SRC.MAXSTAM>
SRC.GO <DEF0.BATTLEGROUNDS_MATCH_LOCATION>
SRC.FIX
RETURN 1
ON=@KILL
F_BATTLEGROUNDS_RECORD_KILL
[ITEMDEF I_BATTLEGROUNDS_QUE_STONE]
DEFNAME=I_BATTLEGROUNDS_QUE_STONE
NAME=Battlegrounds Que Stone
ID=I_GRAVE_STONE
ON=@CREATE
COLOR=0481
ON=@DCLICK
MENU MENU_BATTLEGROUNDS_QUE
RETURN 1
[EOF]