Your content here
The Big Heist
obj_test with switch statment in Step and ready_up[]
Scotland yard
obj_test with switch statment in Step and ready_up[]
Batesville on The Go
Tax Game
Tower Game
Tank Game
obj_test with switch statment in Step and ready_up[]
Dust Fire and Ice (Phabbits2 branch)
Test Scripts
Create Event
tests = ds_list_create()
//ds_list_add(tests, new stc_test_multiplayer(false))
//obj_menu.main_player_controller = 1
//ds_list_add(tests, new stc_test_singleplayer(false, true))
//s_list_add(tests, new stc_test_tutorial())
Step Event
for (var i=0; i<ds_list_size(tests); i++){
tests[| i].step()
}
scr_tests
function find_and_click_button(action) {
// Find the correct button
for (var i=0; i<ds_list_size(obj_menu.Buttons); i++){
if action == STATE_OPTIONS and obj_menu.Buttons[| i].title = "options" {
with obj_menu.Buttons[| i] {
event_user(0)
}
}
if action == STATE_CONTROLS and obj_menu.Buttons[| i].title = "controls" {
with obj_menu.Buttons[| i] {
event_user(0)
}
}
}
}
function stc_test() constructor {
step = function(){
}
}
function stc_test_multiplayer(stop_at_game) : stc_test() constructor {
ready_up[0] = false
ready_up[1] = false
ready_up[2] = false
ready_up[3] = false
ready_up[4] = stop_at_game
step = function(){
switch obj_menu.state{
case STATE_MAIN:
if not ready_up[0]{
find_and_click_button(STATE_ONLINE)
ready_up[0] = true
}
break
case STATE_ONLINE:
if not ready_up[1]{
// Host
with obj_online event_user(1)
ready_up[1] = true
}
break
case STATE_LOBBY:
// Wait for client to complete connection
if obj_client.network_state == NETWORK_LOBBY and not ready_up[2]{
// Ready up
var connect_ids = ds_map_keys_to_array(obj_campaign.Authoritative_players)
for (var i=0; i<array_length(connect_ids); i++) {
// obj_authoritative_player instances
var Authoritative_player = obj_campaign.Authoritative_players[? connect_ids[i]]
Authoritative_player.ready_to_start = true
}
ready_up[2] = true
}
break
case STATE_GAMECONFIG:
if not ready_up[3]{
// Path menu uses one player readying up to continue
client_send_input(obj_client.connect_id, READY_UP, -1, -1)
ready_up[3] = true
}
break
case STATE_GAME:
// Wait for client to complete connection
if not ready_up[4]{
// Ready up
var connect_ids = ds_map_keys_to_array(obj_campaign.Authoritative_players)
for (var i=0; i<array_length(connect_ids); i++) {
// obj_authoritative_player instances
var Authoritative_player = obj_campaign.Authoritative_players[? connect_ids[i]]
Authoritative_player.ready_to_start = true
}
ready_up[4] = true
}
break
}
}
}
function stc_test_singleplayer(stop_at_path_menu, stop_at_game) : stc_test() constructor {
ready_up[0] = false
ready_up[1] = false
ready_up[2] = false
ready_up[3] = stop_at_path_menu
ready_up[4] = stop_at_game
step = function(){
switch obj_menu.state{
case STATE_MAIN:
if not ready_up[0]{
find_and_click_button(STATE_LOBBY)
ready_up[0] = true
}
break
case STATE_LOBBY:
// Ready up
for(var i = 0; i < ds_list_size(obj_lobby.active_connect_ids); i++) {
// obj_local_player instances
var Local_player = obj_lobby.Local_players[? obj_lobby.active_connect_ids[| i]]
Local_player.Player.ready_to_start = true
}
ready_up[2] = true
break
case STATE_GAMECONFIG:
if not ready_up[3]{
find_and_click_button(STATE_GAME)
ready_up[3] = true
}
break
case STATE_GAME:
if not ready_up[4]{
with obj_character instance_destroy()
ready_up[4] = true
}
break
}
}
}
function stc_test_tutorial() : stc_test() constructor {
global.tutorial = true
ds_list_add(obj_test.tests, new stc_test_singleplayer(false, true))
}
function stc_test_options() : stc_test() constructor {
ready_up[0] = false
ready_up[1] = false
step = function(){
switch obj_menu.state{
case STATE_MAIN:
if not ready_up[0]{
find_and_click_button(STATE_OPTIONS)
ready_up[0] = true
}
break
case STATE_OPTIONS:
if not ready_up[1]{
find_and_click_button(STATE_CONTROLS)
ready_up[1] = true
}
break
}
}
}
function stc_test_win() : stc_test() constructor {
// Inform clients game is starting
var connected_client_count = ds_list_size(obj_server.active_connect_ids)
for (var i=0; i<connected_client_count; i++){
// obj_connected_client
var Connected_client = ds_map_find_value(obj_server.Connected_clients, obj_server.active_connect_ids[| i])
// Actual game start message is handled in obj_server
ds_queue_enqueue(Connected_client.messages_out, SERVER_STATESWITCH)
}
step = function(){
}
}
function stc_test_camera() : stc_test() constructor {
var Character = noone
if global.online
Character = obj_campaign.Authoritative_players[? obj_client.connect_id].Character
else
Character = instance_find(obj_local_player, 0).Player.Character
// Move character halfway up
Character.y = room_height/4
Character.x = room_width/2
// Ensure charact is not stuck
with Character {
while not place_free(x, y) {
y -= 1
}
}
turn_to_pirahna_timer = game_get_speed(gamespeed_fps)*5
step = function(){
if turn_to_pirahna_timer > 0 {
turn_to_pirahna_timer--
if turn_to_pirahna_timer == 0 {
ds_list_add(obj_test.tests, new stc_test_pirahna())
}
}
}
}
function stc_test_pirahna() : stc_test() constructor {
var Character = noone
if global.online
Character = obj_campaign.Authoritative_players[? obj_client.connect_id].Character
else
Character = instance_find(obj_local_player, 0).Player.Character
// Kill character to create pirahna
// obj_character will complete interaction die
// Which destroys the character
// Which sends a ready up message to the server
Character.hp = 0
obj_test.debug_do_not_ready_on_death = true
// Raise water to allow pirahna to swim
obj_control.water_height = room_height/2
step = function(){
}
}