Scripting Concept of a scoring system for Dual Objective Maps
- [li]Content
[/li]This post deals with the scripting of some kind of scoring system for dual objective maps.
Actually the method I use is an enhanced version of the counters usually used for the winner determination in single objective maps.
I use four accums instead of one accum for the team that has to fullfill objectives and that counts the completed objectives.
One objective-counter for each team (that makes two), one for the sum of completed objectives (plus for Axis, minus for Allied) and the last one is used to register which team has firstly completed an objective.
So if no team achieves to completely fullfill all of their objectives the sum is checked.
If the sum is greater than 0 Axis are the winner.
If the sum is less than 0 Allied are the winner.
If the sum is 0 the fourth accum is checked.
Then the team that firstly completed the objective with highest priority is the winner.
Only in case that none of the teams is able to fullfill only one objective the game is a tie.
Remark: For the sum and the teambits I use some kind of weighting / priority system.
[li]Motivation
[/li]I followed the discussion in the SD-forum: timelimit_hit.
And so this idea has been born.
I think this method could be handy for Dual Objective Type maps.
[li]Script
[/li][list=a:e673fb8869]
[li]Overview
[/li]The script contains the “game_manager”-scriptblock and several Entity-scriptblocks.
The “game_manager”-scriptblock contains the needed events to check the accum’s.
[li]game_manager
[/li][list:e673fb8869]
[li]Spawn
[/li]Nothing unusuall here:
Setting of the used accums, the game rules and the objective data.
spawn { // accum 1 = No. of completed AXIS objectives accum 1 set 0 // accum 2 = No. of completed ALLIED objectives accum 2 set 0 // accum 3 = weighted sum of Axis and Allied objectives // Axis + | Allied - // if timelimit is hit: // if accum 3 > 0 Axis win // if accum 3 < 0 Allied win accum 3 set 0 // accum 4 = Bitsets for firstly completed objectives accum 4 set 0 // game rules // low values for testing purposes wm_axis_respawntime 5 wm_allied_respawntime 5 wm_set_round_timelimit 2 // AXIS Objectives: // 1: Primary: Destroy the AXIS_KLOTZ // 3: Primary: Secure the AXIS_GOLD // 5: Primary: Construct the AXIS_CONSTRUCTIBLE // ALLIED Objectives: // 2: Primary: Destroy the ALLIED_KLOTZ // 4: Primary: Secure the ALLIED_GOLD // 6: Primary: Construct the ALLIED_CONSTRUCTIBLE // Both: // 7: Primary: Capture the Flag wm_number_of_objectives 7 // No. of Primary objectives (objective-no. ; Team) // func_explosive's wm_set_main_objective 1 0 wm_set_main_objective 1 1 wm_set_main_objective 2 0 wm_set_main_objective 2 1 // Gold wm_set_main_objective 3 0 wm_set_main_objective 3 1 wm_set_main_objective 4 0 wm_set_main_objective 4 1 // Constructible wm_set_main_objective 5 0 wm_set_main_objective 5 1 wm_set_main_objective 6 0 wm_set_main_objective 6 1 // Flag wm_set_main_objective 7 0 wm_set_main_objective 7 1 // wm_objective_status objective-no. ; team ; status (0=neutral 1=complete 2=failed) // func_explosive's wm_objective_status 1 0 0 wm_objective_status 1 1 0 wm_objective_status 2 0 0 wm_objective_status 2 1 0 // Gold wm_objective_status 3 0 0 wm_objective_status 3 1 0 wm_objective_status 4 0 0 wm_objective_status 4 1 0 // Constructible wm_objective_status 5 0 0 wm_objective_status 5 1 0 wm_objective_status 6 0 0 wm_objective_status 6 1 0 // Flag wm_objective_status 7 0 0 wm_objective_status 7 1 0 // Winner if timelimit is hit wm_setwinner 1 wait 2000 }
[li]Summing up the objectives
[/li]Every time an objective is fullfiled I trigger the following “add”-events according to the priority of the objective.
Remark: Because the allied is going to be negative I inc accum 3 by -1 in the “add”-event.
I also added “sub”-events (“sub” for subtract).
These events are used if an objective has been fullfilled but has been “returned” by the other team (for example destruction of an constructible).
Remark: Because the allied is going to be negative I inc accum 3 by +1 in the “sub”-event.
For the other priorities I inc accum 3 by +2/-2, +3/-3, +4/-4 …
trigger AXIS_add_priority_type_1 { accum 3 inc 1 } trigger ALLIED_add_priority_type_1 { accum 3 inc -1 } trigger AXIS_sub_priority_type_1 { accum 3 inc -1 } trigger ALLIED_sub_priority_type_1 { accum 3 inc 1 } // parts snipped
[li]Setting of the teambits
[/li]Accum 4 only contains data about which team firstly has completed an objective.
I decided to split up this process into two parts.
One Bit contains the information if this type of objective has already been fullfilled.
Another Bit contains the information which team has fullfilled this type of objective.
As accums contain 32 Bits one accum has the ability to store the informaton about 16 objectives.
If the Bit for this type of objectives has already been set I abort.
Otherwise I set this Bit. And also the Bit for the team.
I have initialized accum 4 with 0.
So the bitresets in the “axis”-events are actually unnecessary.
trigger AXIS_setbit_objective_priority_type_1 { accum 4 abort_if_bitset 1 accum 4 bitset 1 accum 4 bitreset 16 // Bit 16 = 0 = AXIS } trigger ALLIED_setbit_objective_priority_type_1 { accum 4 abort_if_bitset 1 accum 4 bitset 1 accum 4 bitset 16 // Bit 16 = 1 = ALLIED } // parts snipped
[li]Checkgames
[/li]Nothing unusuall here.
I inc the appropriate accum.
And check if the total No. of objectives is fullfilled.
If no I abort.
If yes I set the winner and end the round. - **** UPDATED *****
trigger AXIS_checkgame { accum 1 inc 1 accum 1 abort_if_not_equal 4 wm_setwinner 0 wm_endround } trigger ALLIED_checkgame { accum 2 inc 1 accum 2 abort_if_not_equal 4 wm_setwinner 1 wm_endround } // events for destruction of constructibles trigger AXIS_checkgame_sub { accum 1 inc -1 } trigger ALLIED_checkgame_sub { accum 2 inc -1 } // events for recapturing the flag trigger AXIS_checkgame_flag_sub { accum 4 abort_if_not_bitset 4 accum 1 inc -1 } trigger ALLIED_checkgame_flag_sub { accum 4 abort_if_not_bitset 4 accum 2 inc -1 }
[li]Timelimit Hit
[/li]The “timelimit_hit”-event and the checking of accum 3 and accum 4 is a little bit tricky.
[list:e673fb8869]
[li]timelimit_hit
[/li]First I set the winner to -1.
So in case the checking of accum 3 and accum 4 does not determine a winner the game is a tie.
If accum 3 is 0 (means the weighted sum of the fullfilled objectives of both teams is equal) I check accum 4 and abort the script.
Otherwise (accum 3 is greater or less than zero) I check accum 3.
trigger timelimit_hit { wm_setwinner -1 accum 3 trigger_if_equal 0 game_manager gamecheck_teambitset accum 3 abort_if_equal 0 // test accum 3 trigger game_manager gamecheck_variable_axis trigger game_manager gamecheck_variable_allied wm_endround }
[li]accum 4
[/li]For every objective priority type I check the bits.
If the according bit is set I check the teambit.
Otherwise I abort the script (meaning none of the teams has firstly fullfilled this objective prority type).
If it has been fullfilled I set the winner to team 1.
Afterwards I check this. If this is true (teambit is really 1) I abort the script.
Otherwise (teambit is 0) I set the winner to 0.
trigger gamecheck_teambitset { // checking in ascending priority trigger game_manager teambitset_objective_priority_type_1 trigger game_manager teambitset_objective_priority_type_2 trigger game_manager teambitset_objective_priority_type_3 trigger game_manager teambitset_objective_priority_type_4 wm_endround } trigger teambitset_objective_priority_type_1 { accum 4 abort_if_not_bitset 1 wm_setwinner 1 // set ALLIED as winner accum 4 abort_if_bitset 16 // stops if bit 16 = 1 == ALLIED are really the winner wm_setwinner 0 // otherwise (bit 16 = 0) sets AXIS as winner } // parts snipped
[li]accum 3
[/li]If this part of script is executed accum 3 must be greater then 0 or less than 0.
I abort the script if the conditions are not correct.
Otherwise I set the winner.
trigger gamecheck_variable_axis { accum 3 abort_if_less_than 0 wm_setwinner 0 } trigger gamecheck_variable_allied { accum 3 abort_if_greater_than 0 wm_setwinner 1 }
[/list:u:e673fb8869]
[li]Entities
[/li]The only difference to other scripts:
I trigger three events instead of one.
Remark: Only the Allied objectives are shown here.
- [li]func_explosive
[/li]
scr_ALLIED_KLOTZ { spawn { wait 200 constructible_class 3 } death { wm_objective_status 2 0 2 wm_objective_status 2 1 1 wm_announce "Allied have blown up the func_explosive!" trigger game_manager ALLIED_add_priority_type_1 trigger game_manager ALLIED_setbit_objective_priority_type_1 trigger game_manager ALLIED_checkgame } }
[li]team_CTF-Flag + trigger_flagonly_multiple
[/li]
scr_ALLIED_GOLD { spawn { wait 200 setstate ALLIED_GOLD_CAPTURED invisible setstate ALLIED_GOLD_script_mover_secured invisible } trigger stolen { wm_teamvoiceannounce 0 "Secure the Gold" wm_teamvoiceannounce 1 "The Allied have stolen the Gold" setstate ALLIED_GOLD_cm invisible } trigger returned { wm_teamvoiceannounce 0 "The Allies have retrieved the Gold" wm_teamvoiceannounce 1 "Gold returned! Protect the Gold" setstate ALLIED_GOLD_cm default } trigger captured { setstate ALLIED_GOLD_RED invisible setstate ALLIED_GOLD_CAPTURED default setstate ALLIED_GOLD_script_mover_secured default } } scr_ALLIED_GOLD_flagonly { spawn { } death { wm_objective_status 4 0 2 wm_objective_status 4 1 1 wm_announce "The Allied have secured the Gold" trigger game_manager ALLIED_add_priority_type_2 trigger game_manager ALLIED_setbit_objective_priority_type_2 trigger game_manager ALLIED_checkgame } }
[li]func_constructible
[/li]Remark: If the constructible is destroyed I call the appropriate “sub”-event (subtract).
The temabit for firstly fullfilling this type of objective is not touched.
scr_ALLIED_CONSTRUCTIBLE { spawn { wait 200 trigger self setup constructible_class 3 } trigger setup { setstate ALLIED_CONSTRUCTIBLE invisible setstate ALLIED_CRATES default } buildstart final { setstate ALLIED_CONSTRUCTIBLE underconstruction setstate ALLIED_CRATES default } built final { setstate ALLIED_CONSTRUCTIBLE default setstate ALLIED_CRATES invisible wm_objective_status 6 0 2 wm_objective_status 6 1 1 wm_announce "The Allied Constructible has been build" trigger game_manager ALLIED_add_priority_type_3 trigger game_manager ALLIED_setbit_objective_priority_type_3 trigger game_manager ALLIED_checkgame } decayed final { trigger self setup } death { trigger self setup wm_objective_status 6 0 1 wm_objective_status 6 1 2 wm_announce "The Allied Constructible has been destroyed" trigger game_manager ALLIED_sub_priority_type_3 trigger game_manager ALLIED_checkgame_sub } }
[li]team_WOLF_checkpoint
[/li]***** UPDATED *****
scr_KOTH_FLAG { trigger axis_capture { wm_objective_status 7 0 1 wm_objective_status 7 1 2 wm_announce "The Axis have captured the Flag" trigger game_manager AXIS_add_priority_type_4 // trigger game_manager ALLIED_sub_priority_type_4 trigger game_manager ALLIED_checkgame_flag_sub trigger game_manager AXIS_setbit_objective_priority_type_4 trigger game_manager AXIS_checkgame } trigger allied_capture { wm_objective_status 7 0 2 wm_objective_status 7 1 1 wm_announce "The Allied have captured the Flag" trigger game_manager ALLIED_add_priority_type_4 // trigger game_manager AXIS_sub_priority_type_4 trigger game_manager AXIS_checkgame_flag_sub trigger game_manager ALLIED_setbit_objective_priority_type_4 trigger game_manager ALLIED_checkgame } }
[/list:o:e673fb8869]
[li]Download
[/li]You can download a sample map (source included) at the following address (~ 100 KB):
http://www.nullskillz.de/et/maps/concept_dual_objective.zip
The map is not meant as playing map.
It’s only a sample map.
So I hope you will be patient with me and my mapping SkillZ.
Therefore the scripting is very evil I think.
[li]Known Map Bugs
[/li][ul]
[li]no “clip”-Brushes at the constructibles
[/li][li]the builded constructibles are “porous”
[/li][li]no “trigger_objective_info”- and “misc_commandmap_marker”-entities at the KOTH-Flag
[/li][li]messages concerning the spawn-points in limbo menu (“warning …”)
[/li][li]the “team_CTF”-Flags and the trigger_flagonly_multiple"-Entities should be named other way around (“AXIS_…” should be “ALLIED_…” and vice versa)
[/li][/ul]
[li]Future
[/li]Thinking of CTF (in the terms of dominating the flags / King of the Hill) I’m not satisfied with the handling of the scoring system of the flag.
It’s possible that one team dominates the flag / flags for almost all the time.
But the other team gains the victory because it captures the flag / flags in the last second.
I have the idea to count the seconds while the teams dominate a flag. May be also as sum.
If none of the teams is possible to dominate all the flags the team with the higher counter (for the sum: greater than zero or less than zero) would be the winner.
[li]Credits
[/li][ul]
[li]Fragpoint
[/li]for his Wolfenstein tutorial at http://www.fragpoint.de
[li]G0-Gerbil
[/li]for the permission to use two of his textures (the Axis and the Allied Flag) originally designed for his idea of patrol points
(go and visit THEBURROW)
[li]Ifurita
[/li]for his tutorials “Map Scripting 4 Newbies”, “Making Returnable Objectives (Prefab and script)” and “How Do I Make a PK3 File?”
(go and visit Mapping 4 Newbies)
[li]Judgement
[/li]for his Video Tutorial “Baubare Objekte” (buildable objects)
[li]Ron007
[/li]for his Video Tutorials “Einfaches Objective” (simple objective) and “Multispawns bauen” (building multispawns)
[li]Forummembers @ http://www.level-designer.de
[/li][li]Forummembers @ http://www.splashdamage.com
[/li][/ul]
[li]Final Statement
[/li]Suggestions, criticism and first of all corrections are at any time gladly
welcome.
[/list:o:e673fb8869]
too bad for them 