Skip to content

Commit

Permalink
Files: Auto-Update Damage Libraries
Browse files Browse the repository at this point in the history
damage 1.4.12->1.4.13
  • Loading branch information
github-actions[bot] committed Oct 29, 2024
1 parent 4d71c4c commit 3a70228
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions Nasal/Damage/damage.nas
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var mlw_max=getprop("payload/d-config/mlw_max"); #
var auto_flare_caller = getprop("payload/d-config/auto_flare_caller"); # If damage.nas should detect flare releases, or if function is called from somewhere in aircraft
############################################################################################################################

var preAlphaKey = "ABC";# for hash keys that could start with number, which is not allowed.
srand();
var hp = hp_max;
setprop("sam/damage", math.max(0,100*hp/hp_max));#used in HUD
Expand Down Expand Up @@ -174,6 +175,7 @@ var warheads = {
var AIR_RADAR = "air";

var radar_signatures = {
# be careful these keys do not start with a number char
"unknown-model": AIR_RADAR,
"f-14b": AIR_RADAR,
"F-14D": AIR_RADAR,
Expand Down Expand Up @@ -328,7 +330,7 @@ var DamageRecipient =
var wh = id2warhead[DamageRecipient.emesaryID2typeID(notification.SecondaryKind)][4];
var tacID = left(md5(notification.Callsign~notification.UniqueIdentity~wh),6);
var elapsed = getprop("sim/time/elapsed-sec");
lastSeenTacObject[tacID] = elapsed;
lastSeenTacObject[preAlphaKey ~ tacID] = elapsed;
if (notification.Kind == MOVE) {
var target = ",Color=Red";
if (wh=="Flare") wh=wh~",Type=Flare";
Expand Down Expand Up @@ -381,7 +383,7 @@ var DamageRecipient =
if (tacview.starttime) {
var tacID = left(md5(notification.Callsign~notification.UniqueIdentity~typ[4]),6);
var elapsed = getprop("sim/time/elapsed-sec");
lastSeenTacObject[tacID] = elapsed;
lastSeenTacObject[preAlphaKey ~ tacID] = elapsed;
if (notification.Kind == DESTROY) {
thread.lock(tacview.mutexWrite);
tacview.write("#" ~ (systime() - tacview.starttime)~"\n");
Expand Down Expand Up @@ -412,10 +414,10 @@ var DamageRecipient =

# Missile launch warning:
if (thrustOn) {
var launch = launched[notification.Callsign~notification.UniqueIdentity];
var launch = launched[preAlphaKey ~ notification.Callsign~notification.UniqueIdentity];
if (launch == nil or elapsed - launch > 300) {
launch = elapsed;
launched[notification.Callsign~notification.UniqueIdentity] = launch;
launched[preAlphaKey ~ notification.Callsign~notification.UniqueIdentity] = launch;
if (notification.Position.direct_distance_to(ownPos)*M2NM < mlw_max) {
setprop("payload/armament/MLW-bearing", bearing);
setprop("payload/armament/MLW-launcher", notification.Callsign);
Expand Down Expand Up @@ -443,7 +445,7 @@ var DamageRecipient =
if (notification.Callsign != nil) setprop("payload/armament/MAW-semiactive-callsign", notification.Callsign);# resets every 1 seconds
}
MAW_elapsed = elapsed;
var appr = approached[notification.Callsign~notification.UniqueIdentity];
var appr = approached[preAlphaKey ~ notification.Callsign~notification.UniqueIdentity];
if (appr == nil or elapsed - appr > 450) {
if (radarOn) {
#printf("Missile Approach Warning from %03d degrees.", bearing);
Expand All @@ -454,7 +456,7 @@ var DamageRecipient =
damageLog.push(sprintf("Missile Approach Warning from %s.", notification.Callsign));
if (rwr_to_screen) screen.log.write(sprintf("Missile Approach Warning (semi-active)."), 1,0.5,0);# temporary till someone models a RWR in RIO seat
}
approached[notification.Callsign~notification.UniqueIdentity] = elapsed;
approached[preAlphaKey ~ notification.Callsign~notification.UniqueIdentity] = elapsed;
if (m28_auto) mig28.engagedBy(notification.Callsign, 1);
}
return emesary.Transmitter.ReceiptStatus_OK;
Expand Down Expand Up @@ -1381,7 +1383,7 @@ var nearby_explosion_b = func {

var callsign_struct = {};
var getCallsign = func (callsign) {
var node = callsign_struct[callsign];
var node = callsign_struct[preAlphaKey ~ callsign];
return node;
}

Expand All @@ -1406,7 +1408,7 @@ var processCallsigns = func () {
if(multiplayer.ignore[callsign] == 1) {
continue;
}
callsign_struct[callsign] = player;
callsign_struct[preAlphaKey ~ callsign] = player;
var str6 = player.getNode("sim/multiplay/generic/string[6]");
if (str6 != nil and str6.getValue() != nil and str6.getValue() != "" and size(""~str6.getValue())==4 and left(md5(myCallsign),4) == str6.getValue()) {
painted = 1;
Expand All @@ -1429,7 +1431,7 @@ var processCallsigns = func () {
if (elapsed - lastSeenTacObject[key] > 30) {
thread.lock(tacview.mutexWrite);
tacview.write("#" ~ (systime() - tacview.starttime)~"\n");
tacview.write("-"~key~"\n");
tacview.write("-"~substr(key,size(preAlphaKey))~"\n");
thread.unlock(tacview.mutexWrite);
} else {
new_lastSeenTacObject[key] = lastSeenTacObject[key];
Expand Down
2 changes: 1 addition & 1 deletion oprf-versions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"damage": {
"version": "1.4.12",
"version": "1.4.13",
"path": "Nasal/Damage/damage.nas"
},
"armament-notification": {
Expand Down

0 comments on commit 3a70228

Please sign in to comment.