Skip to content
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
1 change: 1 addition & 0 deletions ChapterMaster.yyp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions objects/obj_star_select/Draw_64.gml
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ if (obj_controller.selecting_planet!=0){
problem_data.f_type = P_features.Mission;
problem_data.time = target.p_timer[current_planet][i];
problem_data.problem = problems[i];
problem_data.array_position = i;
array_push(planet_displays, [mission_string, problem_data]);
}
}
Expand Down
87 changes: 61 additions & 26 deletions scripts/is_specialist/is_specialist.gml
Original file line number Diff line number Diff line change
Expand Up @@ -189,46 +189,81 @@ function is_specialist(unit_role, type="standard", include_trainee=false) {
return array_contains(specialists,unit_role);
}

//TODO write this out with proper formatting when i can be assed
//Used to quikcly collect groups of marines with given parameters
// group takes a string relating to options in the role_groups function, to ignore filtering by group use "all"
// can also pass an array to filter for mutiple groups
// location takes wther a string with a system name or an array with 3 parameters [<location name>,<planet number>,<ship number>]
// if opposite is true then then the roles defined in the group argument are ignored and all others collected
// search conditions
// companies, takes either an int or an arrat to define which companies to search in
// any stat allowed by the stat_valuator basically allows you to look for marines whith certain stat lines
// job allows you to find marines forfuling certain tasks like garrison or forge etc

function collect_role_group(group="standard", location="", opposite=false, search_conditions = {companies:"all"}){
var units = [], unit, count=0, add=false, is_special_group;
var _units = [], unit, count=0, _add=false, _is_special_group;
var _max_count = 0;
var _total_count = 0;
if (struct_exists(search_conditions, "max")){
_max_count = search_conditions.max;
}
if (!struct_exists(search_conditions, "companies")){
search_conditions.companies = "all";
}
for (var com=0;com<=10;com++){
var wanted_companies = search_conditions.companies;
if (wanted_companies!="all"){
if (is_array(wanted_companies)){
if (!array_contains(wanted_companies, com)) then continue;
if (_max_count>0){
if (array_length(_units)>=_max_count){
break;
}
}
var _wanted_companies = search_conditions.companies;
if (_wanted_companies!="all"){
if (is_array(_wanted_companies)){
if (!array_contains(_wanted_companies, com)) then continue;
} else {
if (wanted_companies != com) then continue;
if (_wanted_companies != com) then continue;
}
}
for (i=0;i<array_length(obj_ini.TTRPG[com]);i++){
add=false;
if (_max_count>0){
if (array_length(_units)>=_max_count){
break;
}
}
if array_length(_units)
_add=false;
unit=fetch_unit([com,i]);
if (unit.name()=="") then continue;
if (group!="all"){
if (is_array(group)){
is_special_group = unit.IsSpecialist(group[0], group[1]);
_is_special_group = unit.IsSpecialist(group[0], group[1]);
} else {
is_special_group = unit.IsSpecialist(group);
_is_special_group = unit.IsSpecialist(group);
}
} else {
is_special_group = true;
_is_special_group = true;
}
if ((is_special_group && !opposite) || (!is_special_group && opposite)){
if ((_is_special_group && !opposite) || (!_is_special_group && opposite)){
if (location==""){
add=true;
} else if (unit.is_at_location(location, 0, 0)){
add=true;
}
_add=true;
} else if (!is_array(location)){
_add=unit.is_at_location(location, 0, 0);
} else {
_add=unit.is_at_location(location[0], location[1], location[2]);
}
}
if (add){
if (_add){
if (struct_exists(search_conditions, "stat")){
add = stat_valuator(search_conditions[$ "stat"], unit);
_add = stat_valuator(search_conditions[$ "stat"], unit);
}
if (struct_exists(search_conditions,"job")){
_add = (unit.assignment() == search_conditions.job);
}
}
if (add) then array_push(units, obj_ini.TTRPG[com][i]);
if (_add) then array_push(_units, obj_ini.TTRPG[com][i]);
}
}
return units;
return _units;
}

function stat_valuator(search_params, unit){
Expand All @@ -250,10 +285,10 @@ function stat_valuator(search_params, unit){
}

function collect_by_religeon(religion, sub_cult="", location=""){
var units = [], unit, count=0, add=false;
var _units = [], unit, count=0, _add=false;
for (var com=0;com<=10;com++){
for (i=1;i<array_length(obj_ini.TTRPG[com]);i++){
add=false;
_add=false;
unit=obj_ini.TTRPG[com][i];
if (unit.name()=="")then continue;
if (unit.religion == religion){
Expand All @@ -263,15 +298,15 @@ function collect_by_religeon(religion, sub_cult="", location=""){
}
}
if (location==""){
add=true;
_add=true;
} else if (unit.is_at_location(location, 0, 0)){
add=true;
_add=true;
}
}
if (add) then array_push(units, obj_ini.TTRPG[com][i]);
if (_add) then array_push(_units, obj_ini.TTRPG[com][i]);
}
}
return units;
return _units;
}

function group_selection(group, selection_data){
Expand Down Expand Up @@ -340,7 +375,7 @@ function group_selection(group, selection_data){
if (array_length(vehicles)>0){
for (var veh=0;veh<array_length(vehicles);veh++){
unit = vehicles[veh];
add_vehicle_to_manage_arrays(unit)
_add_vehicle_to_manage_arrays(unit)
}
}
other_manage_data();
Expand Down
3 changes: 0 additions & 3 deletions scripts/scr_draw_management_unit/scr_draw_management_unit.gml
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,6 @@ function scr_draw_management_unit(selected, yy=0, xx=0, draw=true){
if (((mouse_x>=xx+25 && mouse_y>=yy+64 && mouse_x<xx+974 && mouse_y<yy+85) || force_tool==1) && is_struct(unit)){
temp[120] = unit; // unit_struct
}
if (man_sel[selected]){
man_count++;
}
}
if (!ma_view[selected]) return "continue";
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function FeatureSelected(Feature, system, planet) constructor{
}else if (cult_control<75){
control_string = "Has managed to galvanise the populace to overcome the former governor of the planet turning much of the local pdf to it's cause, it must be stopped, lest it spread.";
} else {
control_string = "The Cults rot and control of the planet is complete even if the cult can be dismantled the rot is great and the population will need significant purging and monitering to remove the rot";
control_string = "The Cults rot and control of the planet is complete even if the cult can be dismantled the rot is great and the population will need significant purging and monitering to remove the taint";
}
body = $"The Cult of {feature.name} {control_string}";
break;
Expand Down Expand Up @@ -209,6 +209,7 @@ function FeatureSelected(Feature, system, planet) constructor{
system:obj_controller.selected.id,
feature:obj_star_select.feature,
planet : obj_controller.selecting_planet,
array_slot : feature.array_position,
selections : []
});
destroy=true;
Expand Down
63 changes: 4 additions & 59 deletions scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml
Original file line number Diff line number Diff line change
Expand Up @@ -385,72 +385,17 @@ function scr_enemy_ai_d() {
}
var garrison_mission = has_problem_planet_and_time(i,"provide_garrison", 0);
if (garrison_mission>-1){
var planet = new PlanetData(i, self);
if (problem_has_key_and_value(i,garrison_mission,"stage", "active")){
if (planet.current_owner == eFACTION.Imperium && system_garrison[i-1].garrison_force){
var mission_string = $"The garrison on {planet_numeral_name(i)} has finished the period of garrison support agreed with the planetary governor.";
var p_garrison = system_garrison[i-1];
var result = p_garrison.garrison_disposition_change(id, i);
if (!p_garrison.garrison_leader){
p_garrison.find_leader();
}
if (result == "none"){
//TODO make a dedicated plus minus string function if there isn't one already
} else if (!result){
var effect = result * irandom_range(1,5);
dispo[i] += effect;
mission_string += $"A number of diplomatic incidents occured over the period which had considerable negative effects on our disposition with the planetary governor (disposition -{effect})";
} else {
var effect = result * irandom_range(1,5);
dispo[i] += result * effect;
mission_string += $"As a diplomatic mission the duration of the stay was a success with our political position with the planet being enhanced greatly (disposition +{effect})";
}
var tester = global.character_tester;
var widom_test = tester.standard_test(p_garrison.garrison_leader, "wisdom",0, ["siege"]);
if (widom_test[0]){
p_fortified[i]++;
mission_string+=$"while stationed {p_garrison.garrison_leader.name_role()} makes several notable observations and is able to instruct the planets defense core leaving the world better defended (fortifications++).";
}
//TODO just generall apply this each turn with a garrison to see if a cult is found
if (planet_feature_bool(p_feature[i], P_features.Gene_Stealer_Cult)){
var cult = return_planet_features(planet.features,P_features.Gene_Stealer_Cult)[0];
if (cult.hiding){
widom_test = tester.standard_test(p_garrison.garrison_leader, "wisdom",0, ["tyranids"]);
if (widom_test[0]){
cult.hiding = false;
mission_string+="Most alarmingly signs of a genestealer cult are noted by the garrison. how far the rot has gone will now need to be investigated and the xenos taint purged.";
}
}
}
scr_popup($"Agreed Garrison of {planet_numeral_name(i)} complete",mission_string,"","");
} else {
dispo[i] -= 20;
scr_popup($"Agreed Garrison of {planet_numeral_name(i)}",$"your agreed garrison of {planet_numeral_name(i)} was cut short by your chapter the planetary governor has expressed his displeasure (disposition -20)","","");
}
remove_planet_problem(i, "provide_garrison");
} else {
remove_planet_problem(i, "provide_garrison");
}
try_and_report_loop("complete garrison mission", complete_garrison_mission,true, [i,garrison_mission]);
}
var beast_hunt = has_problem_planet_and_time(i,"hunt_beast", 0);
if (beast_hunt>-1){
var planet = new PlanetData(i, self);
if (problem_has_key_and_value(i,beast_hunt,"stage","active")){
mission_string = "";

scr_popup($"Agreed Garrison of {planet_numeral_name(i)} complete story line mission and rewards need work",mission_string,"","");

remove_planet_problem(i, "hunt_beast");
} else {
remove_planet_problem(i, "hunt_beast");
}
try_and_report_loop("complete beast hunt mission", complete_beast_hunt_mission,true, [i,beast_hunt]);
}

if ((p_tyranids[i]=3) or (p_tyranids[i]=4)) and (p_population[i]>0){
if (!(has_problem_planet(i, "Hive Fleet"))){
var roll, cont;
roll=irandom_range(100,300);
cont=0;
var roll=irandom_range(100,300);
var cont=0;


if (p_tyranids[i]=3) and (roll<=5) then cont=1;
Expand Down
10 changes: 6 additions & 4 deletions scripts/scr_manage_task_selector/scr_manage_task_selector.gml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function scr_manage_task_selector(){
exit;
}
}
man_count = array_sum(man_sel);
if (selection_data.purpose_code!="manage"){
if ((man_count==0 || man_count>selection_data.number)){
proceed_button.draw_shutter(xx+1110,yy+70, "Proceed", 0.5, false);
Expand Down Expand Up @@ -83,10 +84,11 @@ function scr_manage_task_selector(){
case "train_forces":
unit = display_unit[i];
unit.job = {
type:purpose_code,
type:selection_data.purpose_code,
planet:selection_data.planet,
location:selection_data.system.name
};
unit.unload(selection_data.planet, selection_data.system);
break;
}
} else {
Expand All @@ -111,9 +113,9 @@ function scr_manage_task_selector(){
calculate_research_points();
break;
case "hunt_beast":
var problem_slot = find_problem_planet(selection_data.planet, selection_data.purpose_code,selection_data.system);
init_beast_hunt_mission(selection_data.planet, selection_data.system,problem_slot);

var problem_slot = selection_data.array_slot;
init_beast_hunt_mission(selection_data.planet, selection_data.system,problem_slot);
break;
}
exit_adhoc_manage();
exit;
Expand Down
84 changes: 2 additions & 82 deletions scripts/scr_marine_struct/scr_marine_struct.gml
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data={})
turn_stat_gains[$ stat_gains]=1;
}
}
assign_reactionary_traits();
}
return instace_stat_point_gains;
}
Expand Down Expand Up @@ -2145,7 +2146,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data={})
static unload = function(planet_number, system){
var current_location = marine_location();
if (current_location[0]==location_types.ship){
if (!array_contains(["Warp", "Terra", "Mechanicus Vessel"],obj_ini.ship_location[current_location[1]]) && obj_ini.ship_location[current_location[1]]==system.name){
if (!array_contains(["Warp", "Terra", "Mechanicus Vessel"],current_location[2]) && current_location[2]==system.name){
obj_ini.loc[company][marine_number]=obj_ini.ship_location[current_location[1]];
planet_location=planet_number;
ship_location=0;
Expand Down Expand Up @@ -2500,84 +2501,3 @@ function fetch_unit(unit){
}


function PenAndPaperSim() constructor{
static oppposed_test = function(unit1, unit2, stat,unit1_mod=0,unit2_mod=0, modifiers={}){
var stat1 = irandom(99)+1;
var unit1_val = unit1[$ stat]+unit1_mod;
var unit2_val = unit2[$ stat]+unit2_mod;
var stat2 = irandom(99)+1;
var stat1_pass_margin, stat2_pass_margin, winner, pass_margin;
//unit 1 passes test
if (stat1 < unit1_val){
stat1_pass_margin = unit1_val- stat1;

//unit 1 and unit 2 pass tests
if (stat2<unit2_val){
stat2_pass_margin = unit2_val - stat2;

//unit 2 passes by bigger margin and thus wins
if (stat2_pass_margin > stat1_pass_margin){
winner = 2;
pass_margin = stat2_pass_margin-stat1_pass_margin;
} else {
winner = 1;
pass_margin = stat1_pass_margin-stat2_pass_margin;
}
} else {//only unit 1 passes test thus is winner
winner = 1;
pass_margin = unit1_val- stat1;
}
} else if (stat2<unit2_val){//only unit 2 passes test
winner = 2;
pass_margin = unit2_val-stat2;
} else {
winner = 0;
pass_margin = unit1_val- stat1;
}

return [winner, pass_margin];
}
static evaluate_tags = function(unit, tags){
var total_mod = 0,tag;
for (var i=0;i<array_length(tags);i++){
tag=tags[i];
if (tag=="siege"){
if (scr_has_adv("Siege Masters")){
total_mod+=10
}
if (unit.has_trait("siege_master")){
total_mod+=10;
}
}
else if (tag=="tyranids"){
if (scr_has_adv("Enemy: Tyranids")){
total_mod+=10
}
if (unit.has_trait("tyrannic_vet")){
total_mod+=10;
}
}
}
return total_mod;
}

static standard_test = function(unit, stat, difficulty_mod=0, tags = []){
var passed =false;
var margin=0;
difficulty_mod+=evaluate_tags(unit, tags);
var random_roll = irandom_range(1,100);
if (random_roll<unit[$ stat]+difficulty_mod){
passed = true;
margin = unit[$ stat]+difficulty_mod - random_roll;
} else {
passed = false;
margin = unit[$ stat]+difficulty_mod - random_roll;
}

return [passed, margin];
}
}

global.character_tester = new PenAndPaperSim();


Loading