Hard Light Productions Forums
Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: madaboutgames on July 19, 2008, 03:09:17 pm
-
Hi all, well Ill give a bit of an expilnation first. I am making an end of campaign stats mission which involves displaying the stats (in graphic form) of a few things. I have the bulk of it done but just need to know these. (All event based)
How do I return of the number of player kills/score/deaths/assists in the campaign?
Here is the mission code at the minute :
$Mission Desc:
XSTR("Shows end of campaign stats.", -1)
$end_multi_text
+Game Type Flags: 1
+Flags: 134298
+Disallow Support: 1
+Hull Repair Ceiling: 0.000000
+Subsystem Repair Ceiling: 100.000000
+Viewer pos: -1012.211914, 115902.898438, -51924.863281
+Viewer orient:
0.999951, -0.000001, -0.009931,
0.007458, 0.660392, 0.750884,
0.006558, -0.750921, 0.660359
$Load Screen 640: EBW-0.tga
$Load Screen 1024: EBW-0.tga
;;FSO 3.6.0;; $Skybox Model: starfield.pof
$AI Profile: TBP
#Sexp_variables
$Variables:
(
0 "Column1X" "200" "number"
1 "Column2X" "700" "number"
2 "DigitUnitValue" "0" "number"
3 "DigitValue" "0" "number"
4 "DigitX" "0" "number"
5 "HighestUnits" "1000" "number"
6 "NumberDisplayTime" "0" "number"
7 "NumberDrawFlag" "0" "number"
8 "NumberValue" "0" "number"
9 "NumberX" "0" "number"
10 "NumberY" "0" "number"
11 "Pitch" "0" "number"
12 "PlayerAssists" "0" "number"
13 "PlayerDeaths" "0" "number"
14 "PlayerKills" "0" "number"
15 "PlayerScore" "0" "number"
)
#Command Briefing
#Briefing
$start_briefing
$num_stages: 0
$end_briefing
#Debriefing_info
$Num stages: 0
#Players ;! 1 total
$Starting Shipname: Alpha 1
$Ship Choices: (
"EA Aurora" 5
"EA Aurora MK1" 5
"EA Badger" 5
"EA Thunderbolt" 5
"PSI Aurora" 5
"PSI Thunderbolt" 5
"CR Sentri" 5
"NR Frazi" 5
"ISA Whitestar" 5
)
+Weaponry Pool: (
"40mm Pulse" 16
"45mm Pulse" 16
"60mm Pulse" 16
"42mm Plasma" 16
"43mm Plasma" 16
"45mm Fusion" 16
"Disruptor" 16
"Particle Array" 16
"Ion Accelerator" 16
"52mm Pulse" 16
"75mm Pulse" 16
"Neutron Gun" 16
"Light Fusion" 16
"Drazi 35mm" 16
"WS Pulsed Fusion" 16
"WS Pulsed Neutron" 16
"Pulsed Fusion" 16
"WS Neutron Beam" 16
"EA Venom 1" 500
"EA Venom 2" 500
"EA Panther" 500
"EA Bulldog" 500
"CR Asari" 500
"NR Ta'Lon" 500
"NR T'Kor" 500
"MF Shokrai" 500
)
#Objects ;! 1 total
$Name: Alpha 1 ;! Object #0
$Class: EA Aurora
$Team: Friendly
$Location: 0.000000, 0.000000, 0.000000
$Orientation:
1.000000, 0.000000, 0.000000,
0.000000, 1.000000, 0.000000,
0.000000, 0.000000, 1.000000
$AI Behavior: None
$Cargo 1: XSTR("Nothing", -1)
+Initial Velocity: 33
+Initial Hull: 100
+Initial Shields: 100
+Subsystem: Pilot
$Arrival Location: Hyperspace
$Arrival Cue: ( false )
$Departure Location: Hyperspace
$Departure Cue: ( false )
$Determination: 10
+Flags: ( "cargo-known" "beam-protect-ship" "no-shields" "player-start" "invulnerable" "hidden-from-sensors" )
+Flags2: ( "targetable-as-bomb" )
+Respawn priority: 0
+Group: 0
+Score: 20
#Wings ;! 1 total
$Name: Alpha
$Waves: 1
$Wave Threshold: 0
$Special Ship: 0 ;! Alpha 1
$Arrival Location: Hyperspace
$Arrival Cue: ( true )
$Departure Location: Hyperspace
$Departure Cue: ( false )
$Ships: ( ;! 1 total
"Alpha 1"
)
+Hotkey: 0
+Flags:( )
#Events ;! 30 total
$Formula: ( do-nothing )
+Name: __________SET THESE ACCORDINGLY
+Repeat Count: 1
+Interval: 1
+Team: 0
$Formula: ( when
( true )
( modify-variable @PlayerKills[0] 1 )
)
+Name: set player kills
+Repeat Count: 1
+Interval: 1
+Team: 0
$Formula: ( when
( true )
( modify-variable @PlayerAssists[0] 2 )
)
+Name: set player assists
+Repeat Count: 1
+Interval: 1
+Team: 0
$Formula: ( when
( true )
( modify-variable @PlayerDeaths[0] 3 )
)
+Name: set player deaths
+Repeat Count: 1
+Interval: 1
+Team: 0
$Formula: ( when
( true )
( modify-variable @PlayerScore[0] 4 )
)
+Name: set player score
+Repeat Count: 1
+Interval: 1
+Team: 0
$Formula: ( do-nothing )
+Name: _______MAKE THESE TRUE OR FALSE
+Repeat Count: 1
+Interval: 1
+Team: 0
$Formula: ( when
( is-previous-event-true
"Brak attack 16a"
"start"
)
( do-nothing )
)
+Name: you did well
+Repeat Count: 1
+Interval: 1
+Team: 0
$Formula: ( when
( is-previous-event-true
"Brak attack 16b"
"start"
)
( do-nothing )
)
+Name: you did not do well
+Repeat Count: 1
+Interval: 1
+Team: 0
$Formula: ( when
( or
( < @PlayerKills[0] 15 )
( > @PlayerDeaths[0] 30 )
)
( do-nothing )
)
+Name: rookie
+Repeat Count: 1
+Interval: 1
+Team: 0
$Formula: ( when
( or
( < @PlayerKills[0] 30 )
( > @PlayerDeaths[0] 25 )
)
( do-nothing )
)
+Name: pilot
+Repeat Count: 1
+Interval: 1
+Team: 0
$Formula: ( when
( or
( < @PlayerKills[0] 30 )
( > @PlayerDeaths[0] 20 )
)
( do-nothing )
)
+Name: veteran
+Repeat Count: 1
+Interval: 1
+Team: 0
$Formula: ( when
( or
( > @PlayerKills[0] 70 )
( < @PlayerDeaths[0] 20 )
)
( do-nothing )
)
+Name: wing commander
+Repeat Count: 1
+Interval: 1
+Team: 0
$Formula: ( when
( or
( < @PlayerKills[0] 15 )
( > @PlayerDeaths[0] 30 )
)
( do-nothing )
)
+Name: pussy
+Repeat Count: 1
+Interval: 1
+Team: 0
$Formula: ( when
( or
( < @PlayerKills[0] 30 )
( > @PlayerDeaths[0] 25 )
)
( do-nothing )
)
+Name: brave
+Repeat Count: 1
+Interval: 1
+Team: 0
$Formula: ( when
( and
( < @PlayerKills[0] 50 )
( > @PlayerDeaths[0] 20 )
)
( do-nothing )
)
+Name: a threat
+Repeat Count: 1
+Interval: 1
+Team: 0
$Formula: ( when
( or
( > @PlayerKills[0] 70 )
( < @PlayerDeaths[0] 20 )
)
( do-nothing )
)
+Name: fearless
+Repeat Count: 1
+Interval: 1
+Team: 0
$Formula: ( do-nothing )
+Name: ____________THE CUTSCENE ITSELF
+Repeat Count: 1
+Interval: 1
+Team: 0
$Formula: ( when
( true )
( lock-perspective ( true ) )
( player-use-ai )
( add-goal
"Alpha 1"
( ai-waypoints-once "Dest" 89 )
)
( hud-disable 1 )
( play-sound-from-file
"b5_season4.wav"
)
( remove-sun-bitmap 0 )
)
+Name: start
+Repeat Count: 1
+Interval: 1
+Team: 0
$Formula: ( when
( true )
( show-subtitle
32
32
" "
4000
"ebwlogo.tga"
1000
( true )
( true )
)
)
+Name: ebw logo
+Repeat Count: 1
+Interval: 1
+Chained: 0
+Team: 0
$Formula: ( when
( true )
( show-subtitle
64
32
" "
999999
"ebwendofwarsummary.tga"
1000
( true )
)
)
+Name: end of war summary
+Repeat Count: 1
+Interval: 1
+Chained: 4
+Team: 0
$Formula: ( when
( true )
( when
( is-event-true-delay
"you did well"
0
)
( show-subtitle
32
128
" "
999999
"ebwyoudidwell.tga"
1000
( true )
)
)
( when
( is-event-true-delay
"you did not do well"
0
)
( show-subtitle
32
128
" "
999999
"ebwyoudidwell.tga"
1000
( true )
)
)
)
+Name: you did (not) do well pilot
+Repeat Count: 1
+Interval: 1
+Chained: 4
+Team: 0
$Formula: ( when
( true )
( show-subtitle
@Column1X[200]
256
" "
999999
"ebwplayerkills.tga"
1000
)
( modify-variable
@NumberValue[0]
@PlayerKills[0]
)
( modify-variable
@NumberX[0]
@Column2X[700]
)
( modify-variable @NumberY[0] 256 )
( modify-variable
@NumberDisplayTime[0]
999999
)
( modify-variable
@DigitUnitValue[0]
@HighestUnits[1000]
)
( modify-variable
@NumberDrawFlag[0]
1
)
)
+Name: player kills
+Repeat Count: 1
+Interval: 1
+Chained: 3
+Team: 0
$Formula: ( when
( true )
( show-subtitle
@Column1X[200]
320
" "
999999
"ebwplayerassists.tga"
1000
)
( modify-variable
@NumberValue[0]
@PlayerAssists[0]
)
( modify-variable
@NumberX[0]
@Column2X[700]
)
( modify-variable @NumberY[0] 320 )
( modify-variable
@NumberDisplayTime[0]
999999
)
( modify-variable
@DigitUnitValue[0]
@HighestUnits[1000]
)
( modify-variable
@NumberDrawFlag[0]
1
)
)
+Name: player assists
+Repeat Count: 1
+Interval: 1
+Chained: 1
+Team: 0
$Formula: ( when
( true )
( show-subtitle
@Column1X[200]
384
" "
999999
"ebwplayerdeaths.tga"
1000
)
( modify-variable
@NumberValue[0]
@PlayerDeaths[0]
)
( modify-variable
@NumberX[0]
@Column2X[700]
)
( modify-variable @NumberY[0] 384 )
( modify-variable
@NumberDisplayTime[0]
999999
)
( modify-variable
@DigitUnitValue[0]
@HighestUnits[1000]
)
( modify-variable
@NumberDrawFlag[0]
1
)
)
+Name: player deaths
+Repeat Count: 1
+Interval: 1
+Chained: 1
+Team: 0
$Formula: ( when
( true )
( show-subtitle
@Column1X[200]
448
" "
999999
"ebwplayerscore.tga"
1000
)
( modify-variable
@NumberValue[0]
@PlayerScore[0]
)
( modify-variable
@NumberX[0]
@Column2X[700]
)
( modify-variable @NumberY[0] 448 )
( modify-variable
@NumberDisplayTime[0]
999999
)
( modify-variable
@DigitUnitValue[0]
@HighestUnits[1000]
)
( modify-variable
@NumberDrawFlag[0]
1
)
)
+Name: player score
+Repeat Count: 1
+Interval: 1
+Chained: 1
+Team: 0
$Formula: ( when
( true )
( show-subtitle
@Column1X[200]
512
" "
999999
"ebwplayerrating.tga"
1000
)
( when
( is-event-true-delay "pussy" 0 )
( show-subtitle
@Column2X[700]
512
" "
999999
"ebwpussy.tga"
1000
)
)
( when
( is-event-true-delay "brave" 0 )
( show-subtitle
@Column2X[700]
512
" "
999999
"ebwbrave.tga"
1000
)
)
( when
( is-event-true-delay "a threat" 0 )
( show-subtitle
@Column2X[700]
512
" "
999999
"ebwathreat.tga"
1000
)
)
( when
( is-event-true-delay "fearless" 0 )
( show-subtitle
@Column2X[700]
512
" "
999999
"ebwfearless.tga"
1000
)
)
)
+Name: player rating
+Repeat Count: 1
+Interval: 1
+Chained: 1
+Team: 0
$Formula: ( when
( true )
( show-subtitle
@Column1X[200]
576
" "
999999
"ebwplayerranking.tga"
1000
)
( when
( is-event-true-delay "rookie" 0 )
( show-subtitle
@Column2X[700]
576
" "
999999
"ebwrookie.tga"
1000
)
)
( when
( is-event-true-delay "pilot" 0 )
( show-subtitle
@Column2X[700]
576
" "
999999
"ebwpilot.tga"
1000
)
)
( when
( is-event-true-delay "veteran" 0 )
( show-subtitle
@Column2X[700]
576
" "
999999
"ebwveteran.tga"
1000
)
)
( when
( is-event-true-delay
"wing commander"
0
)
( show-subtitle
@Column2X[700]
576
" "
999999
"ebwwingcommander.tga"
1000
)
)
)
+Name: player rank
+Repeat Count: 1
+Interval: 1
+Chained: 1
+Team: 0
$Formula: ( when ( true ) ( fade-out 2000 1 ) )
+Name: fade out
+Repeat Count: 1
+Interval: 1
+Chained: 15
+Team: 0
$Formula: ( when ( true ) ( end-mission ) )
+Name: end mission
+Repeat Count: 1
+Interval: 1
+Chained: 3
+Team: 0
$Formula: ( every-time
( = @NumberDrawFlag[0] 1 )
( every-time
( < @NumberValue[0] 0 )
( training-msg
"Negative Number Error"
)
( modify-variable
@NumberValue[0]
( abs @NumberValue[0] )
)
)
( modify-variable
@DigitValue[0]
( mod
( /
@NumberValue[0]
@DigitUnitValue[0]
)
10
)
)
( every-time
( = @DigitValue[0] 0 )
( show-subtitle
@NumberX[0]
@NumberY[0]
" "
@NumberDisplayTime[0]
"ebw0.tga"
1000
)
)
( every-time
( = @DigitValue[0] 1 )
( show-subtitle
@NumberX[0]
@NumberY[0]
" "
@NumberDisplayTime[0]
"ebw1.tga"
1000
)
)
( every-time
( = @DigitValue[0] 2 )
( show-subtitle
@NumberX[0]
@NumberY[0]
" "
@NumberDisplayTime[0]
"ebw2.tga"
1000
)
)
( every-time
( = @DigitValue[0] 3 )
( show-subtitle
@NumberX[0]
@NumberY[0]
" "
@NumberDisplayTime[0]
"ebw3.tga"
1000
)
)
( every-time
( = @DigitValue[0] 4 )
( show-subtitle
@NumberX[0]
@NumberY[0]
" "
@NumberDisplayTime[0]
"ebw4.tga"
1000
)
)
( every-time
( = @DigitValue[0] 5 )
( show-subtitle
@NumberX[0]
@NumberY[0]
" "
@NumberDisplayTime[0]
"ebw5.tga"
1000
)
)
( every-time
( = @DigitValue[0] 6 )
( show-subtitle
@NumberX[0]
@NumberY[0]
" "
@NumberDisplayTime[0]
"ebw6.tga"
1000
)
)
( every-time
( = @DigitValue[0] 7 )
( show-subtitle
@NumberX[0]
@NumberY[0]
" "
@NumberDisplayTime[0]
"ebw7.tga"
1000
)
)
( every-time
( = @DigitValue[0] 8 )
( show-subtitle
@NumberX[0]
@NumberY[0]
" "
@NumberDisplayTime[0]
"ebw8.tga"
1000
)
)
( every-time
( = @DigitValue[0] 9 )
( show-subtitle
@NumberX[0]
@NumberY[0]
" "
@NumberDisplayTime[0]
"ebw9.tga"
1000
)
)
( modify-variable
@NumberX[0]
( + @NumberX[0] 24 )
)
( every-time
( = @DigitUnitValue[0] 1 )
( modify-variable
@NumberDrawFlag[0]
0
)
)
( modify-variable
@DigitUnitValue[0]
( / @DigitUnitValue[0] 10 )
)
)
+Name: show number
+Repeat Count: 10000
+Interval: 5
+Team: 0
#Goals ;! 0 total
#Waypoints ;! 1 lists total
$Name: Dest
$List: ( ;! 1 points in list
( 0.000000, 0.000000, 100000.000000 )
)
#Messages ;! 1 total
$Name: Negative Number Error
$Team: -1
$MessageNew: XSTR("show number does not support negative numbers", -1)
$end_multi_text
#Reinforcements ;! 0 total
#Background bitmaps ;! 0 total
$Num stars: 500
$Ambient light level: 7895160
;;FSO 3.6.9;; $Bitmap List:
$Sun: SunWhite
+Angles: 0.000000 0.000000 1.047197
+Scale: 1.000000
#Asteroid Fields
#Music
$Event Music: None
$Briefing Music: None
#End
The events that require the player kills etc is what i need. I also need to know how to get a percentage of completed objectives in the entire campaign for the ranking and rating (eg rookie, pilot, pussy etc.) For example if the player had completed 60% of the total objectives then the (Frearless event) would come true.
Any help in this matter would be appretiaited and credited accordingly in the Earth Brakiri War (Babylon 5 campaign).
MAG :)
-
Can't really help you much with the first part but the percentage of completed objectives could be done using the is-previous-event and is-previous-goal true operators. You would need to know what to divide by. Easy way if it were a liner campaign would be to just count up the total.
The other way if the campaign isn't linear and/or you can't use the is-previous sexps would be to use persistent variables to add up the total possible objective for each mission and the number completed.
Using persistent variables to count up the player stats might work too but I don't know how you could display them.
-
If you use 3.6.10 you have access to the new SEXPs I added with which you can count kills, assists, score and player-deaths. A little clever use of those with persistent variables should allow you to count all that stuff over the entire campaign (use a player-persistent rather than campaign-persistent for the last of those though or you'll get a score of zero for obvious reasons :p ).
All you have to do is write that value into the variable at the end of the mission (Except for player-deaths which you simply increment whenever alpha 1 is destroyed).
-
Cheers fubar, Sounds good Kara, should be just what im after. So how do i add the persistant variables?
-
Always check the Wiki and Kara's FAQ for the quick answers: http://homepage.ntlworld.com/karajorma/FAQ/fredretail.html#variables
Never tried them myself but seems easy enough.
-
Yeah it's pretty easy. Simply update them like this
Mission Completed
When
-Whatever ends the mission
-modify-variable
--Alpha1Kills[0]
-- +
---Alpha1Kills[0]
---num-kills
----Alpha 1
The player deaths has to be be handled differently of course.
when
-is-destroyed-delay
-0
-Alpha 1
-modify-variable
--Alpha1Deaths[0]
-- +
---Alpha1Deaths[0]
---1
As I said, this variable must be a player PV not a campaign PV otherwise it would reset back to 0 when you restarted the mission. You can check how often a player replayed the missions of your campaign by simply adding 1 to a player persistent variable at the start of each mission and then subtracting the number of missions in the campaign at the end.
As for how to get this data out again at the end. If a message or briefing contains this, $Alpha1Kills the current value of Alpha1Kills will be printed in the message. IIRC the value of the variable when the message is sent rather than when it is actually played is sent but apart from that is fairly simple (and since you're probably only using this in briefings and debriefs that shouldn't matter).
-
Excellent Kara, ill try it shortly. Thanks for your help I will give you a mention in the credits :)
-
Im starting to update the missions as mentioned. I guess for the player score & Assists will be the same as kills etc (Making a new pv for score, assists etc.)
I guess this would be very complicated for displaying the rank and rating
What I could do is instead of basing the rank etc on the percentage of completed objectives through the campaign, I could base it on player kills and deaths. How would I check the number of kills and deaths etc as a percentage at the end of the campaign? Then how would i set the event to true if the kills and death are over a percentage or between 2 percentages.
eg. the player ranking - "Pilot" would be true if the total player kills is more than 20 and less than 35, and the player deaths is less than 20 player deaths.
Cheers :)
-
Check Vidmaster_MD01 in the TBP multiplayer. It's in the debriefing but you could be moved to an event as well.
-
If you use 3.6.10 you have access to the new SEXPs.
Cheers fubar, Sounds good Kara, should be just what im after. So how do i add the persistant variables?
Excellent Kara, ill try it shortly. Thanks for your help I will give you a mention in the credits :)
Did i miss a 3.6.10 release > :shaking:
-
Several dozen of them at least but no final one.
-
Got round to putting the PVs into all 27 missions and sorted the stats mission out. I played through the camapign but because I encountered a few bugs (i used notepad for the inclusion of pvs) a couple of missions before the end of the campaign, when it buged out oit must of reset all the variables. The final stats screen worked a dream but the kilss etc where very low and must have only been from the last couple of missions. More testing will see how accurate it is.
Thanks Kara for your help on this, I will include you in the credits :)
If you havnt seen the trailer for EBW then take a look
www.heatemup.co.uk/ebwt.avi - 20mb avi (xvid)