Files
assaultcube-/config/menus_bot.cfg
T
ac-stef b650fca2ca persistidents cleanup
Restore the old persistidents system from AC 1.0, since it's working as
intended - if used properly.

As a reminder:

  * aliases created by "const" and "tempalias" are never persistent
  * aliases created or altered by "alias" or "=" become persistent, if
    the persistidents flag is set during that operation
  * persistidents if false during the execution of almost all config files
    during game start - those files can create aliases with default values
    which will not be persistent (until changed later while the flag is
    set)
  * before saved.cfg is executed, the flag is set and stays set all
    throughout the game - which means, that all changes (from menus, for
    example) will change the altered alias to "persistent"
  * exceptions for map or model config files are unnecessary, since those
    run restricted and can't create aliases anyway
  * exceptions are necessary for "late run" config files like those in
    config/opt/

The new command "persistidents" may be used to manually set or clear the
flag. It also returns the current state of the flag. If used in a config
file, the flag is restored to its original value when the file ends
execution.

In short: only late-run config files (meaning: run after saved.cfg was
restored) may need to manually set/reset the flag. Use const and tempalias
where appropriate and clear persistidents before creating an alias with a
not-to-save default value that may be changed and made persistent later.

DOCREF persistidents
2017-05-05 15:50:59 +02:00

178 lines
5.8 KiB
INI

// bot menus and tools
newmenu botmaps
const genbotmaps [
looplist $arg1 listmapname [
menuitemmapload $listmapname (concat "tmp_botmap =" $listmapname "; startbotmap")
]
]
genbotmaps $defaultmaps
tempalias tmp_botskill good
tempalias tmp_numbots 1
tempalias tmp_mode ""
tempalias tmp_botmap ""
tempalias tmp_isbotteammode 0
// add bots
const startbotmatch [
if ($tmp_isbotteammode) [ // team botmode
tempalias numrvsf (div $tmp_numbots 2)
tempalias numcla (div $tmp_numbots 2)
if (= (player1 team) 0) [ -- numcla ] [
if (= (player1 team) 1) [ -- numrvsf ]
]
if (&& (= $numrvsf $numcla) $needsswitch) [ -- numrvsf ]
addnbot $numrvsf RVSF $tmp_botskill
addnbot $numcla CLA $tmp_botskill
] [ // bot FFA
addnbot $tmp_numbots random $tmp_botskill
]
]
const preparebotmatch [
echo starting botmatch..
tempalias needsswitch 0
if (&& (!= (player1 team) 0) (!= (player1 team) 1)) [ needsswitch = 1; team RVSF ]
// register event that is fired during mapload
addOnLoadOnce [
kickallbots
startbotmatch // add bots
mode 0 // reset mode for next maps
]
mode $tmp_mode
map $tmp_botmap $menuBotGameLength
]
const afterdisconnect [
if $connected [
addOnLoadOnce $arg1
disconnect
] [
if (watchingdemo) [
addOnLoadOnce $arg1
stopdemo
] $arg1
]
]
// register events and change map
const startbotmap [ afterdisconnect preparebotmatch ]
const emptymap [
afterdisconnect [
mode 0
showmenu maps
]
]
newmenu singleplayer
// teamplay not mature yet
menuitem "Bot Team Deathmatch" [ tmp_mode = 7; tmp_isbotteammode = 1; showmenu botskill ]
menuitem "Bot Deathmatch" [ tmp_mode = 8; tmp_isbotteammode = 0; showmenu botskill ]
menuitem "Bot One Shot, One Kill" [ tmp_mode = 12; tmp_isbotteammode = 0; showmenu botskill ]
menuitem "Bot Pistol Frenzy" [ tmp_mode = 18; tmp_isbotteammode = 0; showmenu botskill ]
menuitem "Bot Last Swiss Standing" [ tmp_mode = 19; tmp_isbotteammode = 0; showmenu botskill ]
menuitem "Bot Team Survivor" [ tmp_mode = 20; tmp_isbotteammode = 1; showmenu botskill ]
menuitem "Bot Team One Shot, One Kill" [ tmp_mode = 21; tmp_isbotteammode = 1; showmenu botskill ]
menuitem "Bot Survival" [ load_survival ; showmenu [Survival Mode] ]
menuitem "" -1
menuitem "Bot settings..." [ showmenu [Bot settings] ]
menuitem "" -1
menuitem "Empty map" emptymap
menuitem "Search map..." [ showmenu [search map] ]
searchmap = ""
newmenu [search official map]
menudirlist "packages/maps/official" cgz [map $arg1] 0 searchmap
newmenu [search custom map]
menudirlist "packages/maps" cgz [map $arg1] 0 searchmap
newmenu [search map]
menuitemtextinput "Part of map name or description: " "result $searchmap" [ searchmap = $arg1 ]
menuitem "\f2\t\tSearch in official maps" [ showmenu [search official map] ]
menuitem "\f2\t\tSearch in custom maps" [ showmenu [search custom map] ]
const showmenu_enemies [ if ($tmp_isbotteammode) [ showmenu [team enemies] ] [ showmenu enemies ] ]
newmenu botskill
menuitem Best [ tmp_botskill = best; showmenu_enemies ]
menuitem "Good (default)" [ tmp_botskill = good; showmenu_enemies ]
menuitem Medium [ tmp_botskill = medium; showmenu_enemies ]
menuitem Worse [ tmp_botskill = worse; showmenu_enemies ]
menuitem Bad [ tmp_botskill = bad; showmenu_enemies ]
const genenemyitems [
loop i (listlen $arg1) [
numplayers = (at $arg1 $i)
if (= $arg2 0) [ // DM
-= numplayers 1 // don't count yourself as enemy
menutext = (concat (+ $numplayers 1) players)
] [ // TDM
teamsize = (div $numplayers 2)
menutext = (concatword $teamsize vs $teamsize)
]
menuitem $menutext (concat [tmp_numbots =] $numplayers [; showmenu botmaps])
]
]
newmenu enemies
genenemyitems [2 4 8 12 16 24 32] 0
newmenu [team enemies]
genenemyitems [4 8 12 16 24 32] 1
newmenu [Bot settings]
menuitemslider "Bot match length in minutes: " 1 60 "$menuBotGameLength" 1 [] [ menuBotGameLength = $arg1 ]
menuitemcheckbox "Idle bots?" "(idlebots 2)" [ idlebots $arg1 ]
menuitemcheckbox "Bots attack?" "(botsshoot 2)" [ botsshoot $arg1 ]
newmenu [Creating bot waypoints]
menuitem "Waypoints..." [ showmenu Waypoints ]
menuitem "Paths..." [ showmenu Paths ]
menuitem "Other operations..." [ showmenu [Other bot operations] ]
menuitem "" -1
menuitem "Flood map with waypoints" wpflood
menuitem "Save bot waypoints" wpsave
newmenu Waypoints
menuitem "Add a waypoint" [ addwp 0 ]
menuitem "Add auto-connecting waypoint" [ addwp 1 ]
menuitem "" -1
menuitem "Delete nearest waypoint" delwp
menuitem "Delete all waypoints" [ showmenu [Delete all waypoints] ]
newmenu Paths
menuitem "Create Start of 2-way path" addpath2way1
menuitem "Create End of 2-way path" addpath2way2
menuitem "Delete Start of 2-way path" delpath2way1
menuitem "Delete End of 2-way path" delpath2way2
menuitem "" -1
menuitem "Create Start of 1-way path" addpath1way1
menuitem "Create End of 1-way path" addpath1way2
menuitem "Delete Start of 1-way path" delpath1way1
menuitem "Delete End of 1-way path" delpath1way2
newmenu [Other bot operations]
menuitem "Set waypoint as jumpable" setjumpwp
menuitem "Unset waypoint as jumpable" unsetjumpwp
menuitem "Set waypoint direction (yaw)" setwpyaw
menuitem "" -1
menuitemslider "Waypoint visibility: " 0 1 [ ] 1 ["Hide waypoints" "Show waypoints"] [ wpvisible $arg1 ]
menuitemslider "Select/place waypoints by: " 0 1 "($xhairwpsel)" 1 ["Your current location" "Clicking a point on the grid"] [ xhairwpsel $arg1 ]
newmenu [Delete all waypoints]
menuinit [ delallwps = 0 ] // Ensures this menu works correctly.
menuitemcheckbox "Yes, delete all waypoints: " [delallwps = 1] [delallwps = $arg1]
menuitem "\f2\t\t Apply!" [ if $delallwps wpclear [ showmenu [] ] ]