mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
182 lines
4.8 KiB
Text
182 lines
4.8 KiB
Text
// cb.gib
|
|
//
|
|
// CustomTF class builder for GIB in QuakeForge 0.5
|
|
//
|
|
// Copyright (C) 2002 Brian Koropoff
|
|
//
|
|
// This program is free software; you can redistribute it and/or
|
|
// modify it under the terms of the GNU General Public License
|
|
// as published by the Free Software Foundation; either version 2
|
|
// of the License, or (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
//
|
|
// See the GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program; if not, write to:
|
|
//
|
|
// Free Software Foundation, Inc.
|
|
// 59 Temple Place - Suite 330
|
|
// Boston, MA 02111-1307, USA
|
|
//
|
|
// $Id$
|
|
|
|
// Instructions:
|
|
//
|
|
// First, you'll need to load a menu for whatever server you are on,
|
|
// otherwise it won't know what items are available and where to find
|
|
// them on the custom menu. To use the provided prozac.menu, you would
|
|
// type:
|
|
// custom::load::menu prozac
|
|
//
|
|
// To load a class, get to the first page of the custom menu and use
|
|
// custom::load::class to load up a class file. To use the provided
|
|
// warlock.class, you would type:
|
|
// custom::load::class warlock
|
|
//
|
|
// To record a class, again get to the first page of the custom menu.
|
|
// Now type custom::record at the menu. This will rebind all your
|
|
// number keys to keep track of what selections you have made.
|
|
// If you decide to restart building your class, you will have to
|
|
// type custom::record again. After you have built your class,
|
|
// press 0 as usual. Instead of spawning, you will get a message
|
|
// that recording has finished. To save your class with the name
|
|
// "engy" you would then type:
|
|
// custom::record::save engy
|
|
// You can now use custom::load::class to construct your class at any
|
|
// time.
|
|
|
|
global custom
|
|
|
|
custom.load.menu_f = {
|
|
custom.menu.${custom.menu.size}.name = $1
|
|
custom.menu.${custom.menu.size}.size = 0
|
|
function "__menu" $2
|
|
__menu
|
|
custom.menu.size++
|
|
}
|
|
|
|
custom.load.item_f = {
|
|
local i
|
|
local n
|
|
i = ${custom.menu.size}
|
|
n = ${custom.menu.$i.size}
|
|
custom.menu.$i.$n = $1
|
|
custom.item.$1 = 1
|
|
custom.item.$1.menu = $i
|
|
custom.item.$1.number = $n
|
|
custom.menu.$i.size++
|
|
}
|
|
|
|
custom.load.buy_f = {
|
|
local i n
|
|
ifnot ${custom.item.$1} return
|
|
i = ${custom.item.$1.menu}
|
|
n = ${custom.item.$1.number}
|
|
custom::menu::seek $i
|
|
impulse ($n+1)
|
|
wait; wait; wait
|
|
}
|
|
|
|
|
|
function custom::load::menu {
|
|
local oldm oldi
|
|
oldm = `function::get menu`
|
|
oldi = `function::get item`
|
|
function "menu" ${custom.load.menu_f}
|
|
function "item" ${custom.load.item_f}
|
|
// Clear out old junk
|
|
global::delete custom.menu
|
|
global::delete custom.item
|
|
custom.menu.size = 0
|
|
exec "custom/", $1, ".menu"
|
|
function "menu" $oldm
|
|
function "item" $oldi
|
|
}
|
|
|
|
function custom::load::class {
|
|
local oldb
|
|
oldb = `function::get buy`
|
|
custom.menu.cur = 0
|
|
function "buy" ${custom.load.buy_f}
|
|
exec "custom/", $1, ".class"
|
|
function "buy" $oldb
|
|
}
|
|
|
|
function custom::menu::seek::forward {
|
|
custom.menu.cur = (${custom.menu.cur} + 1)
|
|
impulse 9
|
|
wait; wait;
|
|
}
|
|
|
|
function custom::menu::seek::backward {
|
|
custom.menu.cur = (${custom.menu.cur} - 1)
|
|
impulse 8
|
|
wait; wait;
|
|
}
|
|
|
|
function custom::menu::seek {
|
|
local func
|
|
if (${custom.menu.cur} < $1) {
|
|
func = custom::menu::seek::forward
|
|
} else {
|
|
func = custom::menu::seek::backward
|
|
}
|
|
while (${custom.menu.cur} != $1) $func
|
|
}
|
|
|
|
function custom::record::item {
|
|
local m line
|
|
m = ${custom.menu.cur}
|
|
ifnot ($1 < ${custom.menu.$m.size}) return
|
|
line = "buy \"", ${custom.menu.$m.$1}, "\""
|
|
custom.recording = ${custom.recording}, "\n", $line
|
|
impulse ($1+1)
|
|
}
|
|
|
|
function custom::record::seek {
|
|
local new
|
|
new = (${custom.menu.cur} + $1)
|
|
if ($new < 0 || $new >= ${custom.menu.size}) return
|
|
custom.menu.cur = $new
|
|
if ($1 < 0) {
|
|
impulse 8
|
|
} else {
|
|
impulse 9
|
|
}
|
|
}
|
|
|
|
function custom::record::stop {
|
|
bind "0" "impulse 10"
|
|
for i in `range 1 9` {
|
|
bind $i "impulse ", $i
|
|
}
|
|
echo "CustomBuild-> Recording finished"
|
|
custom.recording = "// Script recorded by CustomTF class builder", ${custom.recording}
|
|
}
|
|
|
|
function custom::record {
|
|
custom.menu.cur = 0
|
|
custom.recording = ""
|
|
bind "0" "custom::record::stop"
|
|
bind "8" "custom::record::seek -1"
|
|
bind "9" "custom::record::seek 1"
|
|
for i in `range 1 7` {
|
|
bind $i "custom::record::item ",($i-1)
|
|
}
|
|
echo "CustomBuild-> Recording class. Please build a class as usual."
|
|
custom
|
|
}
|
|
|
|
function custom::record::save {
|
|
local file
|
|
file = "custom/", $1, ".class"
|
|
echo "Saving class script to ", $file, "..."
|
|
file::write $file ${custom.recording}
|
|
}
|
|
|
|
function::export custom::load::menu custom::load::class custom::record::item
|
|
function::export custom::record::seek custom::record::stop custom::record custom::record::save
|