Simutrans Programm Version 124.5 r11993
Loading...
Searching...
No Matches
ai_scripted_t Class Reference

Squirrel Script AI. More...

#include <ai_scripted.h>

Inheritance diagram for ai_scripted_t:
Collaboration diagram for ai_scripted_t:

Public Member Functions

 ai_scripted_t (uint8 nr)
 ~ai_scripted_t ()
const char * init (const char *ai_base, const char *ai_name)
const char * reload_script ()
bool has_script () const
uint8 get_ai_id () const OVERRIDE
const char * get_ai_name () const
void step () OVERRIDE
bool new_month () OVERRIDE
void new_year () OVERRIDE
void rdwr (loadsave_t *file) OVERRIDE
void finish_rd () OVERRIDE
Public Member Functions inherited from ai_t
 ai_t (uint8 nr)
bool has_road_transport () const
virtual void set_road_transport (bool yesno)
bool has_rail_transport () const
virtual void set_rail_transport (bool yesno)
bool has_ship_transport () const
virtual void set_ship_transport (bool yesno)
bool has_air_transport () const
virtual void set_air_transport (bool yesno)
sint32 get_construction_speed () const
virtual void set_construction_speed (sint32 newspeed)
void rdwr (loadsave_t *file) OVERRIDE
bool is_connected (const koord star_pos, const koord end_pos, const goods_desc_t *wtyp) const
bool call_general_tool (int tool, koord k, const char *param)
bool suche_platz (koord pos, koord &size, koord *dirs)
bool suche_platz (koord &start, koord &size, koord target, koord off)
void clean_marker (koord place, koord size)
void set_marker (koord place, koord size)
halthandle_t get_halt (const koord haltpos) const
koord find_shore (koord start, koord end) const
bool find_harbour (koord &start, koord &size, koord target)
bool built_update_headquarter ()
bool create_simple_road_transport (koord platz1, koord size1, koord platz2, koord size2, const way_desc_t *road)
Public Member Functions inherited from player_t
void book_convoi_number (int count)
void book_new_vehicle (const sint64 price, const koord k, const waytype_t wt=ignore_wt)
void book_revenue (const sint64 amount, const koord k, const waytype_t wt=ignore_wt, sint32 cathegory=2)
void book_running_costs (const sint64 amount, const waytype_t wt=ignore_wt)
void book_toll_paid (const sint64 amount, const waytype_t wt=ignore_wt)
void book_toll_received (const sint64 amount, waytype_t wt=ignore_wt)
void book_transported (const sint64 amount, const waytype_t wt=ignore_wt, int index=2)
void book_delivered (const sint64 amount, const waytype_t wt=ignore_wt, int index=2)
bool has_money_or_assets () const
bool can_afford (sint64 cost) const
finance_tget_finance () const
virtual bool set_active (bool b)
bool is_active () const
bool is_locked () const
bool is_unlock_pending () const
void unlock (bool unlock_, bool unlock_pending_=false)
void check_unlock (const pwd_hash_t &hash)
pwd_hash_taccess_password_hash ()
void age_messages (uint32 delta_t)
 Age messages (move them upwards).
uint8 get_player_color1 () const
 Handles player colors.
uint8 get_player_color2 () const
void set_player_color (uint8 col1, uint8 col2)
const char * get_name () const
void set_name (const char *)
sint8 get_player_nr () const
bool is_public_service () const
 player_t (uint8 player_nr)
virtual ~player_t ()
sint32 get_scenario_completion () const
void set_scenario_completion (sint32 percent)
double get_account_balance_as_double () const
int get_account_overdrawn () const
void display_messages ()
virtual void rotate90 (const sint16 y_size)
void calc_assets ()
void update_assets (sint64 const delta, const waytype_t wt=ignore_wt)
virtual void report_vehicle_problem (convoihandle_t cnv, const koord3d position)
void tell_tool_result (tool_t *tool, koord3d pos, const char *err)
virtual void notify_factory (notification_factory_t, const fabrik_t *)
void init_undo (waytype_t t, unsigned short max)
void add_undo (koord3d k)
sint64 undo ()
void add_headquarter (short hq_level, koord hq_pos)
koord get_headquarter_pos () const
short get_headquarter_level () const
void ai_bankrupt ()

Private Member Functions

bool load_script (const char *filename)

Private Attributes

plainstring ai_name
plainstring ai_path
script_vm_tscript
 pointer to virtual machine

Additional Inherited Members

Public Types inherited from player_t
enum  {
  EMPTY = 0 , HUMAN = 1 , AI_GOODS = 2 , AI_PASSENGER = 3 ,
  AI_SCRIPTED = 4 , MAX_AI , PASSWORD_PROTECTED = 128
}
enum  notification_factory_t { notify_delete }
Static Public Member Functions inherited from ai_t
static const vehicle_desc_tvehicle_search (waytype_t typ, const uint32 target_power, const sint32 target_speed, const goods_desc_t *target_freight, bool include_electric)
 helper method to call vehicle_builder_t::vehicle_search and fill in time-line related parameters
Static Public Member Functions inherited from player_t
static void book_construction_costs (player_t *const player, const sint64 amount, const koord k, const waytype_t wt=ignore_wt)
static bool check_owner (const player_t *owner, const player_t *test)
static sint64 add_maintenance (player_t *player, sint64 const change, waytype_t const wt=ignore_wt)
Public Attributes inherited from player_t
simlinemgmt_t simlinemgmt
Protected Member Functions inherited from player_t
void add_message (sint64 amount, koord k)
void add_money_message (sint64 amount, koord k)
sint64 add_maintenance (sint64 change, waytype_t const wt=ignore_wt)
Protected Attributes inherited from ai_t
bool road_transport
bool rail_transport
bool ship_transport
bool air_transport
sint32 construction_speed
Protected Attributes inherited from player_t
char player_name_buf [256]
finance_tfinance
uint16 player_age
slist_tpl< income_message_t * > messages
uint8 player_color_1
uint8 player_color_2
uint8 player_nr
bool active
bool locked
bool unlock_pending
pwd_hash_t pwd_hash
Static Protected Attributes inherited from player_t
static karte_ptr_t welt

Detailed Description

Squirrel Script AI.

Definition at line 16 of file ai_scripted.h.

Constructor & Destructor Documentation

◆ ai_scripted_t()

ai_scripted_t::ai_scripted_t ( uint8 nr)

Definition at line 21 of file ai_scripted.cc.

Here is the call graph for this function:

◆ ~ai_scripted_t()

ai_scripted_t::~ai_scripted_t ( )

Definition at line 27 of file ai_scripted.cc.

Member Function Documentation

◆ finish_rd()

void ai_scripted_t::finish_rd ( )
virtual

Called after game is fully loaded;

Reimplemented from player_t.

Definition at line 305 of file ai_scripted.cc.

Here is the call graph for this function:

◆ get_ai_id()

uint8 ai_scripted_t::get_ai_id ( ) const
inlinevirtual

Reimplemented from player_t.

Definition at line 53 of file ai_scripted.h.

◆ get_ai_name()

const char * ai_scripted_t::get_ai_name ( ) const
inline

Definition at line 55 of file ai_scripted.h.

◆ has_script()

bool ai_scripted_t::has_script ( ) const
inline

Definition at line 51 of file ai_scripted.h.

Here is the caller graph for this function:

◆ init()

const char * ai_scripted_t::init ( const char * ai_base,
const char * ai_name )

Initializes scripted ai

Definition at line 33 of file ai_scripted.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_script()

bool ai_scripted_t::load_script ( const char * filename)
private

loads ai file with the given name

Parameters
filenamename ai script file (including .nut extension)

Definition at line 79 of file ai_scripted.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ new_month()

bool ai_scripted_t::new_month ( )
virtual

Called monthly by simworld.cc during simulation

Returns
false if player has to be removed (bankrupt/inactive)

Reimplemented from player_t.

Definition at line 147 of file ai_scripted.cc.

Here is the call graph for this function:

◆ new_year()

void ai_scripted_t::new_year ( )
virtual

Called yearly by simworld.cc during simulation

Reimplemented from player_t.

Definition at line 156 of file ai_scripted.cc.

Here is the call graph for this function:

◆ rdwr()

void ai_scripted_t::rdwr ( loadsave_t * file)
virtual

Stores/loads the player state

Parameters
filewhere the data will be saved/loaded

Reimplemented from player_t.

Definition at line 221 of file ai_scripted.cc.

Here is the call graph for this function:

◆ reload_script()

const char * ai_scripted_t::reload_script ( )

Reloads script

Returns
error message

Definition at line 102 of file ai_scripted.cc.

Here is the call graph for this function:

◆ step()

void ai_scripted_t::step ( )
virtual

Called often by simworld.cc during simulation

Note
Any action goes here (only need for AI at the moment)

Reimplemented from player_t.

Definition at line 136 of file ai_scripted.cc.

Member Data Documentation

◆ ai_name

plainstring ai_scripted_t::ai_name
private

name of ai, files are searched in ai/ai_name/... e.g. my_ai

Definition at line 20 of file ai_scripted.h.

◆ ai_path

plainstring ai_scripted_t::ai_path
private

path to ai directory (relative to env_t::user_dir) e.g. ai/my_ai/

Definition at line 24 of file ai_scripted.h.

◆ script

script_vm_t* ai_scripted_t::script
private

pointer to virtual machine

Definition at line 33 of file ai_scripted.h.


The documentation for this class was generated from the following files: