123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452 |
- AddDamageType("Stargate_IrisSlam", '%1 didn\'t rematerialize at the other end.', '%1 didn\'t rematerialize at the other end.', 1, 1);
- AddDamageType("Stargate_WrongSide", '%1 entered the wrong side of a Stargate.', '%1 entered the wrong side of a Stargate.', 1, 1);
- AddDamageType("Stargate_Backwards", '%1 went backwards through the wormhole.', '%1 went backwards through the wormhole.', 1, 1);
- AddDamageType("Stargate_Kawoosh", '%1 stood in the way of the Kawoosh.', '%1 stood in the way of the Kawoosh.', 1, 1);
- AddDamageType("Stargate_Telefrag", '%1 stood in a closing wormhole.', '%1 stood in a closing wormhole.', 1, 1);
- datablock StaticShapeData(StargateOuterRingShape)
- { shapefile = "Add-Ons/Gamemode_Stargate/Milky_Way/Ring/Outer.dts"; };
- datablock StaticShapeData(StargateMiddleRingShape)
- { shapefile = "Add-Ons/Gamemode_Stargate/Milky_Way/Ring/Middle.dts"; };
- datablock StaticShapeData(StargateInnerRingShape)
- { shapefile = "Add-Ons/Gamemode_Stargate/Milky_Way/Ring/Inner.dts"; };
- datablock StaticShapeData(StargateChevronBottomShape)
- { shapefile = "Add-Ons/Gamemode_Stargate/Milky_Way/Chev/Bottom.dts"; };
- datablock StaticShapeData(StargateChevronFinShape)
- { shapefile = "Add-Ons/Gamemode_Stargate/Milky_Way/Chev/Fin.dts"; };
- datablock StaticShapeData(StargateChevronLightShape)
- { shapefile = "Add-Ons/Gamemode_Stargate/Milky_Way/Chev/Light.dts"; };
- datablock StaticShapeData(StargateHorizonShape)
- { shapefile = "Add-Ons/Gamemode_Stargate/Horiz/Horizon.dts"; };
- datablock StaticShapeData(StargateKawooshShape)
- { shapefile = "Add-Ons/Gamemode_Stargate/Horiz/Kawoosh.dts"; };
- datablock StaticShapeData(StargateIrisShape)
- { shapefile = "Add-Ons/Gamemode_Stargate/Horiz/Iris.dts"; };
- datablock StaticShapeData(StargateDestinyShape)
- { shapefile = "Add-Ons/Gamemode_Stargate/Destiny/Stargate/Stargate.dts"; };
- function MakeStargate(%trans, %address, %origin, %name)
- {
- if(!isObject(StargateNetwork))
- new SimSet(StargateNetwork);
-
- (%outer = new StaticShape()
- {
- address = %address;
- datablock = StargateOuterRingShape;
- pointOfOrigin = %origin;
- worldName = %name;
- gateClass = "Milky_Way";
- }).setTransform(%trans);
- %outer.setNodeColor("Outer", "0.3 0.3 0.3 1");
-
- (%middle = new StaticShape()
- {
- datablock = StargateMiddleRingShape;
- }).setTransform(%trans);
- %middle.setNodeColor("Middle", "0.3 0.3 0.3 1");
-
- (%inner = new StaticShape()
- {
- datablock = StargateInnerRingShape;
- }).setTransform(%trans);
- %inner.setNodeColor("Inner", "0.3 0.3 0.3 1");
-
- (%horiz = new StaticShape()
- {
- datablock = StargateHorizonShape;
- }).setTransform(%trans);
- %horiz.setNodeColor("ALL", "1 1 1 1");
- %horiz.hideNode("ALL");
-
- (%kawoosh = new StaticShape()
- {
- datablock = StargateKawooshShape;
- }).setTransform(%trans);
- %kawoosh.setNodeColor("ALL", "0 0.5 1 1");
- %kawoosh.hideNode("ALL");
-
- %outer.middle = %middle;
- %outer.inner = %inner;
- %outer.horiz = %horiz;
- %outer.kawoosh = %kawoosh;
-
- %pos = getWords(%trans, 0, 2);
- %for = %outer.getForwardVector();
- %up = %outer.getUpVector();
- %right = vectorCross(%for, %up);
- %hLen = vectorLen(getWords(%for, 0, 1));
- %vAng = mAtan(getWord(%for, 2), %hLen) * (180 / $PI);
- %hAng = mAtan(getWord(%for, 0), getWord(%for, 1)) * (180 / $PI);
- if(mAbs(vectorDot(%up, "0 0 1")) <= 0.999)
- {
- %hAng += 180; %vAng = 180 - %vAng;
- if(mAbs(vectorDot(%for, "0 0 1")) <= 0.999) %rot += 180;
- }
- for(%i=0;%i<9;%i++)
- {
- %offset = vectorAdd(vectorScale(%right, mSin(%i*$PI/4.5)*-4.2),
- vectorScale(%up, mCos(%i*$PI/4.5)*4.2));
- %trans = vectorAdd(%pos, %offset) SPC eulerToAxis(%vAng SPC -360*(%i/9)+%rot SPC -%hAng);
-
- (%shape = new StaticShape() {
- datablock = StargateChevronBottomShape;
- }).setTransform(%trans);
- %shape.setNodeColor("Bottom", "0.3 0.3 0.3 1");
- %shape.setNodeColor("LightStrips", "0.2 0.2 0.2 1");
- %outer.ChevB[%i] = %shape;
-
- (%shape = new StaticShape() {
- datablock = StargateChevronFinShape;
- }).setTransform(%trans);
- %shape.setNodeColor("LightBody", "0.3 0.3 0.3 1");
- %shape.setNodeColor("Fins", "0.3 0.3 0.3 1");
- %shape.setNodeColor("Detail", "0.3 0.3 0.3 1");
- %outer.ChevF[%i] = %shape;
-
- (%shape = new StaticShape() {
- datablock = StargateChevronLightShape;
- }).setTransform(%trans);
- %shape.setNodeColor("Light", "0.3 0 0 1");
- %outer.ChevL[%i] = %shape;
- }
-
- StargateNetwork.add(%outer);
- return %outer;
- }
- function MakeDestinyGate(%trans, %address, %origin, %name)
- {
- if(!isObject(StargateNetwork))
- new SimSet(StargateNetwork);
-
- (%gate = new StaticShape()
- {
- address = %address;
- datablock = StargateDestinyShape;
- pointOfOrigin = %origin;
- worldName = %name;
- gateClass = "Destiny";
- }).setTransform(%trans);
-
- (%kawoosh = new StaticShape()
- {
- datablock = StargateKawooshShape;
- }).setTransform(%trans);
- %kawoosh.setNodeColor("ALL", "0 0.5 1 1");
- %kawoosh.hideNode("ALL");
- (%horiz = new StaticShape()
- {
- datablock = StargateHorizonShape;
- }).setTransform(%trans);
- %horiz.setNodeColor("ALL", "1 1 1 1");
- %horiz.hideNode("ALL");
-
- %gate.horiz = %horiz;
-
- (%bearing = new StaticShape()
- {
- datablock = StargateDestinyBearingShape;
- }).setTransform(VectorAdd(%trans, "0 0 5.6"));
- %bearing.setNodeColor("ALL", "1 1 1 1");
- %gate.bearing = %bearing;
-
- %gate.kawoosh = %kawoosh;
-
- StargateNetwork.add(%gate);
- return %gate;
- }
- function StaticShape::ChevronLockAnim(%obj, %num, %stayOn)
- {
- %scale = getWord(%obj.getScale(), 2);
- if(isObject(%bottom = %obj.ChevB[%num]))
- {
- %rot = getWords(%bottom.getTransform(), 3, 6);
- if(%bottom.ChevronPosition !$= "") %pos = %bottom.ChevronPosition;
- else {
- %pos = %bottom.getPosition();
- %bottom.ChevronPosition = %pos;
- }
- %dir = vectorNormalize(vectorSub(%obj.getPosition(), %pos));
- for(%i=0;%i<12;%i++)
- {
- cancel(%bottom.ChevLockASched[%i]); cancel(%bottom.ChevLockBSched[%i]);
- %bottom.ChevLockASched[%i] = %bottom.schedule(%i * 16, "setTransform", vectorAdd(%pos, vectorScale(%dir, 0.2 * %scale * (%i / 11))) SPC %rot);
- %bottom.ChevLockBSched[%i] = %bottom.schedule(%i * 16 + 1200, "setTransform", vectorAdd(%pos, vectorScale(%dir, 0.2 * %scale * (1 - %i / 11))) SPC %rot);
- }
- }
- if(isObject(%light = %obj.ChevL[%num]))
- {
- %rot = getWords(%light.getTransform(), 3, 6);
- if(%light.ChevronPosition !$= "") %pos = %light.ChevronPosition;
- else {
- %pos = %light.getPosition();
- %light.ChevronPosition = %pos;
- }
- %dir = vectorNormalize(vectorSub(%obj.getPosition(), %pos));
- for(%i=0;%i<12;%i++)
- {
- cancel(%light.ChevLockASched[%i]); cancel(%light.ChevLockBSched[%i]);
- %light.ChevLockASched[%i] = %light.schedule(%i * 16, "setTransform", vectorAdd(%pos, vectorScale(%dir, -0.05 * %scale * (%i / 11))) SPC %rot);
- %light.ChevLockBSched[%i] = %light.schedule(%i * 16 + 1200, "setTransform", vectorAdd(%pos, vectorScale(%dir, -0.05 * %scale * (1 - %i / 11))) SPC %rot);
- }
- }
- %obj.schedule(384, "ChevronLightAnim", %num, 1, !%stayOn);
- }
- function StaticShape::ChevronLightAnim(%obj, %num, %on, %off)
- {
- if(isObject(%bottom = %obj.ChevB[%num]))
- %bottom.ObjectLightAnim("LightStrips", %on, %off, 0.2, 0.8, 0.2, 0.5, 0.2, -0.2);
- if(isObject(%light = %obj.ChevL[%num]))
- %light.ObjectLightAnim("Light", %on, %off, 0.3, 0.7, 0, 0.7, 0, 0);
- }
- function StaticShape::ObjectLightAnim(%obj, %node, %on, %off, %r0, %r1, %g0, %g1, %b0, %b1)
- {
- if(%on && %off)
- {
- for(%i=0;%i<63;%i++)
- {
- %value = mSin(%i / 62 * $PI);
- if(%i > 31 || !%obj.isNodeLit[%node])
- %obj.schedule(%i * 16, "setNodeColor", %node, %r0+%r1*%value SPC %g0+%g1*%value SPC %b0-%b1*%value SPC 1);
- }
- %obj.isNodeLit[%node] = 0;
- }
- else if(%on && !%obj.isNodeLit[%node])
- {
- for(%i=0;%i<32;%i++)
- {
- %value = mSin(%i / 62 * $PI);
- %obj.schedule(%i * 16, "setNodeColor", %node, %r0+%r1*%value SPC %g0+%g1*%value SPC %b0-%b1*%value SPC 1);
- }
- %obj.isNodeLit[%node] = 1;
- }
- else if(%off && %obj.isNodeLit[%node])
- {
- for(%i=0;%i<32;%i++)
- {
- %value = mSin((%i + 31) / 62 * $PI);
- %obj.schedule(%i * 16, "setNodeColor", %node, %r0+%r1*%value SPC %g0+%g1*%value SPC %b0-%b1*%value SPC 1);
- }
- %obj.isNodeLit[%node] = 0;
- }
- }
- function StaticShape::DialStargate(%obj, %address)
- {
- %obj.setStargateState(1);
- %obj.DiallingSequence(%address, %address, -1, -1, 0, 0, 1);
- }
- function StaticShape::ResetDHD(%obj)
- {
- for(%i=0;%i<19;%i++)
- {
- %obj.dhd.ObjectLightAnim("Sym_A_"@%i, 0, 1, 0.2, 0.8, 0.1, 0.6, 0, 0);
- %obj.dhd.ObjectLightAnim("Sym_B_"@%i, 0, 1, 0.2, 0.8, 0.1, 0.6, 0, 0);
- }
- for(%i=0;%i<9;%i++) %obj.ChevronLightAnim(%i, 0, 1);
- for(%i=0;%i<3;%i++)
- {
- %obj.dhd.stopAudio(%i);
- %obj.dhd.schedule(0, "playAudio", %i, DialFail_Sound);
- }
- return;
- }
- function StaticShape::InstantDial(%obj, %address)
- {
- %gateFound = 0;
- echo(%obj.address);
- echo(%address);
- echo($gateObjs[%address].pointOfOrigin);
- if($gateObjs[%address] && %gate.gateState <= 1 && %address !$= %obj.address)
- {
- %gate = $gateObjs[%address];
- %gateFound = 1;
- %obj.dhd.ObjectLightAnim("BUTTON", 1, 0, 0.5, 0.5, 0, 0, 0, 0);
- %obj.setStargateState(2);
- %gate.setStargateState(2);
- %gate.dhd.dialSequence = "";
- for(%i=0;%i<9;%i++)
- if(%obj.ChevL[%i].isNodeLitLight)
- {
- %gate.ChevronLockAnim(%i, 1);
- serverPlay3D(ChevronLocked_Sound, %gate.getPosition());
- }
- else %gate.ChevronLockAnim(%i, 0);
- %obj.schedule(400, "OpenStargate", %gate, %gate, %pl.client);
- %gate.schedule(400, "OpenStargate", %obj);
- return;
- }
- if(%gateFound == 0) return %obj.ResetDHD();
- }
- function Gate_GetGoalAng(%obj, %goal)
- {
- switch$(%obj.gateClass)
- {
- case "Milky_Way":
- return (%goal / -39) * 360;
- case "Destiny":
- return 9.457616760 + %goal * 7.1 + mFloor(%goal / 4) * 40;
- }
- }
- function StaticShape::DiallingSequence(%obj, %address, %origAddr, %last, %spinStart, %accelMode, %angVel, %spinDir)
- {
- cancel(%obj.DialSched);
- if((%words = getWordCount(%address)) == 0) return;
- %goal = firstWord(%address);
- if(%last == -1)
- {
- %starting = 1;
- %last = getSimTime();
- %spinStart = %last;
- for(%i=0;%i<2;%i++)
- {
- %obj.playAudio(%i, GateRoll_Sound);
- %obj.GateRollSched[%i] = %obj.schedule(3392, "playAudio", %i, GateRollLoop_Sound);
- }
- }
-
- %obj.currSpin -= mFloor(%obj.currSpin / 360) * 360;
- %time = vectorDist(%last, %now = getSimTime()) / 1000;
- %goalAng = Gate_GetGoalAng(%obj, %goal - 1);
- %dist = %obj.currSpin - %goalAng;
- %dist -= mFloor(%dist / 360) * 360;
- switch$(%obj.gateClass)
- {
- case "Milky_Way":
- %spinObj = %obj.Middle;
- case "Destiny":
- %spinObj = %obj;
- }
-
- if(%obj.maxAngularVel < 0.5)
- %obj.maxAngularVel = 40;
- if(%obj.angularAccelTime > 4 || %obj.angularAccelTime < 0.01)
- %obj.angularAccelTime = 1;
- %angTopVel = %obj.maxAngularVel;
- %accelTime = %obj.angularAccelTime;
-
- //%angTopVel = 40; //40
- //%accelTime = 1.0; //1.5
-
- if(%obj.gateState > 1)
- {
- %accelMode = 2;
- %haltGate = 1;
- }
-
- if(%accelMode == 0)
- {
- %accelRate = (%angTopVel / %accelTime) * (%spinDir - 0.5) * 2;
- if(mAbs(%angVel + %accelRate * %time) > %angTopVel)
- {
- %velDiff = %angTopVel - mAbs(%angVel);
- %accelDiff = %velDiff / %accelRate;
- %coastTime = %time - %accelDiff;
- %newRot = (%accelRate / 2) * (%accelDiff * %accelDiff) + %angVel * %accelDiff + %obj.currSpin;
- %angVel = %angTopVel * (%spinDir - 0.5) * 2;
- %newRot += %angVel * %coastTime;
- %obj.currSpin = %newRot;
- %accelMode = 1;
- }
- else
- {
- %newRot = (%accelRate / 2) * (%time * %time) + %angVel * %time + %obj.currSpin;
- %angVel += %accelRate * %time; %obj.currSpin = %newRot;
- }
- }
- else if(%accelMode == 1)
- {
- if(%spinDir)
- {
- %deltaPos = 360 - (%obj.currSpin - %goalAng);
- if(%deltaPos < 0) %deltaPos += 360;
- }
- else
- {
- %deltaPos = %obj.currSpin - %goalAng;
- if(%deltaPos > 360) %deltaPos -= 360;
- }
-
- %accelRate = %angTopVel / %accelTime;
- %decelTime = mAbs(%angVel) / %accelRate;
- %decelDist = (mAbs(%angVel) * %decelTime) - (%accelRate * %decelTime * %decelTime / 2);
-
- %deltaTime = (%deltaPos - %decelDist) / mAbs(%angVel);
- if(%deltaTime < %time && %deltaTime > 0)
- {
- %obj.currSpin += %angVel * %deltaTime;
- %decelTime = %time - %deltaTime;
- %accelRate *= (%spinDir - 0.5) * 2;
- %newRot = (%accelRate / -2) * (%time * %time) + %angVel * %time + %obj.currSpin;
- %angVel -= %accelRate * %time;
- %obj.currSpin = %newRot;
- %accelMode = 2;
- }
- else %obj.currSpin += %angVel * %time;
- }
- else if(%accelMode == 2)
- {
- %accelRate = (%angTopVel / %accelTime) * (%spinDir - 0.5) * 2;
- if(mAbs(%angVel) - mAbs(%accelRate * %time) < 0)
- {
- %velDiff = mAbs(%angVel);
- %accelDiff = %velDiff / %accelRate;
- %newRot = (%accelRate / -2) * (%accelDiff * %accelDiff) + %angVel * %accelDiff + %obj.currSpin;
- %obj.currSpin = %newRot;
- %accelMode = 3;
- %angVel = 0;
-
- if(%haltGate)
- {
- for(%i=0;%i<2;%i++)
- {
- %obj.stopAudio(%i);
- cancel(%obj.GateRollSched[%i]);
- }
- return;
- }
- }
- else
- {
- %newRot = (%accelRate / -2) * (%time * %time) + %angVel * %time + %obj.currSpin;
- %angVel -= %accelRate * %time; %obj.currSpin = %newRot;
- }
- }
- else if(%accelMode == 3)
- {
- for(%i=0;%i<2;%i++)
- {
- %obj.stopAudio(%i);
- cancel(%obj.GateRollSched[%i]);
- }
- //%rot = ((%goal-1)/-39)*360; %obj.currSpin = %rot;
- %rot = %obj.currSpin;
-
- %for = %obj.getForwardVector();
- %hLen = vectorLen(getWords(%for, 0, 1));
- %vAng = mAtan(getWord(%for, 2), %hLen) * (180 / $PI);
- %hAng = mAtan(getWord(%for, 0), getWord(%for, 1)) * (180 / $PI);
- if(mAbs(vectorDot(%obj.getUpVector(), "0 0 1")) > 0.999) %hAng *= -1;
- %spinObj.setTransform(%obj.getPosition() SPC eulerToAxis(%vAng SPC -%rot SPC %hAng));
-
- %obj.DialSched = %obj.schedule(1520, "DiallingSequence", restWords(%address), %origAddr, -1, -1, 0, 0, !%spinDir);
- %obj.ChevronLockAnim(0, %words == 1);
- for(%i=0;%i<2;%i++)
- serverPlay3D(ChevronLocked_Sound, %obj.ChevF0.getPosition());
- if(%words > 1)
- {
- %sequence = "1 2 3 6 7 8 4 5";
- %word = getWordCount(%origAddr) - %words;
- %obj.schedule(1040, "ChevronLightAnim", getWord(%sequence, %word), 1, 0);
- }
- else
- {
- if(getWord(%origAddr, getWordCount(%origAddr) - 1) != %obj.pointOfOrigin
- || getWordCount(%origAddr) <= 1)
- {
- if(isObject(%dhd = %obj.dhd))
- {
- %dhd.dialSequence = "";
- for(%i=0;%i<19;%i++)
- {
- %dhd.ObjectLightAnim("Sym_A_"@%i, 0, 1, 0.2, 0.8, 0.1, 0.6, 0, 0);
- %dhd.ObjectLightAnim("Sym_B_"@%i, 0, 1, 0.2, 0.8, 0.1, 0.6, 0, 0);
- }
- }
- for(%i=0;%i<9;%i++)
- %obj.schedule(1920, "ChevronLightAnim", %i, 0, 1);
- %obj.setStargateState(0);
- return;
- }
- %mainAddr = getWords(%origAddr, 0, getWordCount(%origAddr) - 2);
- if(%mainAddr $= %obj.address)
- {
- if(isObject(%dhd = %obj.dhd))
- {
- %dhd.dialSequence = "";
- for(%i=0;%i<19;%i++)
- {
- %dhd.ObjectLightAnim("Sym_A_"@%i, 0, 1, 0.2, 0.8, 0.1, 0.6, 0, 0);
- %dhd.ObjectLightAnim("Sym_B_"@%i, 0, 1, 0.2, 0.8, 0.1, 0.6, 0, 0);
- }
- }
- for(%i=0;%i<9;%i++)
- %obj.schedule(1920, "ChevronLightAnim", %i, 0, 1);
- %obj.setStargateState(0);
- return;
- }
- %gates = StargateNetwork.getCount();
- for(%i=0;%i<%gates;%i++)
- {
- %gate = StargateNetwork.getObject(%i);
- if(%gate.address $= %mainAddr && %gate.gateState <= 1)
- {
- %obj.setStargateState(2);
- %gate.setStargateState(2);
- %gate.dhd.dialSequence = "";
- //for(%i=0;%i<9;%i++)
- // if(%i == 0 || %obj.ChevL[%i].isNodeLitLight)
- // {
- // %gate.ChevronLockAnim(%i, 1);
- // serverPlay3D(ChevronLocked_Sound, %gate.getPosition());
- // }
- for(%i=0;%i<9;%i++)
- if(%i == 0 || %obj.ChevL[%i].isNodeLitLight)
- {
- %gate.schedule(1520, "ChevronLockAnim", %i, 1);
- schedule(1520, 0, "serverPlay3D", ChevronLocked_Sound, %gate.getPosition());
- }
- else %gate.schedule(1520, "ChevronLockAnim", %i, 0);
- %obj.schedule(1920, "OpenStargate", %gate, %gate);
- %gate.schedule(1920, "OpenStargate", %obj);
- return;
- }
- }
-
- for(%i=0;%i<3;%i++)
- {
- %obj.stopAudio(%i);
- %obj.schedule(1520, "playAudio", %i, DialFail_Sound);
- }
- if(isObject(%dhd = %obj.dhd))
- {
- %dhd.dialSequence = "";
- for(%i=0;%i<19;%i++)
- {
- %dhd.ObjectLightAnim("Sym_A_"@%i, 0, 1, 0.2, 0.8, 0.1, 0.6, 0, 0);
- %dhd.ObjectLightAnim("Sym_B_"@%i, 0, 1, 0.2, 0.8, 0.1, 0.6, 0, 0);
- }
- }
- for(%i=0;%i<9;%i++)
- %obj.schedule(1920, "ChevronLightAnim", %i, 0, 1);
- %obj.setStargateState(0);
- if(%obj.autodialOnShutdown)
- {
- cancel(%obj.autodialSched);
- StargateAutodial(%obj, 90);
- }
- return;
- }
- return;
- }
-
- %for = %obj.getForwardVector();
- %hLen = vectorLen(getWords(%for, 0, 1));
- %vAng = mAtan(getWord(%for, 2), %hLen) * (180 / $PI);
- %hAng = mAtan(getWord(%for, 0), getWord(%for, 1)) * (180 / $PI);
- if(mAbs(vectorDot(%obj.getUpVector(), "0 0 1")) > 0.999) %hAng *= -1;
- %spinObj.setTransform(%obj.getPosition() SPC eulerToAxis(%vAng SPC -%obj.currSpin SPC %hAng));
-
- %obj.DialSched = %obj.schedule(16, "DiallingSequence", %address, %origAddr, %now, %spinStart, %accelMode, %angVel, %spinDir);
- }
- function StaticShape::OpenStargate(%obj, %goal, %linked, %cl)
- {
- cancel(%obj.DialSched);
- cancel(%obj.shutSched);
- cancel(%obj.hardShutSched);
- cancel(%obj.autodialSched);
- if(%obj.maxOpenTime > 0 && isObject(%linked))
- {
- %obj.shutSched = %obj.schedule((%obj.maxOpenTime * 1000) | 0, "CloseStargate");
- %obj.maxOpenTime = 0;
- }
- if(%obj.spawnMalpBotOnLock && isObject(%linked)) //Temporary
- {
- schedule(3000, 0, "createBotMALP", "0 12 2 0 0 1 3.14159", %obj);
- }
- for(%i=0;%i<3;%i++)
- {
- %obj.stopAudio(%i);
- cancel(%obj.GateRollSched[%i]);
- }
- %obj.schedule(0, "setStargateState", 2);
- %obj.horiz.setNodeColor("ALL", "1 1 1 1");
- %obj.hardShutSched = %obj.schedule(16, "HardShutStargate", 2314, getSimTime());
- for(%i=0;%i<3;%i++)
- %obj.schedule(0, "playAudio", %i, WormholeOpened_Sound);
- for(%i=0;%i<8;%i++)
- %obj.horiz.schedule(1008+32*%i, "unhideNode", "Layer"@(7-%i));
-
- %objFor = %obj.getForwardVector();
- %objUp = %obj.getUpVector();
- %objRight = vectorCross(%objFor, %objUp);
- %objPos = %obj.getPosition();
- %mask = $Typemasks::fxBrickAlwaysObjectType;
- %offset0 = vectorScale(%objUp, 0.05);
- %offset1 = vectorScale(%objRight, 0.05);
- %offset2 = vectorScale(%objUp, -0.05);
- %offset3 = vectorScale(%objRight, -0.05);
- %killKawoosh = 1;
- for(%i=0;%i<8;%i++)
- {
- for(%j=0;%j<24;%j++)
- {
- %killCount = 0;
- if(%i == 0 && %j != 0) continue;
- %mult = 0.45 * %i; //3.6 (radius of the wormhole) divided by 8 (number of raycast rings)
- %uVal = mSin(%j / 12 * $PI) * %mult; %rVal = mCos(%j / 12 * $PI) * %mult;
- %pos = vectorAdd(%objPos, vectorAdd(vectorScale(%objUp, %uVal), vectorScale(%objRight, %rVal)));
- for(%k=0;%k<4;%k++)
- {
- %end = vectorAdd(vectorAdd(%pos, %offset[%k]), vectorScale(%objFor, 0.5));
- %ray = containerRaycast(%pos, %end, %mask);
- if(!isObject(%hit = firstWord(%ray)) || !%hit.isColliding()) %killCount++;
- }
- if(%killCount == 4) { %killKawoosh = 0; break; }
- }
- if(!%killKawoosh) break;
- }
-
- if(!%killKawoosh)
- %obj.kawoosh.schedule(1232, "unhideNode", "ALL");
- %scale = getWord(%obj.getScale(), 2);
- for(%i=0;%i<120;%i++)
- {
- if(%i < 30) %colVal = mSin(%i/59*$PI);
- else if(!%killKawoosh && %i >= 90) %colVal = mSin((%i-60)/59*$PI);
- else %colVal = 1;
- if(!%killKawoosh)
- {
- %obj.kawoosh.schedule(1232+16*%i, "setScale", %scale SPC (mSin(%i/119*$PI)*%scale) SPC %scale);
- if(%i & 1) %obj.schedule(1232+16*%i, "SlayNearby", 0, mSin(%i/119*$PI)*13.32);
- %obj.kawoosh.schedule(1232+16*%i, "setNodeColor", "ALL", 1-%colVal SPC 1-%colVal/2@" 1 1");
- }
- %obj.horiz.schedule(1232+16*%i, "setNodeColor", "ALL", 1-%colVal SPC 1-%colVal/2@" 1 1");
- }
- if(!%killKawoosh)
- {
- %obj.kawoosh.schedule(3152, "hideNode", "ALL");
- for(%i=0;%i<16;%i++)
- %obj.horiz.schedule(3152+16*%i, "setNodeColor", "ALL", 1-mSin(%i/31*$PI) SPC 1-mSin(%i/31*$PI)/2@" 1 1");
- }
- for(%i=0;%i<2;%i++)
- %obj.schedule(4000, "playAudio", %i, EventHorizon_Sound);
- %obj.schedule(4000, "setStargateState", 3);
- %obj.SGWormholeSched = %obj.schedule(3152, "StargateWormhole", %goal, getSimTime());
- if(isObject(%linked))
- {
- cancel(%linked.shutSched);
- cancel(%linked.hardShutSched);
- initContainerRadiusSearch(%linked.getPosition(), 16, $Typemasks::fxBrickAlwaysObjectType);
- while(isObject(%brick = containerSearchNext()))
- %brick.WormholeIncoming(%cl);
- initContainerRadiusSearch(%obj.getPosition(), 16, $Typemasks::fxBrickAlwaysObjectType);
- while(isObject(%brick = containerSearchNext()))
- %brick.WormholeOutgoing(%cl);
- %origWorldName = %obj.worldName $= "" ? "a Hidden System" : %obj.worldName;
- %linkedWorldName = %linked.worldName $= "" ? "a Hidden System" : %linked.worldName;
- echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] Wormhole opened from " @ %origWorldName @ " (" @ %obj.address @ ") to " @ %linkedWorldName @ " (" @ %linked.address @ ")");
- %obj.linkedGate = %linked;
- %linked.masterGate = %obj;
- }
- }
- function StaticShape::CloseStargate(%obj)
- {
- %obj.setStargateState(4);
- cancel(%obj.shutSched);
- cancel(%obj.hardShutSched);
- cancel(%obj.autodialSched); %hop = %obj;
- while(isObject(%nextHop = %hop.redirectToGate))
- %hop.redirectToGate = "";
- if(isObject(%dhd = %obj.dhd))
- {
- %dhd.ObjectLightAnim("BUTTON", 0, 1, 0.5, 0.5, 0, 0, 0, 0);
- for(%i=0;%i<19;%i++)
- {
- %dhd.ObjectLightAnim("SYM_A_"@%i, 0, 1, 0.2, 0.8, 0.1, 0.6, 0, 0);
- %dhd.ObjectLightAnim("SYM_B_"@%i, 0, 1, 0.2, 0.8, 0.1, 0.6, 0, 0);
- }
- }
- for(%i=0;%i<9;%i++)
- %obj.schedule(1680, "ChevronLightAnim", %i, 0, 1);
- for(%i=0;%i<3;%i++)
- %obj.playAudio(%i, WormholeClosed_Sound);
- for(%i=0;%i<80;%i++)
- {
- %value = mSin((%i + 80)/159*$PI);
- %obj.horiz.schedule(16*%i, "setNodeColor", "ALL", 1-%value SPC 1-%value/2@" 1 1");
- }
- %obj.schedule(1296, "SlayNearby", 1);
- for(%i=0;%i<39;%i++)
- %obj.horiz.schedule(1296+16*%i, "setNodeColor", "ALL", "1 1 1 "@1-%i/39);
- %obj.horiz.schedule(1920, "hideNode", "ALL");
- %obj.schedule(1920, "setStargateState", 0);
- if(isObject(%linked = %obj.linkedGate))
- {
- %origWorldName = %obj.worldName $= "" ? "a Hidden System" : %obj.worldName;
- %linkedWorldName = %linked.worldName $= "" ? "a Hidden System" : %linked.worldName;
- echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] Wormhole closed from " @ %origWorldName @ " (" @ %obj.address @ ") to " @ %linkedWorldName @ " (" @ %linked.address @ ")");
- %linked.CloseStargate();
- %linked.schedule(1920, "clearLinkedGate");
- %obj.schedule(1920, "clearLinkedGate");
- }
- initContainerRadiusSearch(%obj.getPosition(), 16, $Typemasks::fxBrickAlwaysObjectType);
- while(isObject(%brick = containerSearchNext()))
- %brick.schedule(1920, "WormholeShutdown", %cl);
- if(%obj.autodialOnShutdown)
- {
- cancel(%obj.autodialSched);
- %obj.autodialSched = schedule(4920, 0, "StargateAutodial", %obj, 90);
- }
- }
- function StaticShape::clearLinkedGate(%obj)
- { %obj.masterGate = ""; %obj.linkedGate = ""; }
- function StaticShape::HardShutStargate(%obj, %timeLeft, %last)
- {
- if(!isObject(%this)) return;
- cancel(%obj.hardShutSched);
- %time = vectorDist(%last, %now = getSimTime()) / 1000;
- %timeLeft -= %time; if(%timeLeft <= 0) { %obj.CloseStargate(); return; }
- %obj.hardShutSched = %obj.schedule(16, "HardShutStargate", %timeLeft, %now);
- }
- function StaticShape::StargateWormhole(%this, %dest, %last)
- {
- if(!isObject(%this)) return;
- cancel(%this.SGWormholeSched);
- %scale = getWord(%this.getScale(), 2);
- %time = vectorDist(%last, %now = getSimTime()) / 1000;
- %this.SGWormholeSched = %this.schedule(48, "StargateWormhole", %dest, %now);
- %mask = $Typemasks::CorpseObjectType | $Typemasks::PlayerObjectType |
- $Typemasks::ProjectileObjectType | $Typemasks::VehicleObjectType;
- %playerMask = $Typemasks::CorpseObjectType | $Typemasks::PlayerObjectType;
- initContainerRadiusSearch(%loc = %this.getPosition(), 16 * %scale, %mask);
- while(isObject(%obj = containerSearchNext()))
- {
- %ignore = 0;
- for(%i=0;%i<%this.trackCount;%i++)
- if(%this.trackObj[%i] == %obj)
- { %ignore = 1; break; }
- if(%ignore) continue;
- %this.trackObj[-1+%this.trackCount++] = %obj;
- }
- while(isObject(%nextHop = %dest.redirectToGate) && !%hoppedTo[%nextHop])
- {
- %hoppedTo[%nextHop] = 1;
- %dest = %nextHop;
- }
- %destFor = %dest.getForwardVector();
- %destUp = %dest.getUpVector();
- %destPos = %dest.getPosition();
- for(%i=0;%i<%this.trackCount;%i++)
- {
- %obj = %this.trackObj[%i];
- if(!isObject(%obj))
- { %shift++; continue; }
- %type = %obj.getType();
- if(!(%type & $Typemasks::ProjectileObjectType) && isObject(%obj.getObjectMount())) continue;
- if(%type & %playerMask)
- %pos = %obj.getHackPosition();
- else if(%type & $Typemasks::VehicleObjectType)
- %pos = %obj.getWorldBoxCenter();
- else if(%type & $Typemasks::ProjectileObjectType)
- %pos = vectorAdd(%obj.getPosition(), vectorScale(%obj.getVelocity(), 0.08));
- if(vectorDist(%pos, %loc) > 16 * %scale)
- { %shift++; continue; }
- else %this.trackObj[%i - %shift] = %this.trackObj[%i];
- if((%this.SGLastDetect[%obj] | 0) != (%last | 0))
- {
- %oPos = %pos;
- %this.SGLastVel[%obj] = %obj.getVelocity();
- }
- else %oPos = %this.SGLastPos[%obj];
- %dir = vectorSub(%pos, %loc);
- %oDir = vectorSub(%oPos, %loc);
- %for = %this.getForwardVector();
- %up = %this.getUpVector();
- %right = vectorCross(%for, %up);
- %rDir = vectorDot(%dir, %for) SPC vectorDot(%dir, %right) SPC vectorDot(%dir, %up);
- %roDir = vectorDot(%oDir, %for) SPC vectorDot(%oDir, %right) SPC vectorDot(%oDir, %up);
- if(getWord(%rDir, 0) / getWord(%roDir, 0) < 0)
- {
- %len = getWord(%rDir, 0) / (getWord(%rDir, 0) - getWord(%roDir, 0));
- %yDiff = getWord(%rDir, 1) - getWord(%roDir, 1);
- %zDiff = getWord(%rDir, 2) - getWord(%roDir, 2);
- %hit = "0 "@getWord(%rDir, 1) + %yDiff * %len SPC getWord(%rDir, 2) + %zDiff * %len;
- if(vectorLen(%hit) <= 3.6 * %scale)
- {
- if(getWord(%rDir, 0) <= 0)
- {
- if(isObject(%this.masterGate))
- {
- if(%type & %playerMask)
- {
- %obj.spawnTime = 0;
- %obj.damage(%obj, %obj.position, 10000, $DamageType::Stargate_Backwards);
- echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] " @ %obj.cl.name @ " died from attempting to go through a Stargate backwards.");
- if(%obj.getState() $= "DEAD") { %obj.delete(); }
- }
- else if(%type & $Typemasks::VehicleObjectType)
- {
- %mounts = %obj.getDatablock().numMountPoints;
- for(%i=0;%i<%mounts;%i++)
- {
- %passenger = %obj.getMountedObject(%i);
- %passenger.spawnTime = 0;
- %passenger.damage(%passenger, %passenger.position, 10000, $DamageType::Stargate_Backwards);
- echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] " @ %passenger.client.name @ " died on a vehicle from attempting to go through a Stargate backwards.");
- if(%passenger.getState() $= "DEAD") { %passenger.delete(); }
- }
-
- %spawn = %obj.spawnBrick;
- if(isObject(%spawn))
- %spawn.respawnVehicle();
- else %obj.delete();
- }
- else if(%type & $Typemasks::ProjectileObjectType)
- %obj.delete();
- }
- else
- {
- %vel = %this.SGLastVel[%obj];
- %rPos = vectorDot(%hit, %right);
- %uPos = vectorDot(%hit, %up);
- //%destHit = vectorAdd(vectorAdd(vectorScale(%destRight, %rPos), vectorScale(%destUp, %uPos)), %dest);
- %destRight = vectorCross(%destFor, %destUp);
- %destHit = vectorAdd(%destPos, vectorAdd(vectorAdd(vectorScale(%destFor, -getWord(%rDir, 0)), vectorScale(%destRight, -getWord(%rDir, 1))), vectorScale(%destUp, getWord(%rDir, 2))));
- %index = mAbs(getWord(%destFor, 0)) < mAbs(getWord(%destFor, 1));
- %destHit = setWord(%destHit, %index, getWord(%destPos, %index));
- %objHit = vectorAdd(%this.getPosition(), vectorAdd(
- vectorScale(%right, %rPos), vectorScale(%up, %uPos)));
- serverPlay3D(ObjectEntrance_Sound, %objHit);
- %mask = $Typemasks::fxBrickAlwaysObjectType;
- %ray = containerRaycast(%destHit, vectorAdd(%destHit, vectorScale(%destFor, 0.8)), %mask);
- if(isObject(%ray) && %ray.isColliding())
- {
- if(%type & %playerMask)
- {
- %obj.spawnTime = 0;
- for(%j=0;%j<3;%j++) serverPlay3D(IrisImpact_Sound, %destHit);
- %obj.damage(%obj, %obj.position, 10000, $DamageType::Stargate_IrisSlam);
- echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] " @ %obj.client.name @ " died from attempting to go through a Stargate with its' iris closed.");
- if(%obj.getState() $= "DEAD") { %obj.delete(); } continue;
- }
- else if(%type & $Typemasks::VehicleObjectType)
- {
- %mounts = %obj.getDatablock().numMountPoints;
- for(%i=0;%i<%mounts;%i++)
- {
- %passenger = %obj.getMountedObject(%i); %passenger.spawnTime = 0;
- %passenger.damage(%passenger, %passenger.position, 10000, $DamageType::Stargate_IrisSlam);
- echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] " @ %passenger.client.name @ " died from attempting to go through a Stargate with its' iris closed.");
- if(%passenger.getState() $= "DEAD") { %passenger.delete(); }
- }
-
- for(%j=0;%j<5;%j++) serverPlay3D(IrisImpact_Sound, %destHit);
- %spawn = %obj.spawnBrick;
- if(isObject(%spawn))
- %spawn.respawnVehicle();
- else %obj.delete();
- continue;
- }
- else if(%type & $Typemasks::ProjectileObjectType)
- { serverPlay3D(IrisImpact_Sound, %destHit); %obj.delete(); continue; }
- }
- else serverPlay3D(ObjectEntrance_Sound, %destHit);
- if(%obj.getClassName() $= "Player" && $Pref::Server::Stargate::EnvironMode)
- {
- if(!isObject(EnvGuiMaster))
- new ScriptObject(EnvGuiMaster)
- { isEnvMaster = 1; isAdmin = 1; isSuperAdmin = 1; };
- %id = skyTexToIDX(%dest.skyTex);
- if(%id != -1) servercmdEnvGui_SetVar(EnvGuiMaster, "SkyIDX", %id);
- %id = groundTexToIDX(%dest.groundTex);
- if(%id != -1) servercmdEnvGui_SetVar(EnvGuiMaster, "GroundIDX", %id);
- if(%dest.dLightColor !$= "") servercmdEnvGui_SetVar(EnvGuiMaster, "DirectLightColor", %dest.dLightColor);
- if(%dest.aLightColor !$= "") servercmdEnvGui_SetVar(EnvGuiMaster, "AmbientLightColor", %dest.aLightColor);
- if(%dest.shadowColor !$= "") servercmdEnvGui_SetVar(EnvGuiMaster, "ShadowColor", %dest.shadowColor);
- if(%dest.sunAzim !$= "" || %dest.sunElev !$= "")
- {
- if(%dest.sunAzim !$= "") Sun.azimuth = %dest.sunAzim;
- if(%dest.sunElev !$= "") Sun.elevation = %dest.sunElev;
- Sun.sendUpdate();
- }
- Sky.visibleDistance = getMin($EnvGuiServer::VisibleDistance, 225);
- Sky.sendUpdate();
- }
- %destRight = vectorCross(%destFor, %destUp);
- %tele = vectorAdd(%destPos, vectorAdd(vectorAdd(
- vectorScale(%destFor, -getWord(%rDir, 0)),
- vectorScale(%destRight, -getWord(%rDir, 1))),
- vectorScale(%destUp, getWord(%rDir, 2))));
- if(%type & $Typemasks::PlayerObjectType)
- %offset = vectorSub(%obj.getHackPosition(), %obj.getPosition());
- else if(%type & $Typemasks::PlayerObjectType)
- %offset = vectorSub(%obj.getWorldBoxCenter(), %obj.getPosition());
- %tele = vectorSub(%tele, %offset);
-
- %oFor = %obj.getForwardVector();
- %fFor = vectorDot(%oFor, %for);
- %rFor = vectorDot(%oFor, %right);
- %uFor = vectorDot(%oFor, %up);
- %oFor = vectorAdd(vectorScale(%destFor, -%fFor), vectorScale(%destRight, -%rFor));
- %ang = mAtan(getWord(%oFor, 0), getWord(%oFor, 1));
- if(%type & $Typemasks::ProjectileObjectType)
- {
- %fVel = vectorDot(%vel, %for);
- %rVel = vectorDot(%vel, %right);
- %uVel = vectorDot(%vel, %up);
- %outVel = vectorAdd(vectorAdd(vectorScale(%destFor, -%fVel),
- vectorScale(%destRight, -%rVel)), vectorScale(%destUp, %uVel));
-
- %obj.setName("SGTeleport_OldProjectile");
- %proj = new Projectile(:SGTeleport_OldProjectile)
- {
- initialPosition = %tele;
- initialVelocity = %outVel;
- };
- MissionCleanup.add(%proj);
- %obj.delete();
-
- //if(%this.gateState == 2 || %this.gateState == 3)
- //{
- // if(getTimeRemaining(%this.shutSched) <= 5000)
- // {
- // cancel(%this.shutSched);
- // %this.shutSched = %this.schedule(5000, "CloseStargate");
- // }
- //}
- }
- else if(!isObject(%obj.getObjectMount()))
- {
- if(%type & $Typemasks::VehicleObjectType)
- {
- %mounts = %obj.getDatablock().numMountPoints;
- for(%i=0;%i<%mounts;%i++)
- {
- %passenger = %obj.getMountedObject(%i);
- if(isObject(%cl = %passenger.client))
- {
- %origWorldName = %this.worldName $= "" ? "a Hidden System" : %this.worldName;
- %linkedWorldName = %this.linkedGate.worldName $= "" ? "a Hidden System" : %this.linkedGate.worldName;
- echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] Player " @ %cl.name @ " travelled from " @ %origWorldName @ " (" @ %this.address @ ") to " @ %linkedWorldName @ " ("@ %this.linkedGate.address @ ")");
- %cl.Stargate = %this.linkedGate;
- %cl.StargatePos = %destPos;
- %destAng = mAtan(getWords(%destFor, 0), getWords(%destFor, 1));
- %cl.StargateSpawn = vectorAdd(%destPos, vectorScale(%destFor, 4))@" 0 0 1 "@%destAng;
- }
- }
- }
-
- %obj.setTransform(%tele@" 0 0 1 "@%ang);
-
- %fVel = vectorDot(%vel, %for);
- %rVel = vectorDot(%vel, %right);
- %uVel = vectorDot(%vel, %up);
- %obj.setVelocity(vectorAdd(vectorAdd(vectorScale(%destFor, -%fVel),
- vectorScale(%destRight, -%rVel)), vectorScale(%destUp, %uVel)));
-
- if(isObject(%cl = %obj.client))
- {
- %origWorldName = %this.worldName $= "" ? "a Hidden System" : %this.worldName;
- %linkedWorldName = %this.linkedGate.worldName $= "" ? "a Hidden System" : %this.linkedGate.worldName;
- echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] Player " @ %cl.name @ " travelled from " @ %origWorldName @ " (" @ %this.address @ ") to " @ %linkedWorldName @ " ("@ %this.linkedGate.address @ ")");
- %cl.Stargate = %this.linkedGate;
- %cl.StargatePos = %destPos;
- %destAng = mAtan(getWords(%destFor, 0), getWords(%destFor, 1));
- %cl.StargateSpawn = vectorAdd(%destPos, vectorScale(%destFor, 4))@" 0 0 1 "@%destAng;
- }
-
- if(%this.gateState == 2 || %this.gateState == 3)
- {
- if(!(%this.dontCloseOnObjectEnter ||
- (%obj.getClassName() $= "AIPlayer" && %this.dontCloseOnBotEnter)))
- {
- cancel(%this.shutSched);
- %this.shutSched = %this.schedule(20000, "CloseStargate");
- }
- }
- }
- }
- }
- else
- {
- if(%type & $Typemasks::PlayerObjectType)
- {
- %obj.spawnTime = 0;
- %obj.damage(%obj, %obj.position, 10000, $DamageType::Stargate_WrongSide);
- echo($obj);
- echo(%obj.name);
- echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] " @ %obj.client.name @ " died from attempting to go through a Stargate from the other side.");
- if(%obj.getState() $= "DEAD") { %obj.delete(); }
- }
- else if(%type & $Typemasks::VehicleObjectType)
- {
- %mounts = %obj.getDatablock().numMountPoints;
- for(%i=0;%i<%mounts;%i++)
- {
- %passenger = %obj.getMountedObject(%i);
- if(!isObject(%passenger)) continue;
- %passenger.spawnTime = 0;
- %passenger.damage(%passenger, %passenger.position, 10000, $DamageType::Stargate_WrongSide);
- echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] " @ %passenger.client.name @ " died from attempting to go through a Stargate from the other side.");
- if(%passenger.getState() $= "DEAD") { %passenger.delete(); }
- }
-
- %spawn = %obj.spawnBrick;
- if(isObject(%spawn))
- %spawn.respawnVehicle();
- else %obj.delete();
- }
- else if(%type & $Typemasks::ProjectileObjectType)
- %obj.delete();
- }
- }
- }
- if(isObject(%obj))
- {
- %this.SGLastDetect[%obj] = %now;
- %this.SGLastPos[%obj] = %pos;
- %this.SGLastVel[%obj] = %obj.getVelocity();
- }
- else %shift++;
- }
- %this.trackCount -= %shift;
- }
- function StaticShape::SlayNearby(%this, %mode, %len)
- {
- %scale = getWord(%this.getScale(), 2);
- if(%mode == 0)
- {
- %loc = %this.getPosition();
- %for = %this.getForwardVector();
- %up = %this.getUpVector();
- %right = vectorCross(%for, %up);
- initContainerRadiusSearch(vectorAdd(%loc, vectorScale(%for, 10)), %scale * 16 + 8, $Typemasks::PlayerObjectType);
- while(isObject(%obj = containerSearchNext()))
- {
- %pos = %obj.getHackPosition();
- %dir = vectorSub(%pos, %loc);
- %objF = vectorDot(%dir, %for);
- %objU = vectorDot(%dir, %up);
- %objR = vectorDot(%dir, %right);
- %objOffset = vectorLen(%objU SPC %objR);
- if(%objOffset > 3.6 * %scale) continue;
- if(mAbs(%objF) <= 0.36)
- {
- %obj.spawnTime = 0;
- %obj.damage(%obj, %obj.position, 10000, $DamageType::Stargate_Kawoosh);
- echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] " @ %obj.client.name @ " died from attempting to go through a Stargate from the other side.");
- if(%obj.getState() $= "DEAD") { %obj.delete(); }
- }
- %objOffset /= 3.6 * %scale;
- %kLen = %len - (%objOffset * %objOffset * %len);
- if(%objF < %kLen && %objF > 0)
- {
- %obj.spawnTime = 0;
- %obj.damage(%obj, %obj.position, 10000, $DamageType::Stargate_Kawoosh);
- echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] " @ %obj.client.name @ " died from attempting to go through a Stargate from the other side.");
- if(%obj.getState() $= "DEAD") { %obj.delete(); }
- }
- }
- }
- else if(%mode == 1)
- {
- initContainerRadiusSearch(%loc = %this.getPosition(), %scale * 10, $Typemasks::PlayerObjectType);
- while(isObject(%obj = containerSearchNext()))
- {
- %pos = %obj.getHackPosition();
- if(vectorDist(%pos, %loc) > 3.6 * %scale) continue;
- %dir = vectorSub(%pos, %loc);
- if(mAbs(vectorDot(%dir, %this.getForwardVector())) <= 0.35)
- {
- %obj.spawnTime = 0;
- %obj.damage(%obj, %obj.position, 10000, $DamageType::Stargate_Telefrag);
- echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] " @ %obj.client.name @ " died in a closing wormhole.");
- if(%obj.getState() $= "DEAD") { %obj.delete(); }
- }
- }
- cancel(%this.SGWormholeSched);
- }
- }
- function StaticShape::setStargateState(%obj, %state)
- {
- if(%state == 0)
- {
- %obj.isOpened = 0;
- %obj.isOpening = 0;
- %obj.isClosed = 1;
- %obj.isClosing = 0;
- %obj.isDialing = 0;
- %obj.gateState = 0;
- }
- else if(%state == 1)
- {
- %obj.isOpened = 0;
- %obj.isOpening = 0;
- %obj.isClosed = 0;
- %obj.isClosing = 0;
- %obj.isDialing = 1;
- %obj.gateState = 1;
- }
- else if(%state == 2)
- {
- %obj.isOpened = 0;
- %obj.isOpening = 1;
- %obj.isClosed = 0;
- %obj.isClosing = 0;
- %obj.isDialing = 0;
- %obj.gateState = 2;
- }
- else if(%state == 3)
- {
- %obj.isOpened = 1;
- %obj.isOpening = 0;
- %obj.isClosed = 0;
- %obj.isClosing = 0;
- %obj.isDialing = 0;
- %obj.gateState = 3;
- }
- else if(%state == 4)
- {
- %obj.isOpened = 0;
- %obj.isOpening = 0;
- %obj.isClosed = 0;
- %obj.isClosing = 1;
- %obj.isDialing = 0;
- %obj.gateState = 4;
- }
- }
- function StaticShape::DeleteStargate(%obj)
- {
- for(%i=0;%i<3;%i++)
- %obj.stopAudio(%i);
- for(%i=0;%i<9;%i++)
- {
- %obj.ChevB[%i].delete();
- %obj.ChevF[%i].delete();
- %obj.ChevL[%i].delete();
- }
- %obj.kawoosh.delete();
- %obj.horiz.delete();
- %obj.inner.delete();
- %obj.middle.delete();
- %obj.dhd.delete();
- %obj.delete();
- }
- function StaticShape::UpdateStargateTrans(%obj, %trans)
- {
- %obj.setTransform(%trans);
- %obj.middle.setTransform(%trans);
- %obj.inner.setTransform(%trans);
- %obj.horiz.setTransform(%trans);
- %obj.kawoosh.setTransform(%trans);
-
- %pos = getWords(%trans, 0, 2);
- %for = %obj.getForwardVector();
- %up = %obj.getUpVector();
- %right = vectorCross(%for, %up);
- %hLen = vectorLen(getWords(%for, 0, 1));
- %vAng = mAtan(getWord(%for, 2), %hLen) * (180 / $PI);
- %hAng = mAtan(getWord(%for, 0), getWord(%for, 1)) * (180 / $PI);
- %radius = getWord(%obj.getScale(), 2) * 4.2;
- if(mAbs(vectorDot(%up, "0 0 1")) <= 0.999)
- {
- %hAng += 180; %vAng = 180 - %vAng;
- if(mAbs(vectorDot(%for, "0 0 1")) <= 0.999) %rot += 180;
- }
- for(%i=0;%i<9;%i++)
- {
- %offset = vectorAdd(vectorScale(%right, mSin(%i*$PI/4.5)*-%radius),
- vectorScale(%up, mCos(%i*$PI/4.5)*%radius));
- %trans = vectorAdd(%pos, %offset) SPC eulerToAxis(%vAng SPC -360*(%i/9)+%rot SPC -%hAng);
-
- %obj.ChevB[%i].setTransform(%trans);
- %obj.ChevF[%i].setTransform(%trans);
- %obj.ChevL[%i].setTransform(%trans);
-
- %obj.ChevB[%i].ChevronPosition = getWords(%trans, 0, 3);
- %obj.ChevL[%i].ChevronPosition = getWords(%trans, 0, 3);
- }
- }
- function StaticShape::UpdateStargateScale(%obj, %scalar)
- {
- %scalar = getWord(%scalar, 0) * 1;
- %scale = %scalar SPC %scalar SPC %scalar;
-
- %obj.setScale(%scale);
- %obj.middle.setScale(%scale);
- %obj.inner.setScale(%scale);
- %obj.horiz.setScale(%scale);
- %obj.kawoosh.setScale(%scale);
-
- %pos = getWords(%trans, 0, 2);
- %for = %obj.getForwardVector();
- %up = %obj.getUpVector();
- %right = vectorCross(%for, %up);
- %hLen = vectorLen(getWords(%for, 0, 1));
- %vAng = mAtan(getWord(%for, 2), %hLen) * (180 / $PI);
- %hAng = mAtan(getWord(%for, 0), getWord(%for, 1)) * (180 / $PI);
- %radius = getWord(%obj.getScale(), 2) * 4.2;
- if(mAbs(vectorDot(%up, "0 0 1")) <= 0.999)
- {
- %hAng += 180; %vAng = 180 - %vAng;
- if(mAbs(vectorDot(%for, "0 0 1")) <= 0.999) %rot += 180;
- }
- for(%i=0;%i<9;%i++)
- {
- %offset = vectorAdd(vectorScale(%right, mSin(%i*$PI/4.5)*-%radius),
- vectorScale(%up, mCos(%i*$PI/4.5)*%radius));
- %trans = vectorAdd(%pos, %offset) SPC eulerToAxis(%vAng SPC -360*(%i/9)+%rot SPC -%hAng);
-
- %obj.ChevB[%i].setScale(%scale);
- %obj.ChevF[%i].setScale(%scale);
- %obj.ChevL[%i].setScale(%scale);
-
- %obj.ChevB[%i].setTransform(%trans);
- %obj.ChevF[%i].setTransform(%trans);
- %obj.ChevL[%i].setTransform(%trans);
-
- %obj.ChevB[%i].ChevronPosition = getWords(%trans, 0, 3);
- %obj.ChevL[%i].ChevronPosition = getWords(%trans, 0, 3);
- }
- }
- function StaticShape::copyEnvironment(%gate)
- {
- %gate.skyTex = Sky.materialList;
- %gate.groundTex = GroundPlane.topTexture;
- %gate.dLightColor = Sun.color;
- %gate.aLightColor = Sun.ambient;
- %gate.shadowColor = Sun.shadowColor;
- %gate.sunAzim = Sun.azimuth;
- %gate.sunElev = Sun.elevation;
- }
- //Destiny gate symbols
- //Symbol 1: 9.457616760
- //Symbol 2: 16.557627498
- //Delta: 7.100010738
- //Symbol 5: 49.457612532
- //Delta: 39.999995772
- //MakeDHD(MakeStargate("0 0.25 4.5"), "0 20 1 1 0 0 0");
- //for(%i=0;%i<9;%i++)%hit.ChevronLightAnim(%i,0,1);%hit.horiz.hideNode("ALL");for(%i=0;%i<2;%i++)%hit.playAudio(%i,WormholeClosed_Sound);
- //%hit.DialStargate("27 7 15 32 12 30 1"); Abydos
- //%hit.DialStargate("9 18 27 15 21 36 1"); Final Destination
- //%hit.DialStargate("11 27 23 16 33 3 9 1"); Othala
- //2 9 11 14 29 35
- //%hit.DialStargate("6 0 0 0 0 0 5 0 1"); //Destiny - known symbols
- //%hit.DialStargate("6 35 11 2 14 9 5 29 1"); //Destiny - assumed address
- function MakeGates()
- {
- if(!$MadeGates)
- {
- $MadeGates = 1;
- %earthGate = MakeStargate("0 0.25 5.3 "@eulerToAxis("0 0 0"), "28 26 5 36 11 29", 1, "Earth");
- $gateObjs["28 26 5 36 11 29"] = %earthGate;
- if(!isWriteableFileName("config/List.txt")) pathCopy("./List.txt", "config/List.txt", true);
- if(isFile("config/List.txt")) {
- %file = new FileObject();
- %file.openForRead("config/List.txt");
- echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] Loading planets in List.txt");
- while(!%file.isEOF())
- {
- %line = %file.readLine();
- echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] Loading line " @ %line);
- %addresses[-1+%addresses++] = %line;
- }
- %file.close();
- %file.delete();
- echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] Planets successfully loaded");
- } else {
- error("ERROR: MakeGates(): Failed to open file List.txt for reading");
- return;
- }
-
- //%address[-1+%address++] = "9-18-27-15-21-36 21";
- //%address[-1+%address++] = "11-27-23-16-33-3-9 1 Othala";
- //%address[-1+%address++] = "6-35-11-2-14-9-5-29 1 Destiny";
-
- // Please add a BIGGER seed than 671.... and preferably a prime one over 100k+...
- %id = createRandContext($Pref::Server::Stargate::RNGSeed); //*Magick* Mage's BL_ID
- %dupcheck = $Pref::Server::Stargate::DuplicateCheck ? "duplicate check on" : "duplicate check off";
- echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] Generating " @ $Pref::Server::Stargate::MaxHiddenAddresses @ " random addresses using seed " @ $Pref::Server::Stargate::RNGSeed @ ", " @ %dupcheck);
- while(%addresses < $Pref::Server::Stargate::MaxHiddenAddresses)
- {
- %randAddr = "";
- for(%i=0;%i<6;%i++)
- {
- %symbol = mFloor(rand(%id, 2, 40));
- if(%symbol >= 40) %symbol = 39;
- %flag = 1;
- while(%flag)
- {
- %flag = 0;
- for(%j=0;%j<%i;%j++)
- if(getWord(%randAddr, %j) == %symbol)
- {
- %symbol = mFloor(rand(%id, 2, 40));
- if(%symbol >= 40) %symbol = 39;
- %flag = 1;
- }
- }
- %randAddr = trim(%randAddr SPC %symbol);
- }
- %randAddr = strReplace(%randAddr, " ", "-");
- if($Pref::Server::Stargate::DuplicateCheck) {
- %duplicate = 0;
- if($gateObjs[%randAddr]) %duplicate = 1;
- if(%duplicate == 1) {
- %randAddr = "";
- for(%i=0;%i<6;%i++)
- {
- %symbol = mFloor(rand(%id, 2, 40));
- if(%symbol >= 40) %symbol = 39;
- %flag = 1;
- while(%flag)
- {
- %flag = 0;
- for(%j=0;%j<%i;%j++)
- if(getWord(%randAddr, %j) == %symbol)
- {
- %symbol = mFloor(rand(%id, 2, 40));
- if(%symbol >= 40) %symbol = 39;
- %flag = 1;
- }
- }
- %randAddr = trim(%randAddr SPC %symbol);
- }
- %randAddr = strReplace(%randAddr, " ", "-");
- }
- }
- %addresses[-1+%addresses++] = %randAddr;
- $gateObjs[%randAddr] = %randAddr;
- }
- echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] Generation complete; creating Stargates");
- for(%y=0;%y<33;%y++)
- {
- %nVal = mFloatLength((%y - 16) * 443.405 * 2, 0) / 2;
- %width = 33 - mAbs(%y - 16);
- for(%x=0;%x<%width;%x++)
- {
- %eVal = (%x * 512) - ((%width - 1) * 256);
- if(%nVal == 0 && %eVal == 0) continue;
-
- %addrID = mFloor(rand(%id, 0, %addresses));
- if(%addrID >= %addresses) %addrID = %addresses - 1;
- %gateAddr = strReplace(getWord(%addr = %addresses[%addrID], 0), "-", " ");
- if(getWord(%addr, 1) !$= "")
- {
- %origin = getWord(%addr, 1);
- rand(%id, 2, 40);
- }
- else
- {
- %origin = mFloor(rand(%id, 2, 40));
- if(%origin >= 40)
- %origin = 39;
- }
- %ang = mFloor(rand(%id, 0, 4)) * 90;
- %gateName = strReplace(getWord(%addr, 2), "_", " ");
-
- %shift = 0;
- for(%i=0;%i<%addresses;%i++)
- if(%i == %addrID) %shift++;
- else %addresses[%i - %shift] = %addresses[%i];
- %addresses -= %shift;
-
- %gate = MakeStargate(vectorAdd(%eVal SPC %nVal SPC 4.7,
- vectorScale(-mSin(%ang/180*$PI) SPC mCos(%ang/180*$PI), -0.25))
- SPC eulerToAxis("0 0 "@%ang), %gateAddr, %origin, %gateName);
- %dhd = MakeDHD(%gate, vectorAdd(%eVal SPC %nVal SPC 1.2,
- vectorScale(-mSin(%ang/180*$PI) SPC mCos(%ang/180*$PI), 20))
- SPC eulerToAxis("0 0 "@%ang));
- $gateObjs[%gateAddr] = %gate;
- switch(%addrID)
- {
- case 0:
- %gate.groundTex = "./TTasphalt01.jpg";
- %gate.skyTex = "./Slate_Storm.dml";
- %gate.sunAzim = 0;
- %gate.sunElev = 90;
- }
- }
- }
- %earthGate.groundTex = "./cement-pebbled.jpg";
- %earthGate.skyTex = "./Blue2.dml";
- %earthGate.sunAzim = 0;
- %earthGate.sunElev = 30;
- %earthGate.autodialOnShutdown = 1;
- %earthGate.spawnMalpBotOnLock = 1; //Temporary
- %earthGate.dontCloseOnObjectEnter = 0;
- %earthGate.dontCloseOnBotEnter = 1;
- schedule(15000, 0, "StargateAutodial", %earthGate, 90);
- echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] Stargates successfully created");
- }
- }
- function StargateAutodial(%gate, %openTime)
- {
- if(!isObject(%gate)) return;
- if(%gate.gateState != 0) return;
- %gates = StargateNetwork.getCount();
- for(%i=0;%i<%gates;%i++)
- {
- %obj = StargateNetwork.getObject(%i);
- if(%obj.worldName !$= "")
- {
- if(%obj == %gate) continue;
- %list[-1+%list++] = %obj;
- }
- }
- if(%list > 0)
- {
- %gate.maxOpenTime = %openTime;
- %dialGate = %list[getRandom(0, %list - 1)];
- MessageAllInRange(%gate.getPosition(), "\c2"@trim(%gate.worldName SPC "Autodialler")@"\c6: Dialling to "@%dialGate.worldName@".");
- echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] " @ %gate.worldName @ " autodialling to "@%dialGate.worldName);
- %gate.DialStargate(%dialGate.address SPC %gate.pointOfOrigin);
- for(%i=0;%i<3;%i++) %gate.lastAutodial[%i + 1] = %gate.lastAutodial[%i];
- %gate.lastAutodial0 = %dialGate;
- }
- }
- if(!isObject(StargateNetwork))
- new SimSet(StargateNetwork);
- MakeGates();
|