-- -- Geblaese -- This is the specialization for Geblaese -- -- M@D Author Headshot XXL -- M@D date 06.06.2009 -- -- > Copyright (C) Headshot XXL - www.planet-ls.de < -- Geblaese = {}; function Geblaese.prerequisitesPresent(specializations) return SpecializationUtil.hasSpecialization(Attachable, specializations); end; function Geblaese:load(xmlFile) self.onPlayerTrigger = Geblaese.onPlayerTrigger; self.playerTrigger = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.playerTrigger#index")); self.playerInRange = false; if self.playerTrigger ~= nil then addTrigger(self.playerTrigger, "onPlayerTrigger", self); end; self.trigger = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.trigger#index")); self.triggerObject = TipTrigger:new(self.trigger); table.insert(g_currentMission.tipTriggers, self.triggerObject); self.plane = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.plane#index")); local rohrtrans1Node = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.rohrtrans1#index")); if rohrtrans1Node ~= nil then self.rohrtrans1 = {}; self.rohrtrans1.node = rohrtrans1Node; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rohrtrans1#minTrans")); self.rohrtrans1.minTrans = {}; self.rohrtrans1.minTrans[1] = Utils.getNoNil(x, 0); self.rohrtrans1.minTrans[2] = Utils.getNoNil(y, 0); self.rohrtrans1.minTrans[3] = Utils.getNoNil(z, 0); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rohrtrans1#maxTrans")); self.rohrtrans1.maxTrans = {}; self.rohrtrans1.maxTrans[1] = Utils.getNoNil(x, 0); self.rohrtrans1.maxTrans[2] = Utils.getNoNil(y, 0); self.rohrtrans1.maxTrans[3] = Utils.getNoNil(z, 0); self.rohrtrans1.transTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rohrtrans1#transTime"), 2)*1000; self.rohrtrans1.touchTransLimit = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rohrtrans1#touchTransLimit"), 10); end; local rohrscale1Node = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.rohrscale1#index")); if rohrscale1Node ~= nil then self.rohrscale1 = {}; self.rohrscale1.node = rohrscale1Node; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rohrscale1#minScale")); self.rohrscale1.minScale = {}; self.rohrscale1.minScale[1] = Utils.getNoNil(x, 0); self.rohrscale1.minScale[2] = Utils.getNoNil(y, 0); self.rohrscale1.minScale[3] = Utils.getNoNil(z, 0); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rohrscale1#maxScale")); self.rohrscale1.maxScale = {}; self.rohrscale1.maxScale[1] = Utils.getNoNil(x, 0); self.rohrscale1.maxScale[2] = Utils.getNoNil(y, 0); self.rohrscale1.maxScale[3] = Utils.getNoNil(z, 0); self.rohrscale1.ScaleTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rohrscale1#ScaleTime"), 2)*1000; self.rohrscale1.touchScaleLimit = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rohrscale1#touchScaleLimit"), 10); end; local rohrrot1Node = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.rohrrot1#index")); if rohrrot1Node ~= nil then self.rohrrot1 = {}; self.rohrrot1.node = rohrrot1Node; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rohrrot1#minRot")); self.rohrrot1.minRot = {}; self.rohrrot1.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rohrrot1.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rohrrot1.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rohrrot1#maxRot")); self.rohrrot1.maxRot = {}; self.rohrrot1.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rohrrot1.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rohrrot1.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rohrrot1.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rohrrot1#rotTime"), 2)*1000; self.rohrrot1.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rohrrot1#touchRotLimit"), 10)); end; local geblaeseSound = getXMLString(xmlFile, "vehicle.geblaeseSound#file"); if geblaeseSound ~= nil and geblaeseSound ~= "" then geblaeseSound = Utils.getFilename(geblaeseSound, self.baseDirectory); self.geblaeseSoundPitchOffset = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.geblaeseSound#pitchOffset"), 0); self.geblaeseSoundRadius = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.geblaeseSound#radius"), 50); self.geblaeseSoundInnerRadius = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.geblaeseSound#innerRadius"), 10); self.geblaeseSoundVolume = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.geblaeseSound#volume"), 1); self.geblaeseSound = createAudioSource("geblaeseSound", geblaeseSound, self.geblaeseSoundRadius, self.geblaeseSoundInnerRadius, self.geblaeseSoundVolume, 0); link(self.components[1].node, self.geblaeseSound); setVisibility(self.geblaeseSound, false); end; self.isOn = 0; self.vis = 0; end; function Geblaese:delete() for i=1, table.getn(g_currentMission.tipTriggers) do if g_currentMission.tipTriggers[i] == self.triggerObject then table.remove(g_currentMission.tipTriggers, i); end; end; if self.playerTrigger ~= nil then removeTrigger(self.playerTrigger); end; end; function Geblaese:loadFromAttributesAndNodes(xmlFile, key, resetVehicles) local rohrtrans1x = getXMLFloat(xmlFile, key.."#rohrtrans1x"); local rohrtrans1y = getXMLFloat(xmlFile, key.."#rohrtrans1y"); local rohrtrans1z = getXMLFloat(xmlFile, key.."#rohrtrans1z"); local rohrscale1x = getXMLFloat(xmlFile, key.."#rohrscale1x"); local rohrscale1y = getXMLFloat(xmlFile, key.."#rohrscale1y"); local rohrscale1z = getXMLFloat(xmlFile, key.."#rohrscale1z"); local rohrrot1x = getXMLFloat(xmlFile, key.."#rohrrot1x"); local rohrrot1y = getXMLFloat(xmlFile, key.."#rohrrot1y"); local rohrrot1z = getXMLFloat(xmlFile, key.."#rohrrot1z"); self.vis = getXMLFloat(xmlFile, key.."#vis"); if rohrtrans1x ~= nil and rohrtrans1y ~= nil and rohrtrans1z ~= nil and rohrscale1x ~= nil and rohrscale1y ~= nil and rohrscale1z ~= nil and rohrrot1x ~= nil and rohrrot1y ~= nil and rohrrot1z ~= nil then setTranslation(self.rohrtrans1.node, rohrtrans1x, rohrtrans1y, rohrtrans1z); setScale(self.rohrscale1.node, rohrscale1x, rohrscale1y, rohrscale1z); setRotation(self.rohrrot1.node, rohrrot1x, rohrrot1y, rohrrot1z); end; return BaseMission.VEHICLE_LOAD_OK; end; function Geblaese:getSaveAttributesAndNodes(nodeIdent) local rohrtrans1x, rohrtrans1y, rohrtrans1z = getTranslation(self.rohrtrans1.node); local rohrscale1x, rohrscale1y, rohrscale1z = getScale(self.rohrscale1.node); local rohrrot1x, rohrrot1y, rohrrot1z = getRotation(self.rohrrot1.node); local attributes = 'rohrtrans1x="'..rohrtrans1x..'" rohrtrans1y="'..rohrtrans1y..'" rohrtrans1z="'..rohrtrans1z..'" rohrscale1x="'..rohrscale1x..'" rohrscale1y="'..rohrscale1y..'" rohrscale1z="'..rohrscale1z..'" rohrrot1x="'..rohrrot1x..'" rohrrot1y="'..rohrrot1y..'" rohrrot1z="'..rohrrot1z..'" vis="'..self.vis..'"'; return attributes, nil; end; function Geblaese:mouseEvent(posX, posY, isDown, isUp, button) end; function Geblaese:keyEvent(unicode, sym, modifier, isDown) end; function Geblaese:update(dt) if self.playerInRange then if InputBinding.hasEvent(InputBinding.GEBLAESEVIS) then self.vis = self.vis+1; end; if self.vis == 1 then if InputBinding.hasEvent(InputBinding.GEBLAESEON) then self.isOn = self.isOn+1; end; if InputBinding.isPressed(InputBinding.GEBLAESEROHRUP) then local x, y, z = getTranslation(self.rohrtrans1.node); local trans = {x,y,z}; local newTrans = Utils.getMovedLimitedValues(trans, self.rohrtrans1.maxTrans, self.rohrtrans1.minTrans, 3, self.rohrtrans1.transTime, dt, true); setTranslation(self.rohrtrans1.node, unpack(newTrans)); end; if InputBinding.isPressed(InputBinding.GEBLAESEROHRDOWN) then local x, y, z = getTranslation(self.rohrtrans1.node); local trans = {x,y,z}; local newTrans = Utils.getMovedLimitedValues(trans, self.rohrtrans1.maxTrans, self.rohrtrans1.minTrans, 3, self.rohrtrans1.transTime, dt, false); setTranslation(self.rohrtrans1.node, unpack(newTrans)); end; if InputBinding.isPressed(InputBinding.GEBLAESEROHRFORWARD) then local x, y, z = getScale(self.rohrscale1.node); local scale = {x,y,z}; local newScale = Utils.getMovedLimitedValues(scale, self.rohrscale1.maxScale, self.rohrscale1.minScale, 3, self.rohrscale1.ScaleTime, dt, true); setScale(self.rohrscale1.node, unpack(newScale)); end; if InputBinding.isPressed(InputBinding.GEBLAESEROHRBACK) then local x, y, z = getScale(self.rohrscale1.node); local scale = {x,y,z}; local newScale = Utils.getMovedLimitedValues(scale, self.rohrscale1.maxScale, self.rohrscale1.minScale, 3, self.rohrscale1.ScaleTime, dt, false); setScale(self.rohrscale1.node, unpack(newScale)); end; if InputBinding.isPressed(InputBinding.GEBLAESEROHRROTLEFT) then local x, y, z = getRotation(self.rohrrot1.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rohrrot1.maxRot, self.rohrrot1.minRot, 3, self.rohrrot1.rotTime, dt, false); setRotation(self.rohrrot1.node, unpack(newRot)); end; if InputBinding.isPressed(InputBinding.GEBLAESEROHRROTRIGHT) then local x, y, z = getRotation(self.rohrrot1.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rohrrot1.maxRot, self.rohrrot1.minRot, 3, self.rohrrot1.rotTime, dt, true); setRotation(self.rohrrot1.node, unpack(newRot)); end; if self.isOn == 2 then g_currentMission:addExtraPrintText("Taste".. " " ..InputBinding.getButtonKeyName(InputBinding.GEBLAESEON).. ": " ..g_i18n:getText("GEBLAESE1")); elseif self.isOn == 0 then g_currentMission:addExtraPrintText("Taste".. " " ..InputBinding.getButtonKeyName(InputBinding.GEBLAESEON).. ": " ..g_i18n:getText("GEBLAESE2")); end; g_currentMission:addExtraPrintText("Taste".. " " ..InputBinding.getButtonKeyName(InputBinding.GEBLAESEROHRUP).. "/" ..InputBinding.getButtonKeyName(InputBinding.GEBLAESEROHRDOWN).. ": " ..g_i18n:getText("GEBLAESE3")); g_currentMission:addExtraPrintText("Taste".. " " ..InputBinding.getButtonKeyName(InputBinding.GEBLAESEROHRFORWARD).. "/" ..InputBinding.getButtonKeyName(InputBinding.GEBLAESEROHRBACK).. ": " ..g_i18n:getText("GEBLAESE4")); g_currentMission:addExtraPrintText("Taste".. " " ..InputBinding.getButtonKeyName(InputBinding.GEBLAESEROHRROTLEFT).. "/" ..InputBinding.getButtonKeyName(InputBinding.GEBLAESEROHRROTRIGHT).. ": " ..g_i18n:getText("GEBLAESE5")); end; if self.vis == 1 then g_currentMission:addExtraPrintText("Taste".. " " ..InputBinding.getButtonKeyName(InputBinding.GEBLAESEVIS).. ": " ..g_i18n:getText("GEBLAESE6")); else g_currentMission:addExtraPrintText("Taste".. " " ..InputBinding.getButtonKeyName(InputBinding.GEBLAESEVIS).. ": " ..g_i18n:getText("GEBLAESE7")); end; end; if self.vis == 2 then self.vis = 0; self.isOn = 0; end; if self.vis == 1 then setVisibility(self.rohrtrans1.node, true); setVisibility(self.plane, true); else setVisibility(self.rohrtrans1.node, false); setVisibility(self.plane, false); end; if self.isOn == 1 then setVisibility(self.geblaeseSound, true); end; if self.isOn == 2 then setVisibility(self.geblaeseSound, false); self.isOn = 0; end; end; function Geblaese:draw() end; function Geblaese:onPlayerTrigger(triggerId, otherId, onEnter, onLeave, onStay, otherShapeId) if onEnter or onLeave then if otherId == Player.rootNode then if onEnter then self.playerInRange = true; elseif onLeave then self.playerInRange = false; end; end; end; end;