DI-Guy Lua AI SDK
 All Classes Files Functions Variables Groups Pages
luaUrbanCivilian Class Reference

The base class for an urban civilian. More...

Inheritance diagram for luaUrbanCivilian:
luaUrbanEntity luaCharacter

Public Member Functions

 init_package ()
 Standard init_package function. Establishes some values used by all instances. More...
 
 serialize_instance ()
 
 reset ()
 Standard reset function. More...
 
 init ()
 Initialize the urban civilian at time 0. More...
 
 draw ()
 Draw debugging graphics. More...
 
 heartbeat ()
 Standard heartbeat function. More...
 
 process_core_messages (message_object)
 Key message-handler. More...
 
 entry_point ()
 Base state of the urban civilian mind. More...
 
 idle_state ()
 State function for standing around doing nothing. Not really used right now. More...
 
 choose_point_state ()
 State for the user giving a move order to the character. Not currently used. More...
 
 goto_food_state ()
 State for going to a location that provides food. More...
 
 goto_food_stand_state (food_stand)
 State for going to a food stand (not a food building) More...
 
 goto_food_building_state (food_building)
 State for going into a food building (not stand) More...
 
 goto_home_state ()
 State for going into the building assigned as my home and staying a while. More...
 
 goto_store_state ()
 State for going into a store building. More...
 
 goto_church_state ()
 State for going into a church and staying for a while. More...
 
 in_building_state (use_time)
 State for being inside a building. More...
 
 process_messages_panic (message_object)
 Event processor tied to panic_state. More...
 
 panic_state ()
 State function for runnning away from a frightening event, such as an explosion. More...
 
 curiosity_state ()
 State function for being curious about a frightening event. More...
 
 altruism_state (dest_vec)
 State for helping the injured near the site of a frightening event, such as an explosion. More...
 
 think_state ()
 State for stopping to think, while walking along. More...
 
 process_talk_messages (message_object)
 Process messages related to having a conversation. More...
 
 talk_state (sender, am_initiator)
 State for having a conversation. More...
 
 process_walk_messages (message_object)
 Event processor tied to goto_point_state. More...
 
 process_walk_messages_simple (message_object)
 A pared-down version of process_walk_messages() More...
 
 goto_point_state (dest_vec, approach_to_dist, allow_interruptions)
 State for going from one point to another, with other behaviors. More...
 
 wait_for_light_state (dest_vec)
 State function called when character is waiting for light to change, in order to enter crosswalk. More...
 
 get_out_of_street_state ()
 State for escaping from street (to avoid traffic) More...
 
 first_update ()
 
 get_ui_signals ()
 
 show_speech_balloon (text)
 Display a speech balloon above character. More...
 
 show_thought_balloon (text)
 Display a speech balloon above character. More...
 
 debug_thought_balloon (text)
 
 hide_thought_balloon ()
 
 die_now ()
 Causes character to die. More...
 
 choose_next_action (short_term)
 Selects the next action. More...
 
 set_normal_walk_parameters ()
 As opposed to flee. More...
 
 mark_goal_satisfied (name)
 Brings a goal's current value back below minimum threshold, indicating that it's been satisfied. More...
 
 set_panic_goal ()
 Sets the need to panic. All other needs will be inhibited. More...
 
 set_curiosity_goal ()
 Sets the need to be curious about a frightening event. More...
 
 set_church_goal ()
 Sets the need to go to church. More...
 
 restore_normal_goals ()
 
 get_crossing_street (test_pos)
 Used to figure out if character is at/near street crossing. More...
 
 get_about_to_enter_street ()
 Determines if character is about to enter street. More...
 
 test_intersection_safe (dest_vec, allow_yellow)
 Determines if the closest intersection is safe to enter. More...
 
 set_current_speed (setting)
 Sets the character's travel speed. Current options are fast (running) or normal. More...
 
- Public Member Functions inherited from luaUrbanEntity
 begin_state (_state_name)
 Designate a state as having been entered. More...
 
 invoke_state (state_obj, _message_handler)
 Enter a child state. More...
 
 sleep_process_messages (duration, msg_handler)
 Puts the active coroutine to sleep for the number of seconds specified. More...
 
 send_message_up_state_chain (message)
 Chained message handler communication function. More...
 
 check_higher_state_interruption ()
 Checks if a higher state requests an interruption. More...
 
 pop_stored_message_response ()
 Retrieves message response from chained event handlers. More...
 
 mark_state_interruption (_interrupt)
 For use by chained message processors. More...
 
- Public Member Functions inherited from luaCharacter
 get_ui_signals ()
 This function returns a comma separated list of signals that the agent is currently willing to accept. More...
 
 get_ui_state_label ()
 This function returns a string that the DI-Guy Scenario UI will add onto the end of the state name label. More...
 
 one_time_init ()
 This function is called when a mind is first created, currently no ops. More...
 
 init (arg0, arg1, arg2)
 This function is called at t=0 or when a mind is created, currently no ops. More...
 
 reset ()
 This function resets the luaCharacter representation, called by c++ on scenario reset. More...
 
 destroy ()
 This function is called by C++ when the character is destroyed. Overload it to trigger any world cleanup on destruction. More...
 
 die_now ()
 This function is called when the character is killed. Overload it to trigger any final events or agent clean up on death. More...
 
 draw ()
 This function is called by diguy scenario to draw a lua object Overload it to create your own Drawing behavior. More...
 
 entry_point ()
 This function is called by the state manager as the entry point into the lua state machine. Overload it to create your own HFSM. More...
 
 send_message_to_character (to, from, msg_type, message, params)
 Send a message from a character to a character, will automatically send message over network. More...
 
 state_manager (sender, message_type, message, params)
 This is the main entry point from C++ into the lua framework. More...
 
 sleep (duration)
 
 sleep_until (wake_time)
 
 sleep_ignore_messages (duration)
 This is a simple sleep function, it will put the character to sleep for the duration specified. Messages will not be processed. More...
 
 sleep_process_messages (duration, message_handler)
 This is a sleep function that can take a message_handler function. More...
 
 wait_for_message (message_to_wait_for, message_handler, bg_check_func, bg_freq)
 This is a sleep function that will wait a long time and only wake up when a specific message is recieved. More...
 
 wait_for_multichoice (...)
 This is a sleep function that will wait a long time and only wake up when one of a few specific messages are recieved. More...
 
 internal_get_user_selected (options)
 Internal support function used by other picking functions. More...
 
 get_user_selected_point (_options)
 Function returns a point in the world, picked via the UI. More...
 
 get_user_selected_character (_options)
 Function returns a character in the world, picked via the ui. More...
 
 simple_move_to_state (x, y, z, message_handler, bg_check_func, bg_check_freq, force_a_star)
 This function implements a simple move to state. More...
 
 simple_move_to_path_state (path, message_handler, bg_check_func, bg_check_freq, force_a_star)
 
 get_state_name (state_function, object)
 Convenience function for printing the name of a state, given a function_pointer. More...
 
 begin_state (_name)
 Convenience function for storing the current state in the luaCharacter. More...
 
 get_current_and_previous_states ()
 Convenience function for debugging. Returns comma-separated list of recent states. More...
 
 is_new_state (ret)
 Convenience function for checking if the argument is a new state table. More...
 
 invoke_state (new_state, cleanup_function, extra_info)
 Convenience function for doing a tail call function invokation. More...
 
 draw_path ()
 Function that draws the character's current path object. More...
 
 draw_line_from_self ()
 Function draws a line from self to the point under the mouse, plus it either a circle under the mouse point. More...
 
 get_user_selected_path (message, use_default_ui_draw_function)
 Function returns a string and a path clicked in the world, picked via the UI. More...
 
 scheduler_heartbeat ()
 Experimental - heartbeat function for the post event sceduler. More...
 
 add_scheduled_event (callback_data)
 Experimental - adds a function to happen in the future. More...
 
 update_scheduler ()
 
 process_messages_enroute (message_obj)
 

Public Attributes

string impact_callback_dispatcher =
 
 SPEED_NORMAL = 0
 
 SPEED_FAST = 1
 
 ALLOW_WALK_STATE_INTERRUPTIONS = true
 
 SHORT_TERM_ACTION = true
 
- Public Attributes inherited from luaUrbanEntity
local goto_result = self->invoke_state({state=self.goto_point_state, arg1=dest_vec, arg2=approach_dist})
 
- Public Attributes inherited from luaCharacter
userdata character
 a pointer to the underlying character; More...
 
coroutine state_coroutine
 a microthread that holds the current state of the VM; More...
 
 MESSAGE_HANDLED = -1
 
 init_code =
 Constructor Template String. More...
 
local character = this_scenario->find_character("CHARACTER_NAME")
 
 DERIVED_CLASS = BASE_CLASS->new(character)
 

Detailed Description

The base class for an urban civilian.

Currently used in the Urban Traffic scenario. This character implements several behaviors, such as going to stores, food shops, churches, or home, socializing with other characters, or reacting to events in the world.

Urban civilians are also fairly smart about HOW they get from place to place. They prefer to stay on sidewalks and to only cross the street at crosswalks, when the light is going their way.

Member Function Documentation

luaUrbanCivilian::altruism_state ( dest_vec  )

State for helping the injured near the site of a frightening event, such as an explosion.

luaUrbanCivilian::choose_next_action ( short_term  )

Selects the next action.

Called to choose next behavior, based on current values in goal table and settings in behavior table

Parameters
short_termif true, a behavior flagged as short-term will be selected. Otherwise, a regular (non-short-term) one will be.
luaUrbanCivilian::choose_point_state ( )

State for the user giving a move order to the character. Not currently used.

luaUrbanCivilian::curiosity_state ( )

State function for being curious about a frightening event.

Characters will approach to a certain distance of the event. Some may come in closer and try to help.

luaUrbanCivilian::debug_thought_balloon ( text  )
luaUrbanCivilian::die_now ( )

Causes character to die.

luaUrbanCivilian::draw ( )

Draw debugging graphics.

luaUrbanCivilian::entry_point ( )

Base state of the urban civilian mind.

Carries out behavior-choosing logic (based on values in goals table), then dispatches control to various child states that implement chosen behaviors

luaUrbanCivilian::first_update ( )
luaUrbanCivilian::get_about_to_enter_street ( )

Determines if character is about to enter street.

Based on waypoints of path currently being followed

Returns
first
second
luaUrbanCivilian::get_crossing_street ( test_pos  )

Used to figure out if character is at/near street crossing.

Determines if given point is in a crosswalk. If point not given, uses character pos.

Parameters
test_posa Vec3
Returns
first
second
luaUrbanCivilian::get_out_of_street_state ( )

State for escaping from street (to avoid traffic)

luaUrbanCivilian::get_ui_signals ( )
luaUrbanCivilian::goto_church_state ( )

State for going into a church and staying for a while.

luaUrbanCivilian::goto_food_building_state ( food_building  )

State for going into a food building (not stand)

luaUrbanCivilian::goto_food_stand_state ( food_stand  )

State for going to a food stand (not a food building)

luaUrbanCivilian::goto_food_state ( )

State for going to a location that provides food.

Might be a food stand or a building that has food inside (represented by a luaUrbanSite mind)

luaUrbanCivilian::goto_home_state ( )

State for going into the building assigned as my home and staying a while.

luaUrbanCivilian::goto_point_state ( dest_vec  ,
approach_to_dist  ,
allow_interruptions   
)

State for going from one point to another, with other behaviors.

One of the central state functions of this particular mind. Sends the character from where he/she is now to the destination specified. Along the way, the character may respond to the traffic management system, or to other events in the world. Notice how this is done by varying the message processor.

Parameters
dest_vecVec3 containing destination position
approach_distHow close character needs to get to be "there"
allow_interruptionsIf true, the character can be interrupted by traffic, desire to think, conversation, and other events. If false, character will simply go straight there, ignoring events around him/her.
luaUrbanCivilian::goto_store_state ( )

State for going into a store building.

luaUrbanCivilian::heartbeat ( )

Standard heartbeat function.

Updates current action choices

luaUrbanCivilian::hide_thought_balloon ( )
luaUrbanCivilian::idle_state ( )

State function for standing around doing nothing. Not really used right now.

luaUrbanCivilian::in_building_state ( use_time  )

State for being inside a building.

That is, for being at the luaUrbanSite character that has been placed inside a building

luaUrbanCivilian::init ( )

Initialize the urban civilian at time 0.

luaUrbanCivilian::init_package ( )

Standard init_package function. Establishes some values used by all instances.

luaUrbanCivilian::mark_goal_satisfied ( name  )

Brings a goal's current value back below minimum threshold, indicating that it's been satisfied.

luaUrbanCivilian::panic_state ( )

State function for runnning away from a frightening event, such as an explosion.

luaUrbanCivilian::process_core_messages ( message_object  )

Key message-handler.

Event processor tied to entry_point state. Functions as a chained message processor.

luaUrbanCivilian::process_messages_panic ( message_object  )

Event processor tied to panic_state.

Functions as a chained message processor.

luaUrbanCivilian::process_talk_messages ( message_object  )

Process messages related to having a conversation.

luaUrbanCivilian::process_walk_messages ( message_object  )

Event processor tied to goto_point_state.

Functions as a chained message processor.

luaUrbanCivilian::process_walk_messages_simple ( message_object  )

A pared-down version of process_walk_messages()

Similar to process_walk_messages, but for when we don't want the character to be interrupted by conversation, thinking, or traffic light.

luaUrbanCivilian::reset ( )

Standard reset function.

luaUrbanCivilian::restore_normal_goals ( )
luaUrbanCivilian::serialize_instance ( )
luaUrbanCivilian::set_church_goal ( )

Sets the need to go to church.

luaUrbanCivilian::set_curiosity_goal ( )

Sets the need to be curious about a frightening event.

luaUrbanCivilian::set_current_speed ( setting  )

Sets the character's travel speed. Current options are fast (running) or normal.

luaUrbanCivilian::set_normal_walk_parameters ( )

As opposed to flee.

luaUrbanCivilian::set_panic_goal ( )

Sets the need to panic. All other needs will be inhibited.

luaUrbanCivilian::show_speech_balloon ( text  )

Display a speech balloon above character.

luaUrbanCivilian::show_thought_balloon ( text  )

Display a speech balloon above character.

luaUrbanCivilian::talk_state ( sender  ,
am_initiator   
)

State for having a conversation.

This state may be called within a higher state, such as going to the store

Parameters
sendername of the other character in the conversation
am_initiatortrue if I'm the one who started the conversation
luaUrbanCivilian::test_intersection_safe ( dest_vec  ,
allow_yellow   
)

Determines if the closest intersection is safe to enter.

Parameters
dest_vecis a near-future destination on my path
allow_yellowmeans we treat yellow lights as safe
Returns
first
second
third
luaUrbanCivilian::think_state ( )

State for stopping to think, while walking along.

This state may be called within a higher state, such as going to the store.

luaUrbanCivilian::wait_for_light_state ( dest_vec  )

State function called when character is waiting for light to change, in order to enter crosswalk.

Parameters
dest_vecmy next waypoint

Member Data Documentation

luaUrbanCivilian::ALLOW_WALK_STATE_INTERRUPTIONS = true
string luaUrbanCivilian::impact_callback_dispatcher =
luaUrbanCivilian::SHORT_TERM_ACTION = true
luaUrbanCivilian::SPEED_FAST = 1
luaUrbanCivilian::SPEED_NORMAL = 0

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