From 15f70d072304369980589103c329574bf8912319 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 16 Nov 2024 23:27:56 +0000 Subject: [PATCH] ork behaviour tweaks --- ChapterMaster.yyp | 2 +- objects/obj_controller/Alarm_5.gml | 2 +- objects/obj_en_fleet/Alarm_1.gml | 67 +++++++------- objects/obj_en_fleet/Alarm_4.gml | 1 + objects/obj_en_fleet/Create_0.gml | 4 +- scripts/scr_enemy_ai_c/scr_enemy_ai_c.gml | 8 -- .../scr_fleet_functions.gml | 32 ++++++- scripts/scr_load/scr_load.gml | 1 + .../scr_ork_fleet_functions.gml | 88 ++++++++++++------- scripts/scr_save/scr_save.gml | 1 + 10 files changed, 127 insertions(+), 79 deletions(-) diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index dd2001e494..0ab56fc326 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -1259,4 +1259,4 @@ "TextureGroups": [ {"resourceType":"GMTextureGroup","resourceVersion":"1.3","name":"Default","autocrop":true,"border":2,"compressFormat":"bz2","directory":"","groupParent":null,"isScaled":false,"loadType":"default","mipsToGenerate":0,"targets":-1,}, ], -} +} \ No newline at end of file diff --git a/objects/obj_controller/Alarm_5.gml b/objects/obj_controller/Alarm_5.gml index 0402b19139..ad5b57c7f2 100644 --- a/objects/obj_controller/Alarm_5.gml +++ b/objects/obj_controller/Alarm_5.gml @@ -1294,7 +1294,7 @@ if (fest_scheduled>0) and (fest_repeats>0){ //research and forge related actions research_end(); apothecary_simple(); - +merge_ork_fleets(); //complex route plotting for player fleets with (obj_p_fleet){ if (array_length(complex_route)>0 && action == ""){ diff --git a/objects/obj_en_fleet/Alarm_1.gml b/objects/obj_en_fleet/Alarm_1.gml index 3fe236440a..55b5102457 100644 --- a/objects/obj_en_fleet/Alarm_1.gml +++ b/objects/obj_en_fleet/Alarm_1.gml @@ -6,8 +6,9 @@ var orb=orbiting; if (round(owner)!=eFACTION.Imperium) and (navy=1) then owner= noone; //TODO centralise orbiting logic +var _is_orbiting = is_orbiting(); if (orbiting != 0 && action=="" && owner!=noone){ - var orbiting_found=instance_exists(orbiting); + var orbiting_found=_is_orbiting; if (orbiting_found){ orbiting_found = variable_instance_exists(orbiting, "present_fleet"); if (orbiting_found){ @@ -24,7 +25,12 @@ if ((trade_goods="Khorne_warband") or (trade_goods="Khorne_warband_landing_force khorne_fleet_cargo(); } -if (instance_exists(orbiting)) { +if (_is_orbiting) { + turns_static++; + if (turns_static>15 && owner==eFACTION.Ork){ + ork_fleet_move(); + _is_orbiting=false; + } if (instance_exists(obj_crusade)) and (orbiting.owner <= eFACTION.Ecclesiarchy) and (owner = eFACTION.Imperium) @@ -114,19 +120,17 @@ if (instance_exists(orbiting)) { } if (navy && action=="") { - var orbit = instance_nearest(x,y, obj_star); - orbiting = point_distance(x,y,orbit.x,orbit.y)<50?orbit:false; if trade_goods != "player_hold" { - if (trade_goods="") and (instance_exists(orbiting)){ + if (trade_goods="") and (_is_orbiting){ if (orbiting.present_fleet[20]>0) then exit; } // Check if the ground battle is victorious or not if (obj_controller.faction_status[eFACTION.Imperium]="War") and (trade_goods="invading_player") and (guardsmen_unloaded=1) { - if (instance_exists(orbiting)) { + if (_is_orbiting) { //slightly more verbose than the last way, but reduces reliance on fixed array sizes var tar = array_reduce(orbiting.p_guardsmen, function(prev, curr, idx) { @@ -154,7 +158,7 @@ if (navy && action=="") { // Invade the player homeworld as needed navy_attack_player_world(); // Bombard the shit out of the player homeworld - if (obj_controller.faction_status[eFACTION.Imperium]="War") and (trade_goods="") and (guardsmen_unloaded=0) and (instance_exists(orbiting)){ + if (obj_controller.faction_status[eFACTION.Imperium]="War") and (trade_goods="") and (!guardsmen_unloaded) and (_is_orbiting){ var bombard=false; if (orbiting!=noone){ if (orbiting.object_index==obj_star) then bombard=true; @@ -259,7 +263,7 @@ if (navy && action=="") { if (obj_controller.faction_status[eFACTION.Imperium]="War") and (action="") and (trade_goods="") and (guardsmen_unloaded=0) { var hold = false; - if (is_orbiting()){ + if (_is_orbiting){ var player_owns_planet = scr_get_planet_with_owner(orbiting, eFACTION.Player); hold = player_owns_planet or (orbiting.present_fleet[eFACTION.Player] > 0) } @@ -323,7 +327,7 @@ if (navy && action=="") { if (fleet_distance40) and (instance_exists(obj_temp7)) {// Go towards that fleet planet_nearby=instance_nearest(fleet_nearby.x,fleet_nearby.y,obj_star); - if (instance_exists(planet_nearby)) and (instance_exists(orbiting)){ + if (instance_exists(planet_nearby)) and (_is_orbiting){ if (fleet_distance<=500) and (planet_nearby!=orbiting){// Case 1; really close, wait for them to make the move with(obj_temp7){instance_destroy();} with(obj_temp8){instance_destroy();} @@ -387,7 +391,7 @@ if (navy && action=="") { - if (action="") and (instance_exists(orbiting)) and (guardsmen_unloaded=1){// Move from one planet to another + if (action="") and (_is_orbiting) and (guardsmen_unloaded=1){// Move from one planet to another var o=0,that=0,highest=0,cr=0; o=0;that=0;highest=0;cr=0; @@ -436,14 +440,14 @@ if (navy && action=="") { send_navy_to_forge(); } // Bombard the shit out of things when able - else if (trade_goods=="") and (instance_exists(orbiting)) and (action=""){ + else if (trade_goods=="") and (_is_orbiting) and (action=""){ imperial_navy_bombard(); } // If the guardsmen all die then move on var o=0; - if (guardsmen_unloaded=1) and (instance_exists(orbiting)){ + if (guardsmen_unloaded=1) and (_is_orbiting){ var o=0,guardsmen_alive=1; repeat(orbiting.planets){ o+=1; @@ -525,14 +529,18 @@ if (navy && action=="") { trade_goods="goto_recruiting"; action_x=c_plan.x; action_y=c_plan.y; - set_fleet_movement(); + set_fleet_movement() + _is_orbiting=false; } - with(obj_temp_inq){instance_destroy();}exit; + with(obj_temp_inq){ + instance_destroy(); + } + exit; } // Get recruits if (action="") and (trade_goods="goto_recruiting"){ - if (instance_exists(orbiting)){ + if (_is_orbiting){ var o=0,that=0,te=0,te_large=0; repeat(orbiting.planets){ o+=1; @@ -580,25 +588,22 @@ if (navy && action=="") { } } -var dir;dir=0; -var ret;ret=0; +var dir=0; +var ret=0; -if (action==""){ - if (instance_exists(orbiting)){orbiting=orbiting;}// orbiting.present_fleet[owner]+=1; - else{orbiting=instance_nearest(x,y,obj_star);orbiting=orbiting;} - var max_dis;max_dis=400; +if (action=="" && _is_orbiting){ + var max_dis=400; - if (instance_exists(orbiting)){ - if (orbiting.owner=eFACTION.Player) and (obj_controller.faction_status[eFACTION.Imperium]="War") and (owner=eFACTION.Imperium){ - var i;i=0; - repeat(4){i+=1; - if (orbiting.p_owner[i]=1) then orbiting.p_pdf[i]-=capital_number*50000; - if (orbiting.p_owner[i]=1) then orbiting.p_pdf[i]-=frigate_number*10000; - if (orbiting.p_pdf[i]<0) then orbiting.p_pdf[i]=0; - } + + if (orbiting.owner=eFACTION.Player) and (obj_controller.faction_status[eFACTION.Imperium]="War") and (owner=eFACTION.Imperium){ + for (var i=1;i<=orbiting.planets;i++){ + if (orbiting.p_owner[i]=1) then orbiting.p_pdf[i]-=capital_number*50000; + if (orbiting.p_owner[i]=1) then orbiting.p_pdf[i]-=frigate_number*10000; + if (orbiting.p_pdf[i]<0) then orbiting.p_pdf[i]=0; } } + // 1355; @@ -918,7 +923,7 @@ if (action==""){ }*/ } - if (owner = eFACTION.Tyranids) {// Juggle bio-resources + if (owner == eFACTION.Tyranids) {// Juggle bio-resources if (capital_number*2>frigate_number){ capital_number-=1;frigate_number+=2; } @@ -1005,7 +1010,7 @@ if (action==""){ } } - if (owner=eFACTION.Ork) and (action=""){// Should fix orks converging on useless planets + if (owner=eFACTION.Ork) and (action==""){// Should fix orks converging on useless planets ork_fleet_move(); } } diff --git a/objects/obj_en_fleet/Alarm_4.gml b/objects/obj_en_fleet/Alarm_4.gml index 022227a224..5e07d20081 100644 --- a/objects/obj_en_fleet/Alarm_4.gml +++ b/objects/obj_en_fleet/Alarm_4.gml @@ -61,6 +61,7 @@ if (action==""){ } if (cont=20){// Move the entire fleet, don't worry about the other crap + turns_static = 0; var eta=0; if (trade_goods!="") and (owner != eFACTION.Tyranids) and (owner != eFACTION.Chaos) and (string_count("Inqis",trade_goods)=0) and (string_count("merge",trade_goods)=0)and (string_count("_her",trade_goods)=0) and (trade_goods!="cancel_inspection") and (trade_goods!="return"){ diff --git a/objects/obj_en_fleet/Create_0.gml b/objects/obj_en_fleet/Create_0.gml index 77d45c1f93..096920ca85 100644 --- a/objects/obj_en_fleet/Create_0.gml +++ b/objects/obj_en_fleet/Create_0.gml @@ -12,13 +12,15 @@ hurt=0; orbiting=0; rep=3; minimum_eta=2; +turns_static = 0; navy=0; guardsmen_ratio=0; guardsmen_unloaded=0; complex_route = []; warp_able = false; ii_check=floor(random(5))+1; -etah=0;safe=0; +etah=0; +safe=0; //TODO set up special save method for faction specific fleet variables inquisitor=-1; diff --git a/scripts/scr_enemy_ai_c/scr_enemy_ai_c.gml b/scripts/scr_enemy_ai_c/scr_enemy_ai_c.gml index be613a25da..8bceac7488 100644 --- a/scripts/scr_enemy_ai_c/scr_enemy_ai_c.gml +++ b/scripts/scr_enemy_ai_c/scr_enemy_ai_c.gml @@ -115,14 +115,6 @@ function scr_enemy_ai_c() { } - // This is the ork landing code - ork_fleet_arrive_target(); - - - - - - // traitors below here diff --git a/scripts/scr_fleet_functions/scr_fleet_functions.gml b/scripts/scr_fleet_functions/scr_fleet_functions.gml index a8a09ec3db..6e03cb6e64 100644 --- a/scripts/scr_fleet_functions/scr_fleet_functions.gml +++ b/scripts/scr_fleet_functions/scr_fleet_functions.gml @@ -113,8 +113,8 @@ function get_largest_player_fleet(){ function is_orbiting(){ if (action != "") then return false; var nearest = instance_nearest(x,y,obj_star); - if (point_distance(x,y,nearest.x, nearest.y)<50){ - orbiting = nearest; + if (point_distance(x,y,nearest.x, nearest.y)<10 && nearest.name != ""){ + orbiting = nearest.id; return true } orbiting=false; @@ -126,6 +126,7 @@ function set_fleet_movement(fastest_route = true){ action = ""; if (action==""){ + turns_static = 0; var sys, mine, fleet; var connected=0,cont=0,target_dist=0; if (fastest_route){ @@ -733,7 +734,7 @@ function fleet_arrival_logic(){ if (cur_star.x=old_x) and (cur_star.y=old_y) and (cur_star.owner=self.owner) and (cur_star.action="") and ((owner = eFACTION.Tau) or (owner = eFACTION.Chaos)) and (mergus=10) and (trade_goods!="csm") and (trade_goods!="Khorne_warband"){// Move somewhere new var stue, stue2;stue=0;stue2=0; - var goood;goood=0; + var goood=0; with(obj_star){if (planets=1) and (p_type[1]="Dead") then instance_deactivate_object(id);} stue=instance_nearest(x,y,obj_star); @@ -763,7 +764,11 @@ function fleet_arrival_logic(){ if (owner = eFACTION.Ork){ - + if (is_orbiting()){ + with (orbiting){ + ork_fleet_arrive_target(); + } + } var kay, temp5, temp6, temp7; kay=0;temp5=0;temp6=0;temp7=0; @@ -835,3 +840,22 @@ function choose_fleet_sprite_image(){ } + +function merge_fleets(main_fleet, merge_fleet){ + main_fleet.capital_number += merge_fleet.capital_number; + main_fleet.frigate_number += merge_fleet.frigate_number; + main_fleet.escort_number += merge_fleet.escort_number; + var _merge_cargo = struct_get_names(merge_fleet.cargo_data); + //TODO custom merge stuff + for (var i=0;i0) and (boat.owner = eFACTION.Ork) and (boat.action=="") and (planets>0){ - var landi=0,t1=0,l=0; + if (present_fleet[eFACTION.Player]+present_fleet[eFACTION.Imperium]=0) and (present_fleet[7]>0) and (boat.owner = eFACTION.Ork) and (boat.action=="") and (planets>0){ + var _allow_landing=true,t1=0,l=0; repeat(planets){ l+=1; @@ -115,8 +110,8 @@ function ork_fleet_arrive_target(){ } } - landi = !is_dead_star(); - if (!landi){ + _allow_landing = !is_dead_star(); + if (_allow_landing){ for (var i=1;i<=planets;i++){ if ((p_guardsmen[i]+p_pdf[i]+p_player[i]+p_traitors[i]+p_tau[i]>0) or ((p_owner[i]!=7) and (p_orks[i]<=0))){ if (p_type[i]!="Dead") and (p_orks[i]<4) and (i<=planets) and (instance_exists(boat)){ @@ -136,10 +131,12 @@ function ork_fleet_arrive_target(){ } else { var new_wagh_star = distance_removed_star(x,y, choose(2,3,4,5)); if (instance_exists(new_wagh_star)){ - action_x=new_wagh_star.x; - action_y=new_wagh_star.y; - action = ""; - set_fleet_movement(); + with (boat){ + action_x=new_wagh_star.x; + action_y=new_wagh_star.y; + action = ""; + set_fleet_movement(); + } } } } @@ -148,7 +145,32 @@ function ork_fleet_arrive_target(){ if (aler>0) then scr_alert("green","owner",$"Ork ships have crashed across the {name} system.",x,y); - }// End landing portion of code + }// End _allow_landingng portion of code + +} + +//TOSO provide logic for fleets to attack each other +function merge_ork_fleets(){ + var _stars_with_ork_fleets = {}; + with (obj_en_fleet){ + if (!owner != eFACTION.Ork) then continue; + if (is_orbiting()){ + if (struct_exists(_stars_with_ork_fleets, orbiting.name)){ + array_push(_stars_with_ork_fleets[$orbiting.name],id); + } else { + _stars_with_ork_fleets[$ orbiting.name] = [id]; + } + } + } + var _star_names = struct_get_names(_stars_with_ork_fleets); + for (var i =0;i