574
edits
m (Necolatis moved page Crash and stress damage system for JSBSim to Crash and stress damage system: Also for Yasim) |
m (→How to install the current system on an aircraft: Version 0.12) |
||
Line 20: | Line 20: | ||
# | # | ||
# | # | ||
# Version 0. | # Version 0.12 | ||
# | # | ||
# License: | # License: | ||
Line 51: | Line 51: | ||
m.wingLoadLimitLower = nil; | m.wingLoadLimitLower = nil; | ||
m._looptimer = maketimer(0, m, m._loop); | m._looptimer = maketimer(0, m, m._loop); | ||
m.repairTimer = maketimer(10.0, m, CrashAndStress._finishRepair); | |||
m.repairTimer.singleShot = 1; | |||
m.soundWaterTimer = maketimer(3, m, CrashAndStress._impactSoundWaterEnd); | |||
m.soundWaterTimer.singleShot = 1; | |||
m.soundTimer = maketimer(3, m, CrashAndStress._impactSoundEnd); | |||
m.soundTimer.singleShot = 1; | |||
m.explodeTimer = maketimer(3, m, CrashAndStress._explodeEnd); | |||
m.explodeTimer.singleShot = 1; | |||
m.stressTimer = maketimer(3, m, CrashAndStress._stressDamageEnd); | |||
m.stressTimer.singleShot = 1; | |||
m.input = { | m.input = { | ||
Line 113: | Line 128: | ||
isStarted: func () { | isStarted: func () { | ||
return me.inService; | return me.inService; | ||
}, | }, | ||
# accepts a vector with failure mode IDs, they will fail when wings break off. | # accepts a vector with failure mode IDs, they will fail when wings break off. | ||
Line 192: | Line 192: | ||
me._looptimer.stop(); | me._looptimer.stop(); | ||
} | } | ||
}, | |||
# repair the aircaft | |||
repair: func () { | |||
var failure_modes = FailureMgr._failmgr.failure_modes; | |||
var mode_list = keys(failure_modes); | |||
foreach(var failure_mode_id; mode_list) { | |||
FailureMgr.set_failure_level(failure_mode_id, 0); | |||
} | |||
me.wingsAttached = TRUE; | |||
me.exploded = FALSE; | |||
me.lastMessageTime = 0; | |||
me.repairing = TRUE; | |||
me.repairTimer.restart(10.0); | |||
}, | |||
_finishRepair: func () { | |||
me.repairing = FALSE; | |||
}, | }, | ||
_identifyGears: func (gears) { | _identifyGears: func (gears) { | ||
Line 207: | Line 225: | ||
} | } | ||
}, | }, | ||
_isStructureInContact: func () { | _isStructureInContact: func () { | ||
foreach(var structure; me.wowStructure) { | foreach(var structure; me.wowStructure) { | ||
Line 261: | Line 276: | ||
var lon = me.input.lon.getValue(); | var lon = me.input.lon.getValue(); | ||
var info = geodinfo(lat, lon); | var info = geodinfo(lat, lon); | ||
var solid = info[1] == nil?TRUE:info[1].solid; | var solid = info == nil?TRUE:(info[1] == nil?TRUE:info[1].solid); | ||
var speed = me._calcGroundSpeed(); | var speed = me._calcGroundSpeed(); | ||
Line 288: | Line 303: | ||
} | } | ||
if(solid == TRUE) { | if(solid == TRUE) { | ||
me._impactSoundBegin(speed); | me._impactSoundBegin(speed); | ||
} else { | } else { | ||
me._impactSoundWaterBegin(speed); | me._impactSoundWaterBegin(speed); | ||
} | } | ||
Line 298: | Line 311: | ||
if (speed > 5) {#check if sound already running? | if (speed > 5) {#check if sound already running? | ||
me.input.wCrashOn.setValue(1); | me.input.wCrashOn.setValue(1); | ||
me.soundWaterTimer.restart(3); | |||
} | } | ||
}, | }, | ||
Line 308: | Line 320: | ||
if (speed > 5) { | if (speed > 5) { | ||
me.input.crashOn.setValue(1); | me.input.crashOn.setValue(1); | ||
me.soundTimer.restart(3); | |||
} | } | ||
}, | }, | ||
Line 326: | Line 337: | ||
me._output("Aircraft exploded.", TRUE); | me._output("Aircraft exploded.", TRUE); | ||
me.explodeTimer.restart(3); | |||
}, | }, | ||
_explodeEnd: func () { | _explodeEnd: func () { | ||
Line 340: | Line 350: | ||
me.wingsAttached = FALSE; | me.wingsAttached = FALSE; | ||
me.stressTimer.restart(3); | |||
}, | }, | ||
_stressDamageEnd: func () { | _stressDamageEnd: func () { | ||
Line 375: | Line 385: | ||
var wingload = gForce * weight; | var wingload = gForce * weight; | ||
var broken = FALSE; | var broken = FALSE; | ||
Line 523: | Line 532: | ||
# use: | # use: | ||
var crashCode = CrashAndStress.new([0,1,2], {"weightLbs":30000, "maxG": 12}, [ | var crashCode = CrashAndStress.new([0,1,2], {"weightLbs":30000, "maxG": 12}, ["controls/flight/aileron", "controls/flight/elevator"]); | ||
crashCode.start(); | crashCode.start(); | ||
edits