| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- //-----------------------------------------------------------------------------
- // Copyright (c) 2012 GarageGames, LLC
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to
- // deal in the Software without restriction, including without limitation the
- // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- // sell copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- // IN THE SOFTWARE.
- //-----------------------------------------------------------------------------
- function CheetahCar::onAdd(%this, %obj)
- {
- Parent::onAdd(%this, %obj);
- %obj.setWheelTire(0,CheetahCarTire);
- %obj.setWheelTire(1,CheetahCarTire);
- %obj.setWheelTire(2,CheetahCarTireRear);
- %obj.setWheelTire(3,CheetahCarTireRear);
- // Setup the car with some tires & springs
- for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--)
- {
- %obj.setWheelPowered(%i, true);
- %obj.setWheelSpring(%i, CheetahCarSpring);
- }
- // Steer with the front tires
- %obj.setWheelSteering(0, 1);
- %obj.setWheelSteering(1, 1);
- // Add tail lights
- %obj.rightBrakeLight = new PointLight()
- {
- radius = "1";
- isEnabled = "0";
- color = "1 0 0.141176 1";
- brightness = "2";
- castShadows = "1";
- priority = "1";
- animate = "0";
- animationPeriod = "1";
- animationPhase = "1";
- flareScale = "1";
- attenuationRatio = "0 1 1";
- shadowType = "DualParaboloidSinglePass";
- texSize = "512";
- overDarkFactor = "2000 1000 500 100";
- shadowDistance = "400";
- shadowSoftness = "0.15";
- numSplits = "1";
- logWeight = "0.91";
- fadeStartDistance = "0";
- lastSplitTerrainOnly = "0";
- representedInLightmap = "0";
- shadowDarkenColor = "0 0 0 -1";
- includeLightmappedGeometryInShadow = "0";
- rotation = "1 0 0 0";
- canSave = "1";
- canSaveDynamicFields = "1";
- splitFadeDistances = "10 20 30 40";
- };
- %obj.leftBrakeLight = new PointLight()
- {
- radius = "1";
- isEnabled = "0";
- color = "1 0 0.141176 1";
- brightness = "2";
- castShadows = "1";
- priority = "1";
- animate = "0";
- animationPeriod = "1";
- animationPhase = "1";
- flareScale = "1";
- attenuationRatio = "0 1 1";
- shadowType = "DualParaboloidSinglePass";
- texSize = "512";
- overDarkFactor = "2000 1000 500 100";
- shadowDistance = "400";
- shadowSoftness = "0.15";
- numSplits = "1";
- logWeight = "0.91";
- fadeStartDistance = "0";
- lastSplitTerrainOnly = "0";
- representedInLightmap = "0";
- shadowDarkenColor = "0 0 0 -1";
- includeLightmappedGeometryInShadow = "0";
- rotation = "1 0 0 0";
- canSave = "1";
- canSaveDynamicFields = "1";
- splitFadeDistances = "10 20 30 40";
- };
- // Mount a ShapeBaseImageData
- %didMount = %obj.mountImage(TurretImage, %this.turretSlot);
- // Mount the brake lights
- %obj.mountObject(%obj.rightBrakeLight, %this.rightBrakeSlot);
- %obj.mountObject(%obj.leftBrakeLight, %this.leftBrakeSlot);
- }
- function CheetahCar::onRemove(%this, %obj)
- {
- Parent::onRemove(%this, %obj);
- if(isObject(%obj.rightBrakeLight))
- %obj.rightBrakeLight.delete();
- if(isObject(%obj.leftBrakeLight))
- %obj.leftBrakeLight.delete();
- if(isObject(%obj.turret))
- %obj.turret.delete();
- }
- function serverCmdtoggleBrakeLights(%client)
- {
- %car = %client.player.getControlObject();
- if (%car.getClassName() $= "WheeledVehicle")
- {
- if(%car.rightBrakeLight.isEnabled)
- {
- %car.rightBrakeLight.setLightEnabled(0);
- %car.leftBrakeLight.setLightEnabled(0);
- }
- else
- {
- %car.rightBrakeLight.setLightEnabled(1);
- %car.leftBrakeLight.setLightEnabled(1);
- }
- }
- }
- // Callback invoked when an input move trigger state changes when the CheetahCar
- // is the control object
- function CheetahCar::onTrigger(%this, %obj, %index, %state)
- {
- // Pass trigger states on to TurretImage (to fire weapon)
- switch ( %index )
- {
- case 0: %obj.setImageTrigger( %this.turretSlot, %state );
- case 1: %obj.setImageAltTrigger( %this.turretSlot, %state );
- }
- }
- function TurretImage::onMount(%this, %obj, %slot)
- {
- // Load the gun
- %obj.setImageAmmo(%slot, true);
- }
|