Skip to content

Commit

Permalink
expand compiler syntax, bo4 weapon fields and dev tests for cw
Browse files Browse the repository at this point in the history
  • Loading branch information
ate47 committed Feb 4, 2024
1 parent ac9d0ea commit 97717b2
Show file tree
Hide file tree
Showing 16 changed files with 2,153 additions and 84 deletions.
2 changes: 1 addition & 1 deletion coldwar/scripts/config/config.gsc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

AtianMenuConfig() {
function AtianMenuConfig() {
// - fly when moving, default 20
self.fly_speed_normal = 20;
// - fly when moving fast, default 60
Expand Down
2 changes: 1 addition & 1 deletion coldwar/scripts/config/keys.gsc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* These configurations are used to control the keys inside the menu.
*
*/
AtianMenuKeyConfig() {
function AtianMenuKeyConfig() {
// key config, options:
// "action", "actionslotfour", "actionslotone", "actionslotthree", "actionslottwo", "ads", "attack",
// "changeseat", "frag", "jump", "melee", "offhandspecial", "reload", "secondaryoffhand", "sprint",
Expand Down
2 changes: 1 addition & 1 deletion coldwar/scripts/core_common/config_ci.gsc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

AtianMenuConfigContinuousIntegration() {
function AtianMenuConfigContinuousIntegration() {
// - fly when moving, default 20
self.fly_speed_normal = 20;
// - fly when moving fast, default 60
Expand Down
17 changes: 17 additions & 0 deletions coldwar/scripts/core_common/dev/config.gsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifdef ATIAN_MENU_DEV
function AtianMenuConfigDev() {
// zombies per round
self.zombies_per_rounds = 99999;

self.force_camo = 63;


self.preloaded_menus = array(
"tool_menu::Ammos",
"tool_zm::Max Points",
"tool_zm::Ignore me",
"tool_menu::Invulnerability"
);

}
#endif
13 changes: 10 additions & 3 deletions coldwar/scripts/core_common/gamemode.gsc
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@

is_warzone() {
function is_warzone() {
return sessionmodeiswarzonegame();
}

is_zombies() {
function is_zombies() {
return sessionmodeiszombiesgame();
}

is_multiplayer() {
function is_multiplayer() {
return sessionmodeismultiplayergame();
}

function is_dev_mode() {
#ifdef ATIAN_MENU_DEV
return true;
#else
return false;
#endif
}
63 changes: 50 additions & 13 deletions coldwar/scripts/core_common/header.gsc
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,42 @@

#namespace atianmenu;

autoexec __init__system__() {
function autoexec __init__system__() {
load_cfg();
system::register(#"atianmenu", &__pre_init__, undefined, undefined, undefined);
system::ignore(#"cheat");
}

__pre_init__() {
function event_handler[gametype_init] gametype_init(*eventstruct) {
if (is_zombies()) {
thread init_gametype_zm();
}
}

function init_gametype_zm() {
waitframe(1);
level.atian.old_count_zombies = level.var_ef1a71b3;
level.var_ef1a71b3 = &count_zombies;
}

function __pre_init__() {
callback::on_connect(&on_player_connect);

if (isdefined(level.atianconfig.player_starting_points)) {
level.player_starting_points = level.atianconfig.player_starting_points;
}
}

load_cfg() {
function load_cfg() {
level.atian = spawnstruct();
level.atianconfig = spawnstruct();
#ifdef CI
level.atianconfig AtianMenuConfigContinuousIntegration();
#else
level.atianconfig AtianMenuConfig();
#ifdef ATIAN_MENU_DEV
level.atianconfig AtianMenuConfigDev();
#endif
#endif
}

Expand All @@ -43,17 +59,17 @@ B3ABBFCD
*/

get_look_trace() {
function get_look_trace() {
tag_origin = self geteye();
look = AnglesToForward(self GetPlayerAngles());
return bullettrace(tag_origin, tag_origin + vectorscale(look, 10000), 1, self);
}
get_look_position() {
function get_look_position() {
return get_look_trace()[#"position"];
}


on_player_connect() {
function on_player_connect() {
self.atian = spawnStruct();
self endon("disconnect", #"bled_out");
level endon(#"end_game", #"game_ended");
Expand Down Expand Up @@ -91,18 +107,20 @@ on_player_connect() {
// wait some frames to avoid init things
waitframe(20);

level.var_ef1a71b3 = &count_zombies;

self childthread fly_mode();
self childthread infinite_ammo();
self childthread god_mode();
self childthread set_camo();
}

count_zombies() {
return 99999999;
function count_zombies(*round_number, *player_count) {
if (isdefined(level.atianconfig.zombies_per_rounds) && level.atianconfig.zombies_per_rounds > 0) {
return level.atianconfig.zombies_per_rounds;
}
return [[ level.atian.old_count_zombies ]](round_number, player_count);
}

god_mode() {
function god_mode() {
while (true) {
if (self is_mod_activated("maxpoints")) {
self.score = 99999;
Expand Down Expand Up @@ -135,7 +153,7 @@ god_mode() {
}
}

infinite_ammo() {
function infinite_ammo() {
while(true) {
if (self is_mod_activated("maxammo")) {
weapon = self GetCurrentWeapon();
Expand All @@ -156,7 +174,7 @@ infinite_ammo() {
}
}

fly_mode() {
function fly_mode() {
self notify(#"stop_player_out_of_playable_area_monitor");
self unlink();
if(isdefined(self.originObj)) self.originObj delete();
Expand Down Expand Up @@ -234,4 +252,23 @@ fly_mode() {
}
waitframe(1);
}
}

set_camo() {
while(true) {
if (!isdefined(level.atianconfig.force_camo)) {
waitframe(1);
continue;
}
weapon = self GetCurrentWeapon();
offhand = self GetCurrentOffhand();

if (isdefined(weapon)) {
self setcamo(weapon, level.atianconfig.force_camo);
}
if (isdefined(offhand)) {
self setcamo(offhand, level.atianconfig.force_camo);
}
self waittill(#"weapon_change");
}
}
14 changes: 7 additions & 7 deletions coldwar/scripts/core_common/keymanager.gsc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
key_mgr_init() {
function key_mgr_init() {
if (isdefined(self.key_mgr)) {
// ignore menu creation if already set
return;
Expand Down Expand Up @@ -31,12 +31,12 @@ key_mgr_init() {
self key_mgr_compile_key(#"special_weapon_ternary", key_config.special_weapon_ternary, #"use");
}

key_mgr_is_valid(key) {
function key_mgr_is_valid(key) {
key_mgr_init();
return array::contains(self.key_mgr.valid, key);
}

key_mgr_compile_key(id, config, default_config) {
function key_mgr_compile_key(id, config, default_config) {
if (!isdefined(config)) {
// no config, use default
// force array
Expand All @@ -60,7 +60,7 @@ key_mgr_compile_key(id, config, default_config) {
self.key_mgr.config[id] = cfg;
}

key_mgr_get_key_str(id) {
function key_mgr_get_key_str(id) {
key_mgr_init();

if (!isdefined(self.key_mgr.config[id])) {
Expand All @@ -80,7 +80,7 @@ key_mgr_get_key_str(id) {

return s;
}
key_mgr_has_key_pressed(id, wait_release = false) {
function key_mgr_has_key_pressed(id, wait_release = false) {
key_mgr_init();

if (!isdefined(self.key_mgr.config[id])) {
Expand Down Expand Up @@ -114,7 +114,7 @@ key_mgr_has_key_pressed(id, wait_release = false) {
return true;
}

key_mgr_get_key_str_id(id) {
function key_mgr_get_key_str_id(id) {
switch (id) {
case #"action": return "[{+action}]";
case #"actionslotfour": return "[{+actionslot 4}]";
Expand All @@ -140,7 +140,7 @@ key_mgr_get_key_str_id(id) {
default: return "??";
}
}
key_mgr_has_key_pressed_id(id) {
function key_mgr_has_key_pressed_id(id) {
switch (id) {
case #"action":
return self actionbuttonpressed();
Expand Down
35 changes: 18 additions & 17 deletions coldwar/scripts/core_common/menu.gsc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
init_menu(menu_title) {
function init_menu(menu_title) {
if (isdefined(self.menu_info)) {
// ignore menu creation if already set
return false;
Expand All @@ -19,22 +19,23 @@ init_menu(menu_title) {
return true;
}

menu_drawing_function(txt) {
function menu_drawing_function(txt) {
if (sessionmodeiszombiesgame()) {
self iprintlnbold(txt);
} else {
self iprintln(txt);
}
}

menu_drawing_secondary(txt) {
function menu_drawing_secondary(txt) {
if (sessionmodeiszombiesgame()) {
self iprintln(txt);
} else {
self iprintlnbold(txt);
}
}
get_menu_size_count() {

function get_menu_size_count() {
if (sessionmodeiszombiesgame()) {
return 5;
} else {
Expand All @@ -43,7 +44,7 @@ get_menu_size_count() {
}


toggle_mod(mod_name, value = undefined) {
function toggle_mod(mod_name, value = undefined) {
if (!isdefined(self.menu_info)) {
return;
}
Expand All @@ -63,11 +64,11 @@ toggle_mod(mod_name, value = undefined) {
}
}

is_mod_activated(mod_name) {
function is_mod_activated(mod_name) {
return isdefined(self.menu_info) && isdefined(self.menu_info.mods) && array::contains(self.menu_info.mods, mod_name);
}

add_menu(menu_id, menu_name, parent_id, create_switch = false, menuenterfunc = undefined, menuenterfuncdata1 = undefined, menuenterfuncdata2 = undefined, menuenterfuncdata3 = undefined, menuenterfuncdata4 = undefined) {
function add_menu(menu_id, menu_name, parent_id, create_switch = false, menuenterfunc = undefined, menuenterfuncdata1 = undefined, menuenterfuncdata2 = undefined, menuenterfuncdata3 = undefined, menuenterfuncdata4 = undefined) {
menu =
{
#id: menu_id,
Expand All @@ -89,7 +90,7 @@ add_menu(menu_id, menu_name, parent_id, create_switch = false, menuenterfunc = u
}
return menu;
}
add_menu_item(menu_id, item_name, action, actiondata = undefined, actiondata2 = undefined, actiondata3 = undefined, actiondata4 = undefined, actiondata5 = undefined) {
function add_menu_item(menu_id, item_name, action, actiondata = undefined, actiondata2 = undefined, actiondata3 = undefined, actiondata4 = undefined, actiondata5 = undefined) {
if (!isdefined(self.menu_info.menus[menu_id])) {
self menu_drawing_secondary("^1bad menu config " + menu_id + " isn't set!");
return;
Expand All @@ -114,12 +115,12 @@ add_menu_item(menu_id, item_name, action, actiondata = undefined, actiondata2 =
}


mod_switch(item, mod_name) {
function mod_switch(item, mod_name) {
item.activated = toggle_mod(mod_name);
return true;
}

menu_switch(item, menu_id) {
function menu_switch(item, menu_id) {
if (!isdefined(menu_id)) {
menu_id = "";
}
Expand All @@ -145,19 +146,19 @@ menu_switch(item, menu_id) {
return true;
}

add_menu_item_menuswitch(menu_id, item_name, new_menu_id) {
function add_menu_item_menuswitch(menu_id, item_name, new_menu_id) {
self add_menu_item(menu_id, item_name, &menu_switch, new_menu_id);
}

add_menu_item_modswitch(menu_id, item_name, mod_name) {
function add_menu_item_modswitch(menu_id, item_name, mod_name) {
self add_menu_item(menu_id, item_name, &mod_switch, mod_name);
}

get_current_menu() {
function get_current_menu() {
return self.menu_info.menus[self.menu_info.current_menu];
}

menu_think() {
function menu_think() {
if (!isdefined(self.menu_info)) {
// ignore menu creation if already set
return;
Expand Down Expand Up @@ -340,11 +341,11 @@ menu_think() {

}

ClickMenuButtonIsMenuNameEqual(menu_item, menu_name) {
function ClickMenuButtonIsMenuNameEqual(menu_item, menu_name) {
return menu_item.name == menu_name;
}

ClickMenuButton(menu_id, menu_item_name) {
function ClickMenuButton(menu_id, menu_item_name) {
menu = self.menu_info.menus[menu_id];
if (isdefined(menu)) {
menu_item_index = array::find(menu.sub_menus, menu_item_name, &ClickMenuButtonIsMenuNameEqual);
Expand All @@ -369,7 +370,7 @@ ClickMenuButton(menu_id, menu_item_name) {
}
}

menu_open_message(menu, message, func, data1, data2) {
function menu_open_message(menu, message, func, data1, data2) {

if (isdefined(message)) {
self menu_drawing_secondary(message);
Expand Down
Loading

0 comments on commit 97717b2

Please sign in to comment.