Made the repo more up-to-date.

This commit is contained in:
Nikolai V Chr
2019-04-14 08:57:01 +02:00
parent eb205cc8ff
commit d7aa0c93cc
21 changed files with 1470 additions and 554 deletions
+317
View File
@@ -0,0 +1,317 @@
var clamp = func(v, min, max) { v < min ? min : v > max ? max : v }
var TRUE = 1;
var FALSE = 0;
var hp_max = 200;
var hp = [hp_max,hp_max,hp_max,hp_max,hp_max,hp_max,hp_max];
var cannon_types = {
" M70 rocket hit": 0.25, #135mm
" M55 cannon shell hit": 0.10, # 30mm
" KCA cannon shell hit": 0.10, # 30mm
" Gun Splash On ": 0.10, # 30mm
" M61A1 shell hit": 0.05, # 20mm
" GAU-8/A hit": 0.10, # 30mm
" BK27 cannon hit": 0.07, # 27mm
" GSh-30 hit": 0.10, # 30mm
" GSh-23 hit": 0.065,# 23mm
" 7.62 hit": 0.005,# 7.62mm
" 50 BMG hit": 0.015,# 12.7mm
" S-5 rocket hit": 0.20, #55mm
};
var warhead_lbs = {
"AGM-65": 126.00,
"AGM-84": 488.00,
"AGM-88": 146.00,
"AGM65": 200.00,
"AGM-154A": 493.00,
"AGM-158": 1000.00,
"ALARM": 450.00,
"AM39-Exocet": 364.00,
"AS-37-Martel": 330.00,
"AS30L": 529.00,
"CBU-87": 128.00,
"Exocet": 364.00,
"FAB-100": 92.59,
"FAB-250": 202.85,
"FAB-500": 564.38,
"GBU-12": 190.00,
"GBU-24": 945.00,
"GBU-31": 945.00,
"GBU12": 190.00,
"GBU16": 450.00,
"HVAR": 7.50,#P51
"KAB-500": 564.38,
"Kh-25MP": 197.53,
"Kh-66": 244.71,
"KN-06": 315.00,
"LAU-68": 10.00,
"M317": 145.00,
"M71": 200.00,
"M71R": 200.00,
"M90": 500.00,
"MK-82": 192.00,
"MK-83": 445.00,
"MK-84": 945.00,
"OFAB-100": 92.59,
"RB-04E": 661.00,
"RB-05A": 353.00,
"RB-15F": 440.92,
"RB-75": 126.00,
"RN-14T": 800.00, #fictional, thermobaeric replacement for the RN-24 nuclear bomb
"RN-18T": 1200.00, #fictional, thermobaeric replacement for the RN-28 nuclear bomb
"RS-2US": 28.66,
"S-21": 245.00,
"S-24": 271.00,
"S530D": 66.00,
"SCALP": 992.00,
"Sea Eagle": 505.00,
"SeaEagle": 505.00,
"STORMSHADOW": 850.00,
"ZB-250": 236.99,
"ZB-500": 473.99,
};
var incoming_listener = func {
var history = getprop("/sim/multiplay/chat-history");
var hist_vector = split("\n", history);
if (size(hist_vector) > 0) {
var last = hist_vector[size(hist_vector)-1];
var last_vector = split(":", last);
var author = last_vector[0];
var callsign = getprop("sim/multiplay/callsign");
callsign = size(callsign) < 8 ? callsign : left(callsign,7);
if (size(last_vector) > 1 and author != callsign) {
# not myself
#print("not me");
var m2000 = FALSE;
if (find(" at " ~ callsign ~ ". Release ", last_vector[1]) != -1) {
# a m2000 is firing at us
m2000 = TRUE;
}
if (last_vector[1] == " FOX2 at" or last_vector[1] == " aim7 at" or last_vector[1] == " aim9 at"
or last_vector[1] == " aim120 at" or last_vector[1] == " RB-24J fired at" or last_vector[1] == " RB-74 fired at"
or last_vector[1] == " RB-71 fired at" or last_vector[1] == " RB-15F fired at"
or last_vector[1] == " RB-99 fired at" or m2000 == TRUE) {
# air2air being fired
if (size(last_vector) > 2 or m2000 == TRUE) {
#print("Missile launch detected at"~last_vector[2]~" from "~author);
if (m2000 == TRUE or last_vector[2] == " "~callsign) {
# its being fired at me
#print("Incoming!");
var enemy = getCallsign(author);
if (enemy != nil) {
#print("enemy identified");
var bearingNode = enemy.getNode("radar/bearing-deg");
if (bearingNode != nil) {
#print("bearing to enemy found");
var bearing = bearingNode.getValue();
var heading = getprop("orientation/heading-deg");
var clock = bearing - heading;
while(clock < 0) {
clock = clock + 360;
}
while(clock > 360) {
clock = clock - 360;
}
#print("incoming from "~clock);
if (clock >= 345 or clock < 15) {
playIncomingSound("12");
} elsif (clock >= 15 and clock < 45) {
playIncomingSound("1");
} elsif (clock >= 45 and clock < 75) {
playIncomingSound("2");
} elsif (clock >= 75 and clock < 105) {
playIncomingSound("3");
} elsif (clock >= 105 and clock < 135) {
playIncomingSound("4");
} elsif (clock >= 135 and clock < 165) {
playIncomingSound("5");
} elsif (clock >= 165 and clock < 195) {
playIncomingSound("6");
} elsif (clock >= 195 and clock < 225) {
playIncomingSound("7");
} elsif (clock >= 225 and clock < 255) {
playIncomingSound("8");
} elsif (clock >= 255 and clock < 285) {
playIncomingSound("9");
} elsif (clock >= 285 and clock < 315) {
playIncomingSound("10");
} elsif (clock >= 315 and clock < 345) {
playIncomingSound("11");
} else {
playIncomingSound("");
}
return;
}
}
}
}
} elsif (1 == 1) { # mirage: getprop("/controls/armament/mp-messaging")
# latest version of failure manager and taking damage enabled
#print("damage enabled");
var last1 = split(" ", last_vector[1]);
if(size(last1) > 2 and last1[size(last1)-1] == "exploded" ) {
#print("missile hitting someone");
if (size(last_vector) > 3 and last_vector[3] == " "~callsign) {
#print("that someone is me!");
var type = last1[1];
if (type == "Matra" or type == "Sea") {
for (var i = 2; i < size(last1)-1; i += 1) {
type = type~" "~last1[i];
}
}
var number = split(" ", last_vector[2]);
var distance = num(number[1]);
#print(type~"|");
if(distance != nil) {
var dist = distance;
#check distance w/ if statement here
if (contains(warhead_lbs, type)) {
#maxDist = maxDamageDistFromWarhead(warhead_lbs[type]);
} else {
return;
}
var prob = 1;
if (type == "M90" and distance < 300) {
var failed = fail_systems(warhead_lbs[type]/2);
return;
} elsif (distance < 150) {
if ( distance > 50 ) {
distance = distance - 50;
prob = 1 - (distance/100);
}
}
var failed = fail_systems(warhead_lbs[type] * prob);
#ar percent = 100 * probability;
#printf("Took %.1f%% damage from %s missile at %0.1f meters. %s systems was hit", percent,type,dist,failed);
}
}
} elsif (cannon_types[last_vector[1]] != nil) {
# cannon hitting someone
print("cannon");
if (size(last_vector) > 2 and last_vector[2] == " "~callsign) {
print("cannon hit us");
if (size(last_vector) < 4) {
# msg is either missing number of hits, or has no trailing dots from spam filter.
print('"'~last~'" is not a legal hit message, tell the shooter to upgrade his OPRF plane :)');
return;
}
var last3 = split(" ", last_vector[3]);
#print("last3[2]: " ~ last3[2]);
#print("last3[1]: " ~ last3[1]);
if(size(last3) > 2) {
if ( last3[2] == "hits" ) {
var hit_count = num(last3[1]);
}
} else {
var hit_count = 4;
}
var damaged_sys = 0;
var probability = cannon_types[last_vector[1]];
for (var i = 1; i <= hit_count; i = i + 1) {
var failed = fail_systems(probability);
#damaged_sys = damaged_sys + failed;
}
# that someone is me!
#print("hitting me");
#printf("Took %.1f%% damage from cannon! %s systems was hit.", probability*hit_count*100, damaged_sys);
}
}
}
}
}
}
var maxDamageDistFromWarhead = func (lbs) {
# very simple
var dist = 7*math.sqrt(lbs);
return dist;
}
var fail_systems = func (damage) {
var no = 7;
while (no > 6 or hp[no] < 0) {
no = int(rand()*7);
if (hp[no] < 0) {
if (rand() > 0.8) {
armament.defeatSpamFilter("You shot one of our already sinking ships, you are just mean.");
hp[no] = hp[no] - damage;
print("HP["~no~"]: " ~ hp[no] ~ "/" ~ hp_max);
return;
}
}
}
hp[no] = hp[no] - damage;
print("HP["~no~"]: " ~ hp[no] ~ "/" ~ hp_max);
if ( hp[no] < 0 ) {
setprop("/sim/multiplay/generic/bool["~(no+40)~"]",1);
armament.defeatSpamFilter("So you sank one of our ships, we will get you for that!");
if (!getprop("/carrier/disabled") and hp[0]<0 and hp[1]<0 and hp[2]<0) {
setprop("/carrier/disabled",1);
armament.defeatSpamFilter("Captain our offensive capability is crippled!");
}
if (hp[0]<0 and hp[1]<0 and hp[2]<0 and hp[3]<0 and hp[4]<0 and hp[5]<0 and hp[6]<0) {
setprop("/carrier/sunk",1);
armament.defeatSpamFilter("S.O.S. Heeelp");
} else {
armament.defeatSpamFilter("This is not over yet..");
}
}
};
var playIncomingSound = func (clock) {
setprop("sound/incoming"~clock, 1);
settimer(func {stopIncomingSound(clock);},3);
}
var stopIncomingSound = func (clock) {
setprop("sound/incoming"~clock, 0);
}
var callsign_struct = {};
var getCallsign = func (callsign) {
var node = callsign_struct[callsign];
return node;
}
var processCallsigns = func () {
callsign_struct = {};
var players = props.globals.getNode("ai/models").getChildren();
foreach (var player; players) {
if(player.getChild("valid") != nil and player.getChild("valid").getValue() == TRUE and player.getChild("callsign") != nil and player.getChild("callsign").getValue() != "" and player.getChild("callsign").getValue() != nil) {
var callsign = player.getChild("callsign").getValue();
callsign_struct[callsign] = player;
}
}
settimer(processCallsigns, 1.5);
}
processCallsigns();
var logTime = func{
#log time and date for outputing ucsv files for converting into KML files for google earth.
if (getprop("logging/log[0]/enabled") == TRUE and getprop("sim/time/utc/year") != nil) {
var date = getprop("sim/time/utc/year")~"/"~getprop("sim/time/utc/month")~"/"~getprop("sim/time/utc/day");
var time = getprop("sim/time/utc/hour")~":"~getprop("sim/time/utc/minute")~":"~getprop("sim/time/utc/second");
setprop("logging/date-log", date);
setprop("logging/time-log", time);
}
}
setlistener("/sim/multiplay/chat-history", incoming_listener, 0, 0);
+172
View File
@@ -145,6 +145,31 @@
<bool n="46" type="bool">false</bool>
</generic>
</multiplay>
<menubar>
<default>
<menu n="100">
<label>Missile-frigate</label>
<enabled type="bool">true</enabled>
<item>
<label>Reload</label>
<binding>
<command>nasal</command>
<script>
fire_control.reload();
</script>
</binding>
</item>
<item>
<label>Targets</label>
<name>enemies</name>
<binding>
<command>dialog-show</command>
<dialog-name>enemies</dialog-name>
</binding>
</item>
</menu>
</default>
</menubar>
<aircraft-data>
<!-- Properties that get saved to persist locally between FG sessions -->
@@ -302,6 +327,132 @@
</controls>
<payload>
<weight n="0">
<name>Main Store</name>
<weight-lb alias="/fdm/jsbsim/inertia/pointmass-weight-lbs[1]"/>
<selected>none</selected>
<opt>
<name>KN-06</name>
<lbs>50</lbs>
</opt>
</weight>
<armament>
<models type="string">Aircraft/fleet/Models/Armament/Weapons/</models>
<modelsUseCase type="bool">true</modelsUseCase>
<modelsUpperCase type="bool">true</modelsUpperCase>
<MP-lat type="string">rotors/main/blade[0]/flap-deg</MP-lat>
<MP-lon type="string">rotors/main/blade[1]/flap-deg</MP-lon>
<MP-alt type="string">rotors/main/blade[2]/flap-deg</MP-alt>
<hit-interpolation type="bool">true</hit-interpolation>
<pylon-offset type="int">1</pylon-offset>
<pylon-stations>controls/armament</pylon-stations>
<station-name type="string">station</station-name>
<msg type="bool">true</msg>
<damage type="bool">true</damage>
<kn-06>
<vol-search type="double">0.00</vol-search>
<vol-track type="double">0.15</vol-track> <!-- -->
<vol-track-weak type="double">0.1</vol-track-weak> <!-- -->
<guidance type="string">radar</guidance>
<navigation type="string">APN</navigation> <!-- -->
<all-aspect type="bool">true</all-aspect>
<max-fire-range-nm type="int">85</max-fire-range-nm>
<FCS-field-deg type="int">360</FCS-field-deg>
<seeker-field-deg type="int">220</seeker-field-deg><!-- since launched vertical, it cannot be too small -->
<max-g type="int">22</max-g>
<thrust-lbf-stage-1 type="double">90000</thrust-lbf-stage-1>
<thrust-lbf-stage-2 type="double">77000</thrust-lbf-stage-2> <!-- max 2000 m/s speed, 93 NM range -->
<stage-1-duration-sec type="double">0.25</stage-1-duration-sec>
<stage-2-duration-sec type="double">8.0</stage-2-duration-sec>
<weight-launch-lbs>3920</weight-launch-lbs>
<weight-warhead-lbs>315</weight-warhead-lbs>
<weight-fuel-lbm>2800</weight-fuel-lbm> <!-- -->
<drag-coeff type="double">0.20</drag-coeff> <!-- max 2000 m/s speed, 93 NM range -->
<cross-section-sqft type="double">2.11349</cross-section-sqft>
<arming-time-sec type="double">2</arming-time-sec>
<min-speed-for-guiding-mach type="double">0.25</min-speed-for-guiding-mach>
<self-destruct-time-sec type="double">160</self-destruct-time-sec>
<self-destruct-at-lock-lost type="bool">true</self-destruct-at-lock-lost>
<seeker-angular-speed-dps type="double">3000</seeker-angular-speed-dps>
<loft-altitude type="int">75000</loft-altitude>
<min-fire-range-nm type="double">0.85</min-fire-range-nm>
<max-report-distance type="double">200</max-report-distance> <!-- -->
<rail type="bool">true</rail>
<rail-length-m type="double">7.5</rail-length-m>
<rail-point-forward type="bool">false</rail-point-forward>
<rail-pitch-deg type="double">90</rail-pitch-deg> <!-- new -->
<chaff-resistance type="double">0.95</chaff-resistance>
<proportionality-constant type="double">3</proportionality-constant>
<class type="string">A</class>
<fire-msg>Bird away</fire-msg>
</kn-06>
<!-- test: SAM -->
<test>
<sound-on-off type="bool">false</sound-on-off>
<sound-volume type="double">0.0</sound-volume>
<sound-fire-on-off type="bool">false</sound-fire-on-off>
<vol-search type="double">0.00</vol-search>
<guidance type="string">radar</guidance>
<all-aspect type="bool">true</all-aspect>
<max-fire-range-nm type="int">38.8</max-fire-range-nm>
<FCS-field-deg type="int">360</FCS-field-deg>
<seeker-field-deg type="int">360</seeker-field-deg>
<max-g type="int">30</max-g>
<thrust-lbf-stage-1 type="double">9000</thrust-lbf-stage-1>
<thrust-lbf-stage-2 type="double">1500</thrust-lbf-stage-2>
<stage-1-duration-sec type="double">4.0</stage-1-duration-sec>
<stage-2-duration-sec type="double">15.0</stage-2-duration-sec>
<weight-launch-lbs>291</weight-launch-lbs>
<weight-warhead-lbs>44</weight-warhead-lbs>
<drag-coeff type="double">0.5</drag-coeff>
<drag-area type="double">0.2739</drag-area>
<searcher-beam-width type="double">3.0</searcher-beam-width>
<arming-time-sec type="double">1.6</arming-time-sec>
<min-speed-for-guiding-mach type="double">0.9</min-speed-for-guiding-mach>
<self-destruct-time-sec type="double">90</self-destruct-time-sec>
<seeker-angular-speed-dps type="double">30</seeker-angular-speed-dps>
<loft-altitude>0</loft-altitude>
<min-fire-range-nm type="double">0.35</min-fire-range-nm>
<rail type="bool">true</rail>
<rail-length-m type="double">5</rail-length-m>
<rail-point-forward type="bool">false</rail-point-forward>
<class type="string">A/A</class>
<fire-msg>Chickenbeater</fire-msg>
</test>
<!--<test>
<sound-on-off type="bool">false</sound-on-off>
<sound-volume type="double">0.0</sound-volume>
<vol-search type="double">0.03</vol-search>
<guidance type="string">radar</guidance>
<all-aspect type="bool">true</all-aspect>
<max-fire-range-nm type="double">100</max-fire-range-nm>
<FCS-field-deg type="int">25</FCS-field-deg>
<seeker-field-deg type="int">180</seeker-field-deg>
<max-g type="int">20</max-g>
<max-launch-g type="int">7</max-launch-g>
<thrust-lbf-stage-1 type="double">150</thrust-lbf-stage-1>
<thrust-lbf-stage-2 type="double">0.0</thrust-lbf-stage-2>
<stage-1-duration-sec type="double">200.5</stage-1-duration-sec>
<stage-2-duration-sec type="double">1.0</stage-2-duration-sec>
<weight-launch-lbs type="double">179</weight-launch-lbs>
<weight-warhead-lbs type="double">20.8</weight-warhead-lbs>
<drag-coeff type="double">0.5</drag-coeff>
<drag-area type="double">0.143</drag-area>
<searcher-beam-width type="double">2.0</searcher-beam-width>
<arming-time-sec type="double">1.4</arming-time-sec>
<min-speed-for-guiding-mach type="double">0.4</min-speed-for-guiding-mach>
<self-destruct-time-sec type="double">250</self-destruct-time-sec>
<seeker-angular-speed-dps type="double">50</seeker-angular-speed-dps>
<loft-altitude>100</loft-altitude>
<min-fire-range-nm type="double">0.2</min-fire-range-nm>
<rail type="bool">false</rail>
<class type="string">A/G</class>
</test>-->
</armament>
</payload>
<rotors>
<main>
<blade n="0">
@@ -331,6 +482,27 @@
<e12 userarchive="y" type="string">SNOWY1</e12>
</enemies>
<nasal>
<carrier>
<file>Aircraft/fleet/Nasal/fdm.nas</file>
</carrier>
<damage>
<file>Aircraft/fleet/Nasal/damage.nas</file>
</damage>
<radar_logic>
<file>Aircraft/fleet/Nasal/radar-logic.nas</file>
</radar_logic>
<vector>
<file>Aircraft/fleet/Nasal/vector.nas</file>
</vector>
<armament>
<file>Aircraft/fleet/Nasal/guided-missiles.nas</file>
</armament>
<fire_control>
<file>Aircraft/fleet/Nasal/fire-control.nas</file>
</fire_control>
</nasal>
<input>
<mice include="Sim/mice.xml"/>
</input>