@@ -539,6 +539,213 @@ mem_create_destroyed_orila_system_objects = {
539539 }
540540}
541541
542+ # is fired after the vazuran setup, so that systems destroyed by them can be used as well
543+ mem_gamestart_orila_primitive_setup = {
544+ every_system = {
545+ limit = {
546+ has_star_flag = mem_orila_primitive_system
547+ }
548+ event_target:global_event_country = {
549+ change_variable = {
550+ which = mem_global_orila_primitive_systems
551+ value = 1
552+ }
553+ }
554+ }
555+ while = {
556+ limit = {
557+ event_target:global_event_country = {
558+ check_variable = {
559+ which = mem_global_orila_primitive_systems
560+ value < 5
561+ }
562+ }
563+ any_system = {
564+ has_star_flag = primitive_system
565+ is_fe_cluster = no
566+ NOT = {
567+ has_star_flag = mem_orila_primitive_system
568+ }
569+ }
570+ }
571+ random_system = {
572+ limit = {
573+ has_star_flag = primitive_system
574+ is_fe_cluster = no
575+ NOT = {
576+ has_star_flag = mem_orila_primitive_system
577+ }
578+ }
579+ every_system_planet = {
580+ limit = {
581+ exists = owner
582+ owner = {
583+ is_primitive = yes
584+ }
585+ }
586+ add_building = building_mem_planetary_shield_generator_orila
587+ set_planet_flag = mem_orila_primitive_world
588+ }
589+ set_star_flag = mem_orila_primitive_system
590+ #set the shield effect
591+ random_system_planet = {
592+ planet_event = { id = mem_planetary_shields.5 days = 1 }
593+ }
594+
595+ #################################################################
596+ #TODO Reenable Ancient Protector Spawn by removing the star flag
597+ set_star_flag = mem_orila_primitive_system_destroyed
598+ #################################################################
599+
600+ mem_setup_orila_primitive_system = yes
601+ #variable to count how many of these systems actually have been spawned
602+ event_target:global_event_country = {
603+ change_variable = {
604+ which = mem_global_orila_primitive_systems
605+ value = 1
606+ }
607+ }
608+ }
609+ }
610+ event_target:global_event_country = {
611+ set_variable = {
612+ which = mem_global_orila_primitive_systems_destroyed
613+ value = 0
614+ }
615+ }
616+ while = {
617+ limit = {
618+ any_system = {
619+ is_fe_cluster = no
620+ has_planet_class = pc_nuked
621+ has_planet_class = pc_shattered
622+ has_planet_class = pc_broken
623+ NOR = {
624+ has_star_flag = old_foes_system
625+ has_star_flag = ratling_system
626+ #has_star_flag = empire_cluster
627+ has_star_flag = mem_orila_primitive_system
628+ }
629+ }
630+ event_target:global_event_country = {
631+ check_variable = {
632+ which = mem_global_orila_primitive_systems_destroyed
633+ value < 5
634+ }
635+ }
636+ }
637+ random_system = {
638+ limit = {
639+ is_fe_cluster = no
640+ has_planet_class = pc_nuked
641+ has_planet_class = pc_shattered
642+ has_planet_class = pc_broken
643+ NOR = {
644+ has_star_flag = ratling_system
645+ #has_star_flag = empire_cluster
646+ has_star_flag = mem_orila_primitive_system
647+ }
648+ }
649+ set_star_flag = mem_orila_primitive_system_destroyed
650+ random_system_planet = {
651+ limit = {
652+ is_primary_star = yes
653+ }
654+ random_list = {
655+ 40 = {
656+ create_ambient_object = {
657+ type = mem_orila_spaceport_wreckage_object
658+ location = this
659+ }
660+ last_created_ambient_object = {
661+ set_location = {
662+ target = prev
663+ distance = 20
664+ angle = 120
665+ }
666+ create_ambient_object = {
667+ type = small_debris_object
668+ entity_offset_height = { min = 5 max = -5 }
669+ location = this
670+ }
671+ }
672+ }
673+ 60 = {
674+ create_ambient_object = {
675+ type = small_debris_object
676+ entity_offset_height = { min = 5 max = -5 }
677+ location = this
678+ }
679+ last_created_ambient_object = {
680+ set_location = {
681+ target = prev
682+ distance = 20
683+ angle = 120
684+ }
685+ }
686+ }
687+ }
688+ }
689+ every_system_planet = {
690+ limit = {
691+ OR = {
692+ is_planet_class = pc_nuked
693+ is_planet_class = pc_shattered
694+ is_planet_class = pc_broken
695+ }
696+ }
697+ if = {
698+ limit = {
699+ is_planet_class = pc_nuked
700+ }
701+ #flag can later be used to spawn digsites or anomalies
702+ set_planet_flag = mem_orila_primitive_world_destroyed
703+ }
704+ random_list = {
705+ 40 = {
706+ create_ambient_object = {
707+ type = mem_orila_small_station_wreckage_object
708+ location = this
709+ }
710+ last_created_ambient_object = {
711+ set_location = {
712+ target = prev
713+ distance = 5
714+ angle = random
715+ }
716+ create_ambient_object = {
717+ type = small_debris_object
718+ entity_offset_height = { min = 5 max = -5 }
719+ location = this
720+ }
721+ }
722+ }
723+ 60 = {
724+ create_ambient_object = {
725+ type = small_debris_object
726+ entity_offset_height = { min = 5 max = -5 }
727+ location = this
728+ }
729+ last_created_ambient_object = {
730+ set_location = {
731+ target = prev
732+ distance = 5
733+ angle = random
734+ }
735+ }
736+ }
737+ }
738+ }
739+ event_target:global_event_country = {
740+ change_variable = {
741+ which = mem_global_orila_primitive_systems_destroyed
742+ value = 1
743+ }
744+ }
745+ }
746+ }
747+ }
748+
542749mem_setup_orila_primitive_system = {
543750 if = {
544751 limit = {
0 commit comments