src/bots.h

changeset 73
1ee9b312dc18
parent 72
03e4d9db3fd9
child 74
007fbadfa7f9
--- a/src/bots.h	Fri Jan 10 21:58:42 2014 +0200
+++ b/src/bots.h	Sat Jan 11 22:36:31 2014 +0200
@@ -1,272 +1,167 @@
-//-----------------------------------------------------------------------------
-//
-// Skulltag Source
-// Copyright (C) 2002 Brad Carney
-// Copyright (C) 2007-2012 Skulltag Development Team
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// 1. Redistributions of source code must retain the above copyright notice,
-//    this list of conditions and the following disclaimer.
-// 2. Redistributions in binary form must reproduce the above copyright notice,
-//    this list of conditions and the following disclaimer in the documentation
-//    and/or other materials provided with the distribution.
-// 3. Neither the name of the Skulltag Development Team nor the names of its
-//    contributors may be used to endorse or promote products derived from this
-//    software without specific prior written permission.
-// 4. Redistributions in any form must be accompanied by information on how to
-//    obtain complete source code for the software and any accompanying
-//    software that uses the software. The source code must either be included
-//    in the distribution or be available for no more than the cost of
-//    distribution plus a nominal fee, and must be freely redistributable
-//    under reasonable conditions. For an executable file, complete source
-//    code means the source code for all modules it contains. It does not
-//    include source code for modules or files that typically accompany the
-//    major components of the operating system on which the executable file
-//    runs.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-//
-//
-//
-// Filename: bots.h
-//
-// Description: Contains bot structures and prototypes
-// [Dusk] Cropped out the stuff botc doesn't need.
-//
-//-----------------------------------------------------------------------------
+// Macros and enums from zandronum bots.h
 
 #ifndef BOTC_BOTS_H
 #define BOTC_BOTS_H
 
-//*****************************************************************************
-//  DEFINES
-
-// Maximum number of variables on the bot evaluation stack.
-#define	BOTSCRIPT_STACK_SIZE		8
-
-// Maximum number of botinto structures that can be defines.
-#define	MAX_BOTINFO					128
-
-// Maximum number of states that can appear in a script.
-#define	MAX_NUM_STATES				256
-
-// Maximum number of bot events that can be defined.
-#define	MAX_NUM_EVENTS				32
-
-// Maximum number of global bot events that can be defined.
-#define	MAX_NUM_GLOBAL_EVENTS		32
-
-// Maximum number of global variables that can be defined in a script.
-#define	MAX_SCRIPT_VARIABLES		128
-
-// Maximum number of global arrays that can be defined in a script.
-#define	MAX_SCRIPT_ARRAYS			16
-
-// Maximum number of global arrays that can be defined in a script.
-#define	MAX_SCRIPTARRAY_SIZE		65536
-
-// Maxmimum number of state (local) variables that can appear in a script.
-#define	MAX_STATE_VARIABLES			16
-
-// Maximum number of strings that can appear in a script stringlist.
-#define	MAX_LIST_STRINGS			128
+static const int g_max_states			= 256;
+static const int g_max_events			= 32;
+static const int g_max_global_events	= 32;
+static const int g_max_global_vars		= 128;
+static const int g_max_global_arrays	= 16;
+static const int g_max_array_size		= 65536;
+static const int g_max_state_vars		= 16;
+static const int g_max_stringlist_size	= 128;
+static const int g_max_string_length	= 256;
+static const int g_max_reaction_time	= 52;
+static const int g_max_stored_events	= 64;
 
-// Maximum length of those strings in the stringlist.
-#define	MAX_STRING_LENGTH			256
-
-// Maximum reaction time for a bot.
-#define	MAX_REACTION_TIME			52
-
-// Maximum number of events the bots can store up that it's waiting to react to.
-#define	MAX_STORED_EVENTS			64
-
-//*****************************************************************************
-typedef enum
-{
-	// Bot skill ratings.
-	BOTSKILL_VERYPOOR,
-	BOTSKILL_POOR,
-	BOTSKILL_LOW,
-	BOTSKILL_MEDIUM,
-	BOTSKILL_HIGH,
-	BOTSKILL_EXCELLENT,
-	BOTSKILL_SUPREME,
-	BOTSKILL_GODLIKE,
-	BOTSKILL_PERFECT,
-
-	NUM_BOT_SKILLS
-
-} BOTSKILL_e;
-
-//*****************************************************************************
-//  STRUCTURES
-//
-
-//*****************************************************************************
-//	These are the botscript data headers that it writes out.
-typedef enum
+enum e_data_header
 {
-	DH_COMMAND,
-	DH_STATEIDX,
-	DH_STATENAME,
-	DH_ONENTER,
-	DH_MAINLOOP,
-	DH_ONEXIT,
-	DH_EVENT,
-	DH_ENDONENTER,
-	DH_ENDMAINLOOP,
-	DH_ENDONEXIT,
-	DH_ENDEVENT,
-	DH_IFGOTO,
-	DH_IFNOTGOTO,
-	DH_GOTO,
-	DH_ORLOGICAL,
-	DH_ANDLOGICAL,
-	DH_ORBITWISE,
-	DH_EORBITWISE,
-	DH_ANDBITWISE,
-	DH_EQUALS,
-	DH_NOTEQUALS,
-	DH_LESSTHAN,
-	DH_LESSTHANEQUALS,
-	DH_GREATERTHAN,
-	DH_GREATERTHANEQUALS,
-	DH_NEGATELOGICAL,
-	DH_LSHIFT,
-	DH_RSHIFT,
-	DH_ADD,
-	DH_SUBTRACT,
-	DH_UNARYMINUS,
-	DH_MULTIPLY,
-	DH_DIVIDE,
-	DH_MODULUS,
-	DH_PUSHNUMBER,
-	DH_PUSHSTRINGINDEX,
-	DH_PUSHGLOBALVAR,
-	DH_PUSHLOCALVAR,
-	DH_DROPSTACKPOSITION,
-	DH_SCRIPTVARLIST,
-	DH_STRINGLIST,
-	DH_INCGLOBALVAR,
-	DH_DECGLOBALVAR,
-	DH_ASSIGNGLOBALVAR,
-	DH_ADDGLOBALVAR,
-	DH_SUBGLOBALVAR,
-	DH_MULGLOBALVAR,
-	DH_DIVGLOBALVAR,
-	DH_MODGLOBALVAR,
-	DH_INCLOCALVAR,
-	DH_DECLOCALVAR,
-	DH_ASSIGNLOCALVAR,
-	DH_ADDLOCALVAR,
-	DH_SUBLOCALVAR,
-	DH_MULLOCALVAR,
-	DH_DIVLOCALVAR,
-	DH_MODLOCALVAR,
-	DH_CASEGOTO,
-	DH_DROP,
-	DH_INCGLOBALARRAY,
-	DH_DECGLOBALARRAY,
-	DH_ASSIGNGLOBALARRAY,
-	DH_ADDGLOBALARRAY,
-	DH_SUBGLOBALARRAY,
-	DH_MULGLOBALARRAY,
-	DH_DIVGLOBALARRAY,
-	DH_MODGLOBALARRAY,
-	DH_PUSHGLOBALARRAY,
-	DH_SWAP,
-	DH_DUP,
-	DH_ARRAYSET,
-
-	NUM_DATAHEADERS
-
-} DATAHEADERS_e;
+	dh_command,
+	dh_state_index,
+	dh_state_name,
+	dh_on_enter,
+	dh_main_loop,
+	dh_on_exit,
+	dh_event,
+	dh_end_on_enter,
+	dh_end_main_loop,
+	dh_end_on_exit,
+	dh_end_event,
+	dh_if_goto,
+	dh_if_not_goto,
+	dh_goto,
+	dh_or_logical,
+	dh_and_logical,
+	dh_or_bitwise,
+	dh_eor_bitwise,
+	dh_and_bitwise,
+	dh_equals,
+	dh_not_equals,
+	dh_less_than,
+	dh_at_most,
+	dh_greater_than,
+	dh_at_least,
+	dh_negate_logical,
+	dh_left_shift,
+	dh_right_shift,
+	dh_add,
+	dh_subtract,
+	dh_unary_minus,
+	dh_multiply,
+	dh_divide,
+	dh_modulus,
+	dh_push_number,
+	dh_push_string_index,
+	dh_push_global_var,
+	dh_push_local_var,
+	dh_drop_stack_position,
+	dh_script_var_list,
+	dh_string_list,
+	dh_increase_global_var,
+	dh_decrease_global_var,
+	dh_assign_global_var,
+	dh_add_global_var,
+	dh_subtract_global_var,
+	dh_multiply_global_var,
+	dh_divide_global_var,
+	dh_mod_global_var,
+	dh_increase_local_var,
+	dh_decrease_local_var,
+	dh_assign_local_var,
+	dh_add_local_var,
+	dh_subtract_local_var,
+	dh_multiply_local_var,
+	dh_divide_local_var,
+	dh_mod_local_var,
+	dh_CASEGOTO,
+	dh_DROP,
+	dh_increase_global_array,
+	dh_decrease_global_array,
+	dh_assign_global_array,
+	dh_add_global_array,
+	dh_subtract_global_array,
+	dh_multiply_global_array,
+	dh_divide_global_array,
+	dh_mod_global_array,
+	dh_push_global_array,
+	dh_swap,
+	dh_dup,
+	dh_array_set,
+	num_data_headers
+};
 
 //*****************************************************************************
 //	These are the different bot events that can be posted to a bot's state.
-typedef enum
+enum e_event
 {
-	BOTEVENT_KILLED_BYENEMY,
-	BOTEVENT_KILLED_BYPLAYER,
-	BOTEVENT_KILLED_BYSELF,
-	BOTEVENT_KILLED_BYENVIORNMENT,
-	BOTEVENT_REACHED_GOAL,
-	BOTEVENT_GOAL_REMOVED,
-	BOTEVENT_DAMAGEDBY_PLAYER,
-	BOTEVENT_PLAYER_SAY,
-	BOTEVENT_ENEMY_KILLED,
-	BOTEVENT_RESPAWNED,
-	BOTEVENT_INTERMISSION,
-	BOTEVENT_NEWMAP,
-	BOTEVENT_ENEMY_USEDFIST,
-	BOTEVENT_ENEMY_USEDCHAINSAW,
-	BOTEVENT_ENEMY_FIREDPISTOL,
-	BOTEVENT_ENEMY_FIREDSHOTGUN,
-	BOTEVENT_ENEMY_FIREDSSG,
-	BOTEVENT_ENEMY_FIREDCHAINGUN,
-	BOTEVENT_ENEMY_FIREDMINIGUN,
-	BOTEVENT_ENEMY_FIREDROCKET,
-	BOTEVENT_ENEMY_FIREDGRENADE,
-	BOTEVENT_ENEMY_FIREDRAILGUN,
-	BOTEVENT_ENEMY_FIREDPLASMA,
-	BOTEVENT_ENEMY_FIREDBFG,
-	BOTEVENT_ENEMY_FIREDBFG10K,
-	BOTEVENT_PLAYER_USEDFIST,
-	BOTEVENT_PLAYER_USEDCHAINSAW,
-	BOTEVENT_PLAYER_FIREDPISTOL,
-	BOTEVENT_PLAYER_FIREDSHOTGUN,
-	BOTEVENT_PLAYER_FIREDSSG,
-	BOTEVENT_PLAYER_FIREDCHAINGUN,
-	BOTEVENT_PLAYER_FIREDMINIGUN,
-	BOTEVENT_PLAYER_FIREDROCKET,
-	BOTEVENT_PLAYER_FIREDGRENADE,
-	BOTEVENT_PLAYER_FIREDRAILGUN,
-	BOTEVENT_PLAYER_FIREDPLASMA,
-	BOTEVENT_PLAYER_FIREDBFG,
-	BOTEVENT_PLAYER_FIREDBFG10K,
-	BOTEVENT_USEDFIST,
-	BOTEVENT_USEDCHAINSAW,
-	BOTEVENT_FIREDPISTOL,
-	BOTEVENT_FIREDSHOTGUN,
-	BOTEVENT_FIREDSSG,
-	BOTEVENT_FIREDCHAINGUN,
-	BOTEVENT_FIREDMINIGUN,
-	BOTEVENT_FIREDROCKET,
-	BOTEVENT_FIREDGRENADE,
-	BOTEVENT_FIREDRAILGUN,
-	BOTEVENT_FIREDPLASMA,
-	BOTEVENT_FIREDBFG,
-	BOTEVENT_FIREDBFG10K,
-	BOTEVENT_PLAYER_JOINEDGAME,
-	BOTEVENT_JOINEDGAME,
-	BOTEVENT_DUEL_STARTINGCOUNTDOWN,
-	BOTEVENT_DUEL_FIGHT,
-	BOTEVENT_DUEL_WINSEQUENCE,
-	BOTEVENT_SPECTATING,
-	BOTEVENT_LMS_STARTINGCOUNTDOWN,
-	BOTEVENT_LMS_FIGHT,
-	BOTEVENT_LMS_WINSEQUENCE,
-	BOTEVENT_WEAPONCHANGE,
-	BOTEVENT_ENEMY_BFGEXPLODE,
-	BOTEVENT_PLAYER_BFGEXPLODE,
-	BOTEVENT_BFGEXPLODE,
-	BOTEVENT_RECEIVEDMEDAL,
+	ev_killed_by_enemy,
+	ev_killed_by_player,
+	ev_killed_by_self,
+	ev_killed_by_environment,
+	ev_reached_goal,
+	ev_goal_removed,
+	ev_damaged_by_player,
+	ev_player_say,
+	ev_enemy_killed,
+	ev_respawned,
+	ev_intermission,
+	ev_new_maps,
+	ev_enemy_used_fist,
+	ev_enemy_used_chainsaw,
+	ev_enemy_fired_pistol,
+	ev_enemy_fired_shotgun,
+	ev_enemy_fired_ssg,
+	ev_enemy_fired_chaingun,
+	ev_enemy_fired_minigun,
+	ev_enemy_fired_rocket,
+	ev_enemy_fired_grenade,
+	ev_enemy_fired_railgun,
+	ev_enemy_fired_plasma,
+	ev_enemy_fired_bfg,
+	ev_enemy_fired_bfg10k,
+	ev_player_used_fist,
+	ev_player_used_chainsaw,
+	ev_player_fired_pistol,
+	ev_player_fired_shotgun,
+	ev_player_fired_ssg,
+	ev_player_fired_chaingun,
+	ev_player_fired_minigun,
+	ev_player_fired_rocket,
+	ev_player_fired_grenade,
+	ev_player_fired_railgun,
+	ev_player_fired_plasma,
+	ev_player_fired_bfg,
+	ev_player_fired_bfg10k,
+	ev_used_fist,
+	ev_used_chainsaw,
+	ev_fired_pistol,
+	ev_fired_shotgun,
+	ev_fired_ssg,
+	ev_fired_chaingun,
+	ev_fired_minigun,
+	ev_fired_rocket,
+	ev_fired_grenade,
+	ev_fired_railgun,
+	ev_fired_plasma,
+	ev_fired_bfg,
+	ev_fired_bfg10k,
+	ev_player_joined_game,
+	ev_joined_game,
+	ev_duel_starting_countdown,
+	ev_duel_fight,
+	ev_duel_win_sequence,
+	ev_spectating,
+	ev_lms_starting_countdown,
+	ev_lms_fight,
+	ev_lms_win_sequence,
+	ev_weapon_change,
+	ev_enemy_bfg_explode,
+	ev_player_bfg_explode,
+	ev_bfg_explode,
+	ev_recieved_medal,
 
-	NUM_BOTEVENTS
-
-} BOTEVENT_e;
+	num_bot_events
+};
 
 #endif	// BOTC_BOTS_H

mercurial