Home   Help Search Login Register  

Author Topic: team deathmatch scoring  (Read 4175 times)

0 Members and 1 Guest are viewing this topic.

Offline trinec

  • Members
  • *
  • I'm a llama!
Re:team deathmatch scoring
« Reply #15 on: 09 Oct 2005, 07:41:13 »
Here is the final part of the scripts the camera part is just something i added which does not have to be used.

Init.sqs

; following variables are for side scoring
tx_Wkills = 0
tx_Ekills = 0

; following variables are for individual unit scoring
tx_W1score = 0
tx_W2score = 0
tx_E1score = 0
tx_E2score = 0
;sets timeend to 0
TimeEnd=0

; following is a killed eventhandler, this runs the playerkilled.sqs when the unit is killed (much more efficient than a series of triggers
tx_kill = player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]


Outro.sqs

_Winner = 0
;;_winner=1(for west win)..=2(for east win)..=0 (for a draw)
_message = ""
if(tx_Wkills > tx_Ekills)then{_winner = 1}else{_winner = 2}
if(tx_Wkills == tx_Ekills)then{_winner = 0}

;;when a certain side wins it goes to that part of the script
?(_winner == 0): goto "DRAW"
?(_winner == 1): goto "WWins"
?(_winner == 2): goto "EWins"

;camera stuff for when the score is equal to the same or no score at all this can be changed
#DRAW

playmusic "Draw"
_cam = "camera" camcreate [0,0,0]
_cam cameraeffect ["internal", "back"]
_cam camsettarget esol
_cam camsetrelpos [-2,10,3]
_cam camcommit 0
;shows its a draw on the screen
titleText ["IT'S A DRAW!!","Plain"]
titlecut [" ","BLACK IN",2]
~4

_cam camsetrelpos [-2,-5,0.5]
_cam camcommit 10
@camcommitted _cam
~2

_cam camsettarget wsol
_cam camsetrelpos [-1,3,2]
@camcommitted _cam
~2

titlecut [" ","BLACK OUT",2]
~2
_cam cameraeffect ["terminate", "back"]
camdestroy _cam

titlecut [" ","BLACK IN",2]
;;this tells the teamdeath match to end
TrueEnd=true
exit


#WWins
;plays a music file when the west side wins
playmusic "WWins"
;start of the scoreing part
hint formaT [ "___ FINAL OUTCOME ___\n\n%1",_message]

_W1 = format ["\n%1 had %2 kills",name W1,tx_W1score]
_W2 = format ["\n%1 had %2 kills",name W2,tx_W2score]
_E1 = format ["\n%1 had %2 kills",name E1,tx_E1score]
_E2 = format ["\n%1 had %2 kills",name E2,tx_E2score]

hint formaT [ "___ INDIVIDUAL SCORES ___\n%1%2%3%4",_W1,_W2,_E1,_E2]
;displays the scoring part for 7 seconds
~7

;this is the camera stuff for when the west side wins this can be change but the scoring must be called first before the camera part.

_cam = "camera" camcreate [0,0,0]
_cam cameraeffect ["internal", "back"]

_cam camsettarget wf1
_cam camsetrelpos [-2,15,5]
_cam camcommit 0
@camcommitted _cam
;shows west wins on the screen
titletext ["WEST WINS!!","Plain"]
~6
titlecut [" ","BLACK IN",2]
~2

_cam cameraeffect ["terminate", "back"]
camdestroy _cam

~1
titlecut [" ","BLACK IN",2]
;this ends the team death match
TrueEnd=true
exit


#EWins
;plays music for the east side when they win
playmusic "EWins"

;start of the east scoring part
hint formaT [ "___ FINAL OUTCOME ___\n\n%1",_message]
_W1 = format ["\n%1 had %2 kills",name W1,tx_W1score]
_W2 = format ["\n%1 had %2 kills",name W2,tx_W2score]
_E1 = format ["\n%1 had %2 kills",name E1,tx_E1score]
_E2 = format ["\n%1 had %2 kills",name E2,tx_E2score]

hint formaT [ "___ INDIVIDUAL SCORES ___\n%1%2%3%4",_W1,_W2,_E1,_E2]
~7

;start of camera stuff for east this can be changed
_cam = "camera" camcreate [0,0,0]
_cam cameraeffect ["internal", "back"]

_cam camsettarget ef1
_cam camsetrelpos [-2,15,5]
_cam camcommit 0
~3
titletext ["EAST WINS!!","Plain"]
~6
titlecut [" ","BLACK IN",2]
~2

_cam cameraeffect ["terminate", "back"]
camdestroy _cam

~1
titlecut [" ","BLACK IN",2]
;ends the team deathmatch
TrueEnd=true
exit

playerkilled.sqs


_victim = _this select 0
_killer = _this select 1
_side = side _killer
player removeEventhandler ["killed",tx_kill]
if(side _victim == _side)then{hint "teamkill occurred";exit}
goto (format ["%1", _side])


#EAST
if (name _killer == name E1)then {tx_E1score = tx_E1score + 1;tx_Ekills = tx_Ekills + 1; {Publicvariable _x}foreach ["tx_E1score","tx_Ekills"]}
if (name _killer == name E2)then {tx_E2score = tx_E2score + 1;tx_Ekills = tx_Ekills + 1; {Publicvariable _x}foreach ["tx_E2score","tx_Ekills"]}
goto "END"

#WEST
if (name _killer == name W1)then {tx_W1score = tx_W1score + 1;tx_Wkills = tx_Wkills + 1; {Publicvariable _x}foreach ["tx_W1score","tx_Wkills"]}
if (name _killer == name W2)then {tx_W2score = tx_W2score + 1;tx_Wkills = tx_Wkills + 1; {Publicvariable _x}foreach ["tx_W2score","tx_Wkills"]}
goto "END"

#END
;;; if respawn then add the following
@alive player
tx_kill = player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]

description.ext

;this is for the setting of the time and scoring limits at the start of the mission
titleParam1 = "Time:";
valuesParam1[] = {10000, 300, 600, 900, 1200, 1500, 1800, 2700, 3600, 7200};
defValueParam1 = 1800;
textsParam1[] = {"Unlimited", "5 min", "10 min", "15 min", "20 min", "25 min", "30 min", "45 min", "1 hour", "2 hours"};

titleParam2 = "Score to win:";
valuesParam2[] = {10000, 5, 7, 10, 15, 20, 25, 30};
defValueParam2 = 5;
textsParam2[] = {"Unlimited", 5, 7, 10, 15, 20, 25, 30};


You also need to create some triggers for your map

first one is called Scorelimit which when the score that is set at the start of the mission is reached then this is called and ends the tdm

In the condition filed you put
(param1<10000 and ((time >= param1) or (TimeEnd >= param1))) or (param2<10000 and ((tx_W1score >=param2) or (tx_W2score >=param2) or (tx_E1score >=param2) or (tx_E2score >=param2)))

the on activation you put
TimeEnd=time; publicVariable "TimeEnd";player exec "Outro.sqs"

The next trigger is named End

Type is End1
in the condition field you put  TrueEnd and in the on activation field you put  ForceEnd

if anyone would like to add an update for every so many minutes you get updated on how much time you have left let me know and ill add it Just didnt want to put too much in here Thanks goes to Terox for the base scripts and for the debug info :), worked out the last part of the scoring triggers from reading the old ctf tutorial on the old sventh website

http://www.3dactionplanet.com/flashpoint/Tutorial2/Tutor2_Contents.html

and for fragori's help.

Trinec

« Last Edit: 09 Oct 2005, 07:43:25 by trinec »