Skip to content

Commit

Permalink
flesh out variables
Browse files Browse the repository at this point in the history
  • Loading branch information
OH296 committed Jan 20, 2025
1 parent 8110568 commit f578627
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 61 deletions.
12 changes: 9 additions & 3 deletions objects/obj_controller/Alarm_1.gml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ var xx,yy,ok=0,did=0,_current_system=0,px=0,py=0,rando=0;
_current_system = find_player_spawn_star();

instance_activate_object(obj_star);

var _player_star;
// Set player homeworld
did = instance_exists(_current_system);
if (did){

_player_star = _current_system.id;
if (obj_ini.fleet_type==ePlayerBase.home_world){
set_player_homeworld_star(_current_system);
}
Expand Down Expand Up @@ -83,6 +83,12 @@ if (did){
yy = py;
instance_activate_object(obj_star);
instance_deactivate_object(_current_system);
with (obj_star){
if (system_feature_bool(p_feature, P_features.Recruiting_World)){
instance_deactivate_object(id);
break;
}
}

_current_system=instance_nearest(px,py,obj_star);
_current_system.star="white2";
Expand Down Expand Up @@ -527,7 +533,7 @@ with(obj_creation){
}


create_complex_star_routes();
create_complex_star_routes(_player_star.id);

/* //135 testing crusade object
instance_create(x,y,obj_crusade);
Expand Down
4 changes: 2 additions & 2 deletions objects/obj_creation/Draw_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -636,10 +636,10 @@ try {
draw_set_alpha(1);
}
draw_sprite(spr_creation_arrow, 4, 927 + 64, 761);
if ((popup == "") && ((change_slide >= 70) || (change_slide <= 0)) && (cooldown <= 0) && (mouse_left >= 1)) {
if ((popup == "") && ((change_slide >= 70) || (change_slide <= 0)) && (cooldown <= 0) && (scr_click_left())) {
if (scr_hit(927 + 64 + 12, 761 + 12, 927 + 128 - 12, 761 + 64 - 12)) {
scr_creation(2);
scr_creation(3.5);
scr_creation(3);
scr_creation(4);
scr_creation(5);
scr_creation(6);
Expand Down
2 changes: 1 addition & 1 deletion objects/obj_creation/Step_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if (slide==1){
chapter_string=chapter_name;
}
scr_creation(2);
scr_creation(3.5);
scr_creation(3);
scr_creation(4);
scr_creation(5);
scr_creation(6);
Expand Down
4 changes: 2 additions & 2 deletions scripts/scr_creation/scr_creation.gml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ function scr_creation(slide_num) {
}


if (floor(slide_num)==3 && (recruiting_name!=homeworld_name || custom == 0)){
if (slide_num==3 ){
change_slide=1;
goto_slide=4;
cooldown=8000;
alarm[0]=1;

if (slide_num=3.5){
if (slide_num=3){


if (full_liveries == ""){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ function player_recruit_planet_selection(){

if (_recruit_world_type<2){
recruiting_name = homeworld_name;
} else if (_recruit_world_type==2){
if (recruiting_name == homeworld_name){
recruiting_name = global.name_generator.generate_star_name();
}
}
if (fleet_type=1 && _recruit_world_type<2) and (homeworld_name=recruiting_name) then name_bad=1;
//TODO make a centralised logic for player renaming things in the creation screen
Expand Down
5 changes: 4 additions & 1 deletion scripts/scr_initialize_custom/scr_initialize_custom.gml
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,11 @@ function scr_initialize_custom() {
progenitor = obj_creation.founding;
successors = obj_creation.successors;
homeworld_rule = obj_creation.homeworld_rule;

homeworld_relative_loc = obj_creation.buttons.home_spawn_loc_options.current_selection;
recruit_relative_loc = obj_creation.buttons.home_spawn_loc_options.current_selection;
home_warp_position = obj_creation.buttons.home_warp.current_selection;
home_planet_count = obj_creation.buttons.home_planets.current_selection;
recruit_relative_loc = obj_creation.buttons.recruit_home_relationship.current_selection;


if(struct_exists(obj_creation, "custom_advisors")){
Expand Down
75 changes: 75 additions & 0 deletions scripts/scr_map_and_warp_functions/scr_map_and_warp_functions.gml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,81 @@ function draw_warp_lanes(){
}
}

function create_complex_star_routes(player_star){
var north=[], east=[], west=[], south=[], central=[];
with (obj_star){
if (id == player_star){
if (obj_ini.home_warp_position==0){//isolated environment
instance_deactivate_object(id);
continue;
}
}
if (x<700) then array_push(west, id);
if (y<700) then array_push(north, id);
if (x>room_width-700) then array_push(east, id);
if (y>room_height-700) then array_push(south, id);
if (x>700) && (y>700) && (x<room_width-700) && (x<room_width-700){
array_push(central, id);
}

var nearest_star = distance_removed_star(x,y,1,true,true,false);
if (determine_warp_join(nearest_star.id, self.id)){
array_push(warp_lanes, [distance_removed_star(x,y,2,true,true,false).name, 1]);
} else {
array_push(warp_lanes, [nearest_star.name, 1]);
}

if (!irandom(8) || (id == player_star && obj_ini.home_warp_position==2)){
array_push(warp_lanes, [distance_removed_star(x,y,irandom_range(3, 6),true,true,false).name, 1]);
}
}
full_loci = [north, east,west,south,central];
// here is where we set up the warp hubs
var WarpHub,set, join_set, total_joins;
for (var i=0;i<array_length(full_loci);i++){
var player_hub_overide = false;
if (irandom(1)){
if (obj_ini.home_warp_position!=2){
continue;
} else {
if (!array_contains(full_loci[i], player_star)){
continue;
} else {
player_hub_overide = true;
}
}

}
set = full_loci[i];
if (array_length(set) == 0) then continue;
if (player_hub_overide){
for (var i=0;i<array_length(set);i++){
if (set[i] == player_star){
WarpHub = set[i];
break;
}
}
} else {
WarpHub = array_random_element(set);
}
total_joins =0;
for (var s=0;s<array_length(full_loci);s++){
if (!irandom(1)) then continue;
join_set = full_loci[s];
var set_count = array_length(join_set);
if (s==i || set_count == 0)then continue;
/*//if (irandom(1)) then continue;
for (var i=0;i<array_length(full_loci[s])i++){
//if !(irandom(2)) then
}*/
join_star = array_random_element(join_set);
array_push(WarpHub.warp_lanes, [join_star.name, 4]);
total_joins++;
if (total_joins>3) then break;
}
}
}

function set_map_pan_to_loc(target){
with(obj_controller){
location_viewer.travel_target = [target.x, target.y];
Expand Down
48 changes: 0 additions & 48 deletions scripts/scr_star_travel_algorithm/scr_star_travel_algorithm.gml
Original file line number Diff line number Diff line change
Expand Up @@ -94,54 +94,6 @@ function star_distace_calc(star1,star2){
return point_distance(star1.x, star1.y, star2.x, star2.y);
}

function create_complex_star_routes(){
var north=[], east=[], west=[], south=[], central=[];
with (obj_star){
if (x<700) then array_push(west, id);
if (y<700) then array_push(north, id);
if (x>room_width-700) then array_push(east, id);
if (y>room_height-700) then array_push(south, id);
if (x>700) && (y>700) && (x<room_width-700) && (x<room_width-700){
array_push(central, id);
}

var nearest_star = distance_removed_star(x,y,1,true,true,false);
if (determine_warp_join(nearest_star.id, self.id)){
array_push(warp_lanes, [distance_removed_star(x,y,2,true,true,false).name, 1]);
} else {
array_push(warp_lanes, [nearest_star.name, 1]);
}

if (!irandom(8)){
array_push(warp_lanes, [distance_removed_star(x,y,irandom_range(3, 6),true,true,false).name, 1]);
}
}
full_loci = [north, east,west,south,central];
// here is where we set up the warp hubs
var WarpHub,set, join_set, total_joins;
for (var i=0;i<array_length(full_loci);i++){
if (irandom(1)) then continue;
set = full_loci[i];
if (array_length(set) == 0) then continue;
WarpHub = set[irandom(array_length(set)-1)];
total_joins =0;
for (var s=0;s<array_length(full_loci);s++){
if (!irandom(1)) then continue;
join_set = full_loci[s];
var set_count = array_length(join_set);
if (s==i || set_count == 0)then continue;
/*//if (irandom(1)) then continue;
for (var i=0;i<array_length(full_loci[s])i++){
//if !(irandom(2)) then
}*/
join_star = join_set[irandom(set_count-1)];
array_push(WarpHub.warp_lanes, [join_star.name, 4]);
total_joins++;
if (total_joins>3) then break;
}
}
}



function determine_warp_join(star_a, star_b){
Expand Down
23 changes: 19 additions & 4 deletions scripts/scr_system_spawn_functions/scr_system_spawn_functions.gml
Original file line number Diff line number Diff line change
Expand Up @@ -101,28 +101,43 @@ function set_player_recruit_planet(recruit_planet){

function set_player_homeworld_star(chosen_star){
with (chosen_star){
planets = irandom_range(2,4);
planets = obj_ini.home_planet_count;
var _home_star = irandom_range(1,planets);

player_home_star(_home_star);


if (obj_ini.recruit_relative_loc==1){
var _possible_planets = [];
var _planet_types = ARR_planet_types;
for (var i=1;i<=planets;i++){
if (i!=_home_star){
array_push(_possible_planets, i);
p_type[i] = array_random_element(_planet_types);
}
var _recruit_star = array_random_element(_possible_planets)
set_player_recruit_planet(_recruit_star);

}
} else if (obj_ini.recruit_relative_loc==0){
array_push(p_feature[_home_star], new NewPlanetFeature(P_features.Recruiting_World));//recruiting world
for (var i=1;i<=planets;i++){
if (i!=_home_star){
p_type[i] = array_random_element(_planet_types);
}
}
if (global.chapter_name!="Lamenters") then obj_controller.recruiting_worlds+=string(name)+" II|";
} else if (obj_ini.recruit_relative_loc==2){

create_recruit_system(distance_removed_star(chosen_star.x, chosen_star.y));
}

}
}
}

function create_recruit_system(star){
with (star){
var _recruit_planet = irandom_range(1,planets);
set_player_recruit_planet(_recruit_planet);
}

}

0 comments on commit f578627

Please sign in to comment.