Tribes 2 Links: | Weapons | Armor | Vehicals | Packs, Deployables | Official Map Editor Guide | Scripting | td>
Thanks to the Tribes 2 Coding Community and Nevermind for this tutorial.
Teleport Pad Author: Nevermind |
Step #1 Create a new file in the scripts/packs/ folder, name it telepadpack.cs Paste this into the newly created file: // telepadpack.cs - teleport pack // datablock ShapeBaseImageData(TelePadDeployableImage) { mass = 15; emap = true; shapeFile = "stackable1s.dts"; item = TelePadPack; mountPoint = 1; offset = "0 -0.2 0"; deployed = TelePadDeployedBase; heatSignature = 0.5; stateName[0] = "Idle"; stateTransitionOnTriggerDown[0] = "Activate"; stateName[1] = "Activate"; stateScript[1] = "onActivate"; stateTransitionOnTriggerUp[1] = "Idle"; isLarge = true; maxDepSlope = 30; deploySound = StationDeploySound; }; datablock ItemData(TelePadPack) { className = Pack; catagory = "Deployables"; shapeFile = "stackable1s.dts"; mass = 3.0; elasticity = 0.2; friction = 0.6; pickupRadius = 1; rotate = false; image = "TelePadDeployableImage"; pickUpName = "a deployable teleport pad"; heatSignature = 0; computeCRC = true; emap = true; }; datablock SensorData(TelePadBaseSensorObj) { detects = true; detectsUsingLOS = true; detectsPassiveJammed = false; detectsActiveJammed = false; detectsCloaked = false; detectionPings = true; detectRadius = 10; }; datablock StaticShapeData(TelePadDeployedBase) : StaticShapeDamageProfile { className = "Station"; catagory = "Deployables"; shapefile = "ext_flagstand.dts"; rechargeRate = 0.31; needsNoPower = true; dynamicType = $TypeMasks::StationObjectType; mass = 5.0; maxDamage = 2.00; destroyedLevel = 2.00; disabledLevel = 1.35; repairRate = 0; explosion = DeployablesExplosion; expDmgRadius = 18.0; expDamage = 0.8; expImpulse = 2000.0; deployedObject = true; energyPerDamagePoint = 50; maxEnergy = 150; humSound = SensorHumSound; heatSignature = 0; pausePowerThread = true; debrisShapeName = "debris_generic.dts"; debris = DeployableDebris; cmdIcon = CMDSwitchIcon; cmdCategory = "DSupport"; cmdMiniIconName = "commander/MiniIcons/com_switch_grey"; targetNameTag = 'Deployed'; targetTypeTag = 'Teleport Pad'; sensorData = TelePadBaseSensorObj; sensorRadius = TelePadBaseSensorObj.detectRadius; sensorColor = "0 212 45"; firstPersonOnly = true; //lightOnlyStatic = true; lightType = "PulsingLight"; lightColor = "0 1 0 1"; lightTime = 1200; lightRadius = 6; }; datablock StaticShapeData(TelePadBeam) { className = "Station"; catagory = "DSupport"; shapefile = "nexus_effect.dts"; collideable = 1; needsNoPower = true; emap="true"; sensorData = TelePadBaseSensorObj; sensorRadius = TelePadBaseSensorObj.detectRadius; sensorColor = "0 212 45"; cmdCategory = "DSupport"; targetNameTag = 'Teleport'; targetTypeTag = 'Pad'; //lightOnlyStatic = true; lightType = "PulsingLight"; lightColor = "0 1 0 1"; lightTime = 1200; lightRadius = 6; }; function TelePadDeployedBase::onDestroyed(%this, %obj, %prevState) { echo("pad " @ %obj @ " destroyed!"); Parent::onDestroyed(%this, %obj, %prevState); $TeamDeployedCount[%obj.team, TelePadPack]--; if($TeamDeployedCount[%obj.team, TelePadPack] > 0) // this wasnt the last { if($firstPad[%obj.team] == %obj) // the first was destroyed { echo("first pad destroyed"); $firstPad[%obj.team] = %obj.nextPad; // make the second one the first echo("first pad (" @ %obj @ ") destroyed, new first :" @ $firstPad[%obj.team]); $firstPad[%obj.team].prevPad = -1; } else { %obj.prevPad.nextPad = %obj.nextPad; %obj.nextPad.prevPad = %obj.prevPad; } //blow up another one, maybe %rnd = mFloor(getRandom() * 10); echo("rnd " @ mFloor(%rnd)); if(%rnd == 5) // one in ten chance { echo("another pad blows up"); %obj.nextPad.setDamageLevel(2.01); } } else // last one $firstPad[%obj.team] = ""; // remove it //blow up %obj.shield[0].schedule(10, "delete"); %obj.schedule(15, "delete"); } function TelePadDeployedBase::onCollision(%data, %obj, %col) { if(%col.justTeleported) return; %teleteam = %obj.team; if(%obj.Hacked) // This is just stuff i use for my mod, If you don`t know what your doing, don`t fiddle with it %teleteam = %obj.OldTeam; %pads = $TeamDeployedCount[%teleteam, TelePadPack]; //verify pd.team is team associated and is on player's team if((%obj.team != %col.client.team) && (%obj.team != 0)) { %obj.playAudio(0, TelePadAccessDeniedSound); messageClient(%col.client, 'msgTelepadDenied', '\c2Access Denied -- Wrong team.'); %col.justTeleported = true; schedule(2000, %col, "unteleport", %col); return; } if(%pads < 2) { %obj.playAudio(0, TelePadAccessDeniedSound); messageClient(%col.client, 'msgTelepadDenied', '\c2No other pads to teleport to.'); %col.justTeleported = true; schedule(2000, %col, "unteleport", %col); return; } if(%obj.teleCharging) { %obj.playAudio(0, TelePadAccessDeniedSound); messageClient(%col.client, 'msgTelepadDenied', '\c2Unable to teleport, pad is recharging.'); %col.justTeleported = true; schedule(2000, %col, "unteleport", %col); return; } %rnd = getRandom(); if(%pads > 2) %padloop = (mFloor(%rnd * (%pads - 1)) + 1); else %padloop = 1; %destPad = %obj.nextPad; echo("teleporting player " @ %col @ " from pad " @ %obj @ " to pad " @ %destPad); %obj.shield[0].startFade( 0, 0, true ); //%col.startFade( 0, 0, true ); %col.justTeleported = true; %obj.playAudio(0, IdleSound); %col.setWhiteout(1); // a white flash %col.setTransform(setWord(%col.getPosition(), 2, 800) SPC "0 0 1 0"); //huck em into the sky messageClient(%col.client, 'msgTelepadDenied', "~wfx/misc/diagnostic_on.wav"); schedule(3000, %col, "teleport", %col, %destPad, %obj); // shedule their teleportation schedule(10000, %destPad, "tp_fadein", %destPad); schedule(10000, %obj, "tp_fadein", %obj); //schedule(1000, %col, "pl_fadein", %col); %obj.setEnergyLevel(0); %obj.teleCharging = true; } function pl_fadein(%obj) { %obj.startFade(50, 0, false); } function tp_fadein(%obj) { %obj.playAudio(0, TelePadBeamSound); %obj.shield[0].startFade(100, 0, false); %obj.teleCharging = false; } function unteleport(%pl) { %pl.justTeleported = false; } function teleport(%pl, %destPad, %src) { %pl.setVelocity("0 0 0"); //These numbers tells the game to slow down the player. if(!isObject(%destPad)) // lost the destination %pl.setTransform(%src.getPosition() SPC "0 0 1 0"); else { %pl.setTransform(vectorAdd(%destPad.getPosition(), "0 0 2") SPC "0 0 1 0"); %destPad.shield[0].startFade( 0, 0, true ); %destPad.playAudio(0, IdleSound); %destPad.teleCharging = true; %destPad.setEnergyLevel(0); } schedule(2000, %pl, "unteleport", %pl); } function TelePadBeam::onCollision(%data, %obj, %col) { echo("beam collision!!!!!"); } datablock AudioProfile(TelePadAccessDeniedSound) { filename = "fx/weapons/ELF_underwater.wav"; description = AudioClosest3d; preload = true; }; datablock AudioProfile(TelePadBeamSound) { filename = "fx/powered/inv_pad_appear.wav"; description = AudioClosest3d; preload = true; }; function TelePadPack::onPickup(%this, %obj, %shape, %amount) { // created to prevent console errors } function TelePadDeployableImage::onDeploy(%item, %plyr, %slot) { echo("teledeploy!!"); %deplObj = Parent::onDeploy(%item, %plyr, %slot); //attach green beam %deplObj.shield[0] = new (StaticShape)() { dataBlock = TelePadBeam; }; %deplObj.shield[0].setTransform(%item.surfacePt SPC %rot); //addToDeployGroup(%beamObj); //%deplObj.beam = %beamObj; //echo("pad deployed : " @ %deplObj); %deplObj.shield[0].playThread(0, "ambient"); %deplObj.shield[0].setThreadDir(0, true); //The flash animation plays forwards, then back automatically, so we have to alternate the thread direcction... %deplObj.shield[0].flashThreadDir = true; echo("setting beam!!"); %padcnt = $TeamDeployedCount[%plyr.team, %item.item]; if(%padcnt == 1) { //first pad echo("first pad : " @ %deplObj); $firstPad[%plyr.team] = %deplObj; %deplObj.nextPad = %deplObj; %deplObj.prevPad = -1; } else { %lastPad = $firstPad[%plyr.team]; %txt = "pad list "; %txta = "pad list "; %txtb = "pad list "; for(%i = 1; %i < (%padcnt -1); %i++) // move to the last pad so we can add the next one %lastPad = %lastPad.nextPad; %lastPad.nextPad = %deplObj; %deplObj.prevPad = %lastPad; %deplObj.nextPad = $firstPad[%plyr.team]; %a = $firstPad[%plyr.team]; echo("lastPad " @ %lastPad); echo("firstPad " @ %a); for(%i = 1; %i <= %padcnt; %i++) { %txt = %txt @ "("@%i@") t:" @ %a @ " -> "; %txta = %txta @ "("@%i@") p:" @ %a.prevPad @ " -> "; %txtb = %txtb @ "("@%i@") n:" @ %a.nextPad @ " -> "; %a = %a.nextPad; } } return %deplObj; } function TelePadDeployedBase::disassemble(%data, %plyr, %hTgt) { %teleteam = %hTgt.team; if(%obj.Hacked) // is it hacked currently? { %teleteam = %hTgt.OldTeam; echo("hacked!"); } // dising a telepad makes it yours, remove from the other teams list if($TeamDeployedCount[%teleteam, TelePadPack] > 0) // this wasnt the last { if($firstPad[%teleteam] == %hTgt) // the first was disassembled { echo("first pad disassembled"); $firstPad[%teleteam] = %ohTgtbj.nextPad; // make the second one the first %hTgt.prevPad = -1; %hTgt.nextPad = %obj; } else { %lastPad = $firstPad[%teleteam]; %hTgt.prevPad.nextPad = %hTgt.nextPad; %hTgt.nextPad.prevPad = %hTgt.prevPad; } } else // last one { $firstPad[%teleteam] = ""; // remove it } %hTgt.shield[0].delete(); } Step #2 Open inventoryHud.cs, by now you should know where to add this: $InvPack[19] = "Teleport Pad"; And: $NameToInv["Teleport Pad"] = "TelePadPack"; Step #3 OK, now we will open deployables.cs As this is a pretty "advanced" toturial, find the place to add it for yerself: $TeamDeployableMax[TelePadPack] = 2; And: $ReverseDeployItem[TelePadDeployedBase] = TelePadPack; Step #4 Open up pack.cs Add this under // --- Upgrade packs ---: exec("scripts/packs/telepadpack.cs"); Step #5 Open up player.cs, you know where to add this: max[TelePadPack] = 1; Tell everyone how much you liked this tut(be honest): |
Headlines: |
-(16 June) Thank you Haarmann -(16 June) Disclaimer -(16 June) oopsy -(15 June) Plagarised Tutorials -(15 June) Sorry Cyngon!!! -(15 June) Tutorials Galore! -(15 June) Problems are solved! |