Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Player ship class and arrays #406

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions scripts/scr_ini_ship_cleanup/scr_ini_ship_cleanup.gml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,25 @@ function scr_kill_ship(index){
for (var co=0;co<=companies;co++){
for (var i=0;i<array_length(name[co]);i++){
_unit = fetch_unit([co,i]);
if (_unit.ship_location == index){
if (!irandom(_unit.luck)-3){
scr_kill_unit(_unit.company, _unit.marine_number);
if (_unit.ship_location>-1){
if (_unit.ship_location == index){
if (!(irandom(_unit.luck)-3)){
scr_kill_unit(_unit.company, _unit.marine_number);
} else {
array_push(_units_on_ship, _unit);
}
} else {
array_push(_units_on_ship, _unit);
if (_unit.ship_location>index){
_unit.ship_location--;
}
}
}
}
for (var i=0;i<array_length(veh_role);i++){
for (var i=0;i<array_length(veh_role[co]);i++){
if (veh_lid[co][i]==index){
reset_vehicle_variable_arrays(co, i);
} else if (veh_lid[co][i]>index){
veh_lid[co][i]--;
}
}
}
Expand Down
19 changes: 13 additions & 6 deletions scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ function find_and_move_ship_between_fleets(out_fleet, in_fleet, index){
function merge_player_fleets(main_fleet, merge_fleet){
var _merge_ships = fleet_full_ship_array(merge_fleet);
for (var i=0;i<array_length(_merge_ships);i++){
find_and_move_ship_between_fleets(merge_fleet, main_fleet, _merge_ships[i]);
if (_merge_ships[i]<array_length(obj_ini.ship)){
find_and_move_ship_between_fleets(merge_fleet, main_fleet, _merge_ships[i]);
}
}
main_fleet.alarm[7]=1;
if (instance_exists(obj_fleet_select)){
Expand Down Expand Up @@ -458,26 +460,31 @@ function player_retreat_from_fleet_combat(){
function fleet_full_ship_array(fleet="none", exclude_capitals=false, exclude_frigates = false, exclude_escorts = false){
var all_ships = [];
var i;
var _ship_count = array_length(obj_ini.ship);
if (fleet=="none"){
if (!exclude_capitals){
for (i=0; i<array_length(capital_num);i++){

array_push(all_ships, capital_num[i]);
if (capital_num[i]<_ship_count){
array_push(all_ships, capital_num[i]);
}

}
}
if (!exclude_frigates){
for (i=0; i<array_length(frigate_num);i++){

array_push(all_ships, frigate_num[i]);
if (frigate_num[i]<_ship_count){
array_push(all_ships, frigate_num[i]);
}

}
}
if (!exclude_escorts){
for (i=0; i<array_length(escort_num);i++){

array_push(all_ships, escort_num[i]);

if (escort_num[i]<_ship_count){
array_push(all_ships, escort_num[i]);
}
}
}
} else {
Expand Down
Loading