home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 58 / pcpp58b_TRIBES.iso / Tribes / base / scripts.vol / staticshape.cs < prev    next >
Encoding:
Text File  |  1998-12-16  |  16.3 KB  |  639 lines

  1. //------------------------------------------------------------------------
  2. // Generic static shapes
  3. //------------------------------------------------------------------------
  4.  
  5.  
  6. //------------------------------------------------------------------------
  7. // Default power animation behavior for all static shapes
  8.  
  9. function StaticShape::onPower(%this,%power,%generator)
  10. {
  11.     if (%power) 
  12.         GameBase::playSequence(%this,0,"power");
  13.     else 
  14.         GameBase::stopSequence(%this,0);
  15. }
  16.  
  17. function StaticShape::onEnabled(%this)
  18. {
  19.     if (GameBase::isPowered(%this)) 
  20.         GameBase::playSequence(%this,0,"power");
  21. }
  22.  
  23. function StaticShape::onDisabled(%this)
  24. {
  25.     GameBase::stopSequence(%this,0);
  26. }
  27.  
  28. function StaticShape::onDestroyed(%this)
  29. {
  30.     GameBase::stopSequence(%this,0);
  31.    StaticShape::objectiveDestroyed(%this);
  32.     calcRadiusDamage(%this, $DebrisDamageType, 2.5, 0.05, 25, 13, 2, 0.40, 
  33.         0.1, 250, 100); 
  34. }
  35.  
  36. function StaticShape::onDamage(%this,%type,%value,%pos,%vec,%mom,%object)
  37. {
  38.     %damageLevel = GameBase::getDamageLevel(%this);
  39.     %dValue = %damageLevel + %value;
  40.    %this.lastDamageObject = %object;
  41.    %this.lastDamageTeam = GameBase::getTeam(%object);
  42.     if(GameBase::getTeam(%this) == GameBase::getTeam(%object)) {
  43.         %name = GameBase::getDataName(%this);
  44.         if(%name.className == Generator || %name.className == Station) { 
  45.             %TDS = $Server::TeamDamageScale;
  46.             %dValue = %damageLevel + %value * %TDS;
  47.             %disable = GameBase::getDisabledDamage(%this);
  48.             if(!$Server::TourneyMode && %dValue > %disable - 0.05) {
  49.             if(%damageLevel > %disable - 0.05)
  50.                return;
  51.             else
  52.                %dValue = %disable - 0.05;
  53.             }
  54.         }
  55.     }
  56.     GameBase::setDamageLevel(%this,%dValue);
  57. }
  58.  
  59. function StaticShape::shieldDamage(%this,%type,%value,%pos,%vec,%mom,%object)
  60. {
  61.     %damageLevel = GameBase::getDamageLevel(%this);
  62.    %this.lastDamageObject = %object;
  63.    %this.lastDamageTeam = GameBase::getTeam(%object);
  64.     if (%this.shieldStrength) {
  65.         %energy = GameBase::getEnergy(%this);
  66.         %strength = %this.shieldStrength;
  67.         if (%type == $ShrapnelDamageType)
  68.             %strength *= 0.5;
  69.         else
  70.             if (%type == $MortarDamageType)
  71.                 %strength *= 0.25;
  72.         %absorb = %energy * %strength;
  73.         if (%value < %absorb) {
  74.             GameBase::setEnergy(%this,%energy - (%value / %strength));
  75.             %centerPos = getBoxCenter(%this);
  76.             %sphereVec = findPointOnSphere(getBoxCenter(%object),%centerPos,%vec,%this);
  77.             %centerPosX = getWord(%centerPos,0);
  78.             %centerPosY = getWord(%centerPos,1);
  79.             %centerPosZ = getWord(%centerPos,2);
  80.  
  81.             %pointX = getWord(%pos,0);
  82.             %pointY = getWord(%pos,1);
  83.             %pointZ = getWord(%pos,2);
  84.  
  85.             %newVecX = %centerPosX - %pointX;
  86.             %newVecY = %centerPosY - %pointY;
  87.             %newVecZ = %centerPosZ - %pointZ;
  88.             %norm = Vector::normalize(%newVecX @ " " @ %newVecY @ " " @ %newVecZ);
  89.             %zOffset = 0;
  90.             if(GameBase::getDataName(%this) == PulseSensor)
  91.                 %zOffset = (%pointZ-%centerPosZ) * 0.5;
  92.             GameBase::activateShield(%this,%sphereVec,%zOffset);
  93.         }
  94.         else {
  95.             GameBase::setEnergy(%this,0);
  96.             StaticShape::onDamage(%this,%type,%value - %absorb,%pos,%vec,%mom,%object);
  97.         }
  98.     }
  99.     else {
  100.         StaticShape::onDamage(%this,%type,%value,%pos,%vec,%mom,%object);
  101.     }
  102. }
  103.  
  104. StaticShapeData FlagStand
  105. {
  106.    description = "Flag Stand";
  107.     shapeFile = "flagstand";
  108.     visibleToSensor = false;
  109. };
  110.  
  111.  
  112. function calcRadiusDamage(%this,%type,%radiusRatio,%damageRatio,%forceRatio,
  113.     %rMax,%rMin,%dMax,%dMin,%fMax,%fMin) 
  114. {
  115.     %radius = GameBase::getRadius(%this);
  116.     if(%radius) {
  117.         %radius *= %radiusRatio;
  118.         %damageValue = %radius * %damageRatio;
  119.         %force = %radius * %forceRatio;
  120.         if(%radius > %rMax)
  121.             %radius = %rMax;
  122.         else if(%radius < %rMin)
  123.             %radius = %rMin;
  124.         if(%damageValue > %dMax)
  125.             %damageValue = %dMax; 
  126.         else if(%damageValue < %dMin)
  127.             %damageValue = %dMin;
  128.         if(%force > %fMax)
  129.             %force = %fMax; 
  130.         else if(%force < %fMin)
  131.             %force = %fMin;
  132.         GameBase::applyRadiusDamage(%type,getBoxCenter(%this), %radius,
  133.             %damageValue,%force,%this);
  134.     }
  135. }
  136.  
  137.  
  138.  
  139. function FlagStand::onDamage()
  140. {
  141. }
  142.  
  143. //------------------------------------------------------------------------
  144. // Generators
  145. //------------------------------------------------------------------------
  146.  
  147. function Generator::onEnabled(%this)
  148. {
  149.     GameBase::setActive(%this,true);
  150. }
  151.  
  152. function Generator::onDisabled(%this)
  153. {
  154.     GameBase::stopSequence(%this,0);
  155.      GameBase::generatePower(%this, false);
  156. }
  157.  
  158. function Generator::onDestroyed(%this)
  159. {
  160.     Generator::onDisabled(%this);
  161.    StaticShape::objectiveDestroyed(%this);
  162.     calcRadiusDamage(%this, $DebrisDamageType, 2.5, 0.05, 25, 13, 3, 0.55, 
  163.         0.30, 250, 170); 
  164. }
  165.  
  166. function Generator::onActivate(%this)
  167. {
  168.     GameBase::playSequence(%this,0,"power");
  169.     GameBase::generatePower(%this, true);
  170. }
  171.  
  172. function Generator::onDeactivate(%this)
  173. {
  174.     GameBase::stopSequence(%this,0);
  175.      GameBase::generatePower(%this, false);
  176. }
  177.  
  178. //
  179.  
  180. StaticShapeData TowerSwitch
  181. {
  182.     description = "Tower Control Switch";
  183.     className = "towerSwitch";
  184.     shapeFile = "tower";
  185.     showInventory = "false";
  186.     visibleToSensor = true;
  187.     mapFilter = 4;
  188.     mapIcon = "M_generator";
  189. };
  190.  
  191. StaticShapeData Generator
  192. {
  193.    description = "Generator";
  194.    shapeFile = "generator";
  195.     className = "Generator";
  196.    sfxAmbient = SoundGeneratorPower;
  197.     debrisId = flashDebrisLarge;
  198.     explosionId = flashExpLarge;
  199.    maxDamage = 2.0;
  200.     visibleToSensor = true;
  201.     mapFilter = 4;
  202.     mapIcon = "M_generator";
  203.     damageSkinData = "objectDamageSkins";
  204.     shadowDetailMask = 16;
  205. };
  206.  
  207. StaticShapeData SolarPanel
  208. {
  209.    description = "Solar Panel";
  210.     shapeFile = "solar_med";
  211.     className = "Generator";
  212.     debrisId = flashDebrisMedium;
  213.     maxDamage = 1.0;
  214.     visibleToSensor = true;
  215.     mapFilter = 4;
  216.     mapIcon = "M_generator";
  217.     damageSkinData = "objectDamageSkins";
  218.     shadowDetailMask = 16;
  219.     explosionId = flashExpLarge;
  220. };
  221.  
  222. StaticShapeData PortGenerator
  223. {
  224.    description = "Portable Generator";
  225.    shapeFile = "generator_p";
  226.     className = "Generator";
  227.     debrisId = flashDebrisSmall;
  228.    sfxAmbient = SoundGeneratorPower;
  229.    maxDamage = 1.6;
  230.     mapIcon = "M_generator";
  231.     damageSkinData = "objectDamageSkins";
  232.     shadowDetailMask = 16;
  233.     explosionId = flashExpMedium;
  234. };
  235.  
  236.  
  237. //------------------------------------------------------------------------
  238. StaticShapeData SmallAntenna
  239. {
  240.     shapeFile = "anten_small";
  241.     debrisId = defaultDebrisSmall;
  242.     maxDamage = 1.0;
  243.     damageSkinData = "objectDamageSkins";
  244.     shadowDetailMask = 16;
  245.     explosionId = flashExpMedium;
  246.    description = "Small Antenna";
  247. };
  248.  
  249. //------------------------------------------------------------------------
  250. StaticShapeData MediumAntenna
  251. {
  252.     shapeFile = "anten_med";
  253.     debrisId = flashDebrisSmall;
  254.     maxDamage = 1.5;
  255.     damageSkinData = "objectDamageSkins";
  256.     shadowDetailMask = 16;
  257.     explosionId = flashExpMedium;
  258.    description = "Medium Antenna";
  259. };
  260.  
  261. //------------------------------------------------------------------------
  262. StaticShapeData LargeAntenna
  263. {
  264.     shapeFile = "anten_lrg";
  265.     debrisId = defaultDebrisSmall;
  266.     maxDamage = 1.5;
  267.     damageSkinData = "objectDamageSkins";
  268.     shadowDetailMask = 16;
  269.     explosionId = debrisExpMedium;
  270.    description = "Large Antenna";
  271. };
  272.  
  273. //------------------------------------------------------------------------
  274. StaticShapeData ArrayAntenna
  275. {
  276.     shapeFile = "anten_lava";
  277.     debrisId = flashDebrisSmall;
  278.     maxDamage = 1.5;
  279.     damageSkinData = "objectDamageSkins";
  280.     shadowDetailMask = 16;
  281.     explosionId = flashExpMedium;
  282.    description = "Array Antenna";
  283. };
  284.  
  285. //------------------------------------------------------------------------
  286. StaticShapeData RodAntenna
  287. {
  288.     shapeFile = "anten_rod";
  289.     debrisId = defaultDebrisSmall;
  290.     maxDamage = 1.5;
  291.     damageSkinData = "objectDamageSkins";
  292.     shadowDetailMask = 16;
  293.     explosionId = debrisExpMedium;
  294.    description = "Rod Antenna";
  295. };
  296.  
  297. //------------------------------------------------------------------------
  298. StaticShapeData ForceBeacon
  299. {
  300.     shapeFile = "force";
  301.     debrisId = defaultDebrisSmall;
  302.     maxDamage = 0.5;
  303.     damageSkinData = "objectDamageSkins";
  304.     shadowDetailMask = 16;
  305.     explosionId = debrisExpMedium;
  306.    description = "Force Beacon";
  307. };
  308.  
  309. //------------------------------------------------------------------------
  310. StaticShapeData CargoCrate
  311. {
  312.     shapeFile = "magcargo";
  313.     debrisId = flashDebrisSmall;
  314.     maxDamage = 1.0;
  315.     damageSkinData = "objectDamageSkins";
  316.     shadowDetailMask = 16;
  317.     explosionId = flashExpMedium;
  318.    description = "Cargo Crate";
  319. };
  320.  
  321. //------------------------------------------------------------------------
  322. StaticShapeData CargoBarrel
  323. {
  324.     shapeFile = "liqcyl";
  325.     debrisId = defaultDebrisSmall;
  326.     maxDamage = 1.0;
  327.     damageSkinData = "objectDamageSkins";
  328.     shadowDetailMask = 16;
  329.     explosionId = debrisExpMedium;
  330.    description = "Cargo Barrel";
  331. };
  332.  
  333. //------------------------------------------------------------------------
  334. StaticShapeData SquarePanel
  335. {
  336.     shapeFile = "teleport_square";
  337.     debrisId = flashDebrisSmall;
  338.     maxDamage = 0.3;
  339.     damageSkinData = "objectDamageSkins";
  340.     explosionId = flashExpMedium;
  341.    description = "Panel";
  342. };
  343.  
  344. //------------------------------------------------------------------------
  345. StaticShapeData VerticalPanel
  346. {
  347.     shapeFile = "teleport_vertical";
  348.     debrisId = defaultDebrisSmall;
  349.     explosionId = debrisExpMedium;
  350.     maxDamage = 0.5;
  351.     damageSkinData = "objectDamageSkins";
  352.    description = "Panel";
  353. };
  354.  
  355. //------------------------------------------------------------------------
  356. StaticShapeData BluePanel
  357. {
  358.     shapeFile = "panel_blue";
  359.     debrisId = flashDebrisSmall;
  360.     explosionId = flashExpMedium;
  361.     maxDamage = 0.5;
  362.     damageSkinData = "objectDamageSkins";
  363.    description = "Panel";
  364. };
  365.  
  366. //------------------------------------------------------------------------
  367. StaticShapeData YellowPanel
  368. {
  369.     shapeFile = "panel_yellow";
  370.     debrisId = defaultDebrisSmall;
  371.     explosionId = debrisExpMedium;
  372.     maxDamage = 0.5;
  373.     damageSkinData = "objectDamageSkins";
  374.    description = "Panel";
  375. };
  376.  
  377. //------------------------------------------------------------------------
  378. StaticShapeData SetPanel
  379. {
  380.     shapeFile = "panel_set";
  381.     debrisId = flashDebrisSmall;
  382.     explosionId = flashExpMedium;
  383.     maxDamage = 0.5;
  384.     damageSkinData = "objectDamageSkins";
  385.    description = "Panel";
  386. };
  387.  
  388. //------------------------------------------------------------------------
  389. StaticShapeData VerticalPanelB
  390. {
  391.     shapeFile = "panel_vertical";
  392.     debrisId = defaultDebrisSmall;
  393.     explosionId = debrisExpMedium;
  394.     maxDamage = 0.5;
  395.     damageSkinData = "objectDamageSkins";
  396.    description = "Panel";
  397. };
  398.  
  399. //------------------------------------------------------------------------
  400. StaticShapeData DisplayPanelOne
  401. {
  402.     shapeFile = "display_one";
  403.     debrisId = flashDebrisSmall;
  404.     explosionId = flashExpMedium;
  405.     maxDamage = 0.5;
  406.     damageSkinData = "objectDamageSkins";
  407.    description = "Panel";
  408. };
  409.  
  410. //------------------------------------------------------------------------
  411. StaticShapeData DisplayPanelTwo
  412. {
  413.     shapeFile = "display_two";
  414.     debrisId = defaultDebrisSmall;
  415.     explosionId = debrisExpMedium;
  416.     maxDamage = 0.5;
  417.     damageSkinData = "objectDamageSkins";
  418.    description = "Panel";
  419. };
  420.  
  421. //------------------------------------------------------------------------
  422. StaticShapeData DisplayPanelThree
  423. {
  424.     shapeFile = "display_three";
  425.     debrisId = flashDebrisSmall;
  426.     explosionId = flashExpMedium;
  427.     maxDamage = 0.5;
  428.     damageSkinData = "objectDamageSkins";
  429.    description = "Panel";
  430. };
  431.  
  432. //------------------------------------------------------------------------
  433. StaticShapeData HOnePanel
  434. {
  435.     shapeFile = "dsply_h1";
  436.     debrisId = defaultDebrisSmall;
  437.     explosionId = debrisExpMedium;
  438.     maxDamage = 0.5;
  439.     damageSkinData = "objectDamageSkins";
  440.    description = "Panel";
  441. };
  442.  
  443. //------------------------------------------------------------------------
  444. StaticShapeData HTwoPanel
  445. {
  446.     shapeFile = "dsply_h2";
  447.     debrisId = flashDebrisSmall;
  448.     explosionId = flashExpMedium;
  449.     maxDamage = 0.5;
  450.     damageSkinData = "objectDamageSkins";
  451.    description = "Panel";
  452. };
  453.  
  454. //------------------------------------------------------------------------
  455. StaticShapeData SOnePanel
  456. {
  457.     shapeFile = "dsply_s1";
  458.     debrisId = defaultDebrisSmall;
  459.     explosionId = debrisExpMedium;
  460.     maxDamage = 0.5;
  461.     damageSkinData = "objectDamageSkins";
  462.    description = "Panel";
  463. };
  464.  
  465. //------------------------------------------------------------------------
  466. StaticShapeData STwoPanel
  467. {
  468.     shapeFile = "dsply_s2";
  469.     debrisId = flashDebrisSmall;
  470.     explosionId = flashExpMedium;
  471.     maxDamage = 0.5;
  472.     damageSkinData = "objectDamageSkins";
  473.    description = "Panel";
  474. };
  475.  
  476. //------------------------------------------------------------------------
  477. StaticShapeData VOnePanel
  478. {
  479.     shapeFile = "dsply_v1";
  480.     debrisId = defaultDebrisSmall;
  481.     explosionId = debrisExpMedium;
  482.     maxDamage = 0.5;
  483.     damageSkinData = "objectDamageSkins";
  484.    description = "Panel";
  485. };
  486.  
  487. //------------------------------------------------------------------------
  488. StaticShapeData VTwoPanel
  489. {
  490.     shapeFile = "dsply_v2";
  491.     debrisId = flashDebrisSmall;
  492.     explosionId = flashExpMedium;
  493.     maxDamage = 0.5;
  494.     damageSkinData = "objectDamageSkins";
  495.    description = "Panel";
  496. };
  497.  
  498. //------------------------------------------------------------------------
  499. StaticShapeData ForceField
  500. {
  501.     shapeFile = "forcefield";
  502.     debrisId = defaultDebrisSmall;
  503.     maxDamage = 10000.0;
  504.     isTranslucent = true;
  505.    description = "Force Field";
  506. };
  507.  
  508. //------------------------------------------------------------------------
  509. StaticShapeData ElectricalBeam
  510. {
  511.     shapeFile = "zap";
  512.     maxDamage = 10000.0;
  513.     isTranslucent = true;
  514.     description = "Electrical Beam";
  515.    disableCollision = true;
  516. };
  517.  
  518. StaticShapeData ElectricalBeamBig
  519. {
  520.     shapeFile = "zap_5";
  521.     maxDamage = 10000.0;
  522.     isTranslucent = true;
  523.     description = "Electrical Beam";
  524.    disableCollision = true;
  525. };
  526.  
  527. StaticShapeData PoweredElectricalBeam
  528. {
  529.     shapeFile = "zap";
  530.     maxDamage = 10000.0;
  531.     isTranslucent = true;
  532.     description = "Electrical Beam";
  533.    disableCollision = true;
  534. };
  535.  
  536. //function to fade in electrical beam based on base power.
  537. function PoweredElectricalBeam::onPower(%this, %power, %generator)
  538. {
  539.    if(%power)
  540.       GameBase::startFadeIn(%this);
  541.    else
  542.       GameBase::startFadeOut(%this);
  543. }
  544.       
  545. //-----------------------------------------------------------------------
  546. StaticShapeData Cactus1
  547. {
  548.     shapeFile = "cactus1";
  549.     debrisId = defaultDebrisSmall;
  550.     maxDamage = 0.4;
  551.    description = "Cactus";
  552. };
  553. //------------------------------------------------------------------------
  554. StaticShapeData Cactus2
  555. {
  556.     shapeFile = "cactus2";
  557.     debrisId = defaultDebrisSmall;
  558.     maxDamage = 0.4;
  559.    description = "Cactus";
  560. };
  561. //------------------------------------------------------------------------
  562. StaticShapeData Cactus3
  563. {
  564.     shapeFile = "cactus3";
  565.     debrisId = defaultDebrisSmall;
  566.     maxDamage = 0.4;
  567.    description = "Cactus";
  568. };
  569.  
  570. //------------------------------------------------------------------------
  571. StaticShapeData SteamOnGrass
  572. {
  573.     shapeFile = "steamvent_grass";
  574.     maxDamage = 999.0;
  575.     isTranslucent = "True";
  576.    description = "Steam Vent";
  577. };
  578.  
  579. //------------------------------------------------------------------------
  580. StaticShapeData SteamOnMud
  581. {
  582.     shapeFile = "steamvent_mud";
  583.     maxDamage = 999.0;
  584.     isTranslucent = "True";
  585.    description = "Steam Vent";
  586. };
  587.  
  588. //------------------------------------------------------------------------
  589. StaticShapeData TreeShape
  590. {
  591.     shapeFile = "tree1";
  592.     maxDamage = 10.0;
  593.     isTranslucent = "True";
  594.    description = "Tree";
  595. };
  596.  
  597. //------------------------------------------------------------------------
  598. StaticShapeData TreeShapeTwo
  599. {
  600.     shapeFile = "tree2";
  601.     maxDamage = 10.0;
  602.     isTranslucent = "True";
  603.    description = "Tree";
  604. };
  605.  
  606. //------------------------------------------------------------------------
  607. StaticShapeData SteamOnGrass2
  608. {
  609.     shapeFile = "steamvent2_grass";
  610.     maxDamage = 999.0;
  611.     isTranslucent = "True";
  612. };
  613.  
  614. //------------------------------------------------------------------------
  615. StaticShapeData SteamOnMud2
  616. {
  617.     shapeFile = "steamvent2_mud";
  618.     maxDamage = 999.0;
  619.     isTranslucent = "True";
  620.    description = "Steam Vent";
  621. };
  622. //------------------------------------------------------------------------
  623. StaticShapeData PlantOne
  624. {
  625.     shapeFile = "plant1";
  626.     debrisId = defaultDebrisSmall;
  627.     maxDamage = 0.4;
  628.    description = "Plant";
  629. };
  630.  
  631. //------------------------------------------------------------------------
  632. StaticShapeData PlantTwo
  633. {
  634.     shapeFile = "plant2";
  635.     debrisId = defaultDebrisSmall;
  636.     maxDamage = 0.4;
  637.    description = "Plant";
  638. };
  639.