Stargate.cs 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452
  1. AddDamageType("Stargate_IrisSlam", '%1 didn\'t rematerialize at the other end.', '%1 didn\'t rematerialize at the other end.', 1, 1);
  2. AddDamageType("Stargate_WrongSide", '%1 entered the wrong side of a Stargate.', '%1 entered the wrong side of a Stargate.', 1, 1);
  3. AddDamageType("Stargate_Backwards", '%1 went backwards through the wormhole.', '%1 went backwards through the wormhole.', 1, 1);
  4. AddDamageType("Stargate_Kawoosh", '%1 stood in the way of the Kawoosh.', '%1 stood in the way of the Kawoosh.', 1, 1);
  5. AddDamageType("Stargate_Telefrag", '%1 stood in a closing wormhole.', '%1 stood in a closing wormhole.', 1, 1);
  6. datablock StaticShapeData(StargateOuterRingShape)
  7. { shapefile = "Add-Ons/Gamemode_Stargate/Milky_Way/Ring/Outer.dts"; };
  8. datablock StaticShapeData(StargateMiddleRingShape)
  9. { shapefile = "Add-Ons/Gamemode_Stargate/Milky_Way/Ring/Middle.dts"; };
  10. datablock StaticShapeData(StargateInnerRingShape)
  11. { shapefile = "Add-Ons/Gamemode_Stargate/Milky_Way/Ring/Inner.dts"; };
  12. datablock StaticShapeData(StargateChevronBottomShape)
  13. { shapefile = "Add-Ons/Gamemode_Stargate/Milky_Way/Chev/Bottom.dts"; };
  14. datablock StaticShapeData(StargateChevronFinShape)
  15. { shapefile = "Add-Ons/Gamemode_Stargate/Milky_Way/Chev/Fin.dts"; };
  16. datablock StaticShapeData(StargateChevronLightShape)
  17. { shapefile = "Add-Ons/Gamemode_Stargate/Milky_Way/Chev/Light.dts"; };
  18. datablock StaticShapeData(StargateHorizonShape)
  19. { shapefile = "Add-Ons/Gamemode_Stargate/Horiz/Horizon.dts"; };
  20. datablock StaticShapeData(StargateKawooshShape)
  21. { shapefile = "Add-Ons/Gamemode_Stargate/Horiz/Kawoosh.dts"; };
  22. datablock StaticShapeData(StargateIrisShape)
  23. { shapefile = "Add-Ons/Gamemode_Stargate/Horiz/Iris.dts"; };
  24. datablock StaticShapeData(StargateDestinyShape)
  25. { shapefile = "Add-Ons/Gamemode_Stargate/Destiny/Stargate/Stargate.dts"; };
  26. function MakeStargate(%trans, %address, %origin, %name)
  27. {
  28. if(!isObject(StargateNetwork))
  29. new SimSet(StargateNetwork);
  30. (%outer = new StaticShape()
  31. {
  32. address = %address;
  33. datablock = StargateOuterRingShape;
  34. pointOfOrigin = %origin;
  35. worldName = %name;
  36. gateClass = "Milky_Way";
  37. }).setTransform(%trans);
  38. %outer.setNodeColor("Outer", "0.3 0.3 0.3 1");
  39. (%middle = new StaticShape()
  40. {
  41. datablock = StargateMiddleRingShape;
  42. }).setTransform(%trans);
  43. %middle.setNodeColor("Middle", "0.3 0.3 0.3 1");
  44. (%inner = new StaticShape()
  45. {
  46. datablock = StargateInnerRingShape;
  47. }).setTransform(%trans);
  48. %inner.setNodeColor("Inner", "0.3 0.3 0.3 1");
  49. (%horiz = new StaticShape()
  50. {
  51. datablock = StargateHorizonShape;
  52. }).setTransform(%trans);
  53. %horiz.setNodeColor("ALL", "1 1 1 1");
  54. %horiz.hideNode("ALL");
  55. (%kawoosh = new StaticShape()
  56. {
  57. datablock = StargateKawooshShape;
  58. }).setTransform(%trans);
  59. %kawoosh.setNodeColor("ALL", "0 0.5 1 1");
  60. %kawoosh.hideNode("ALL");
  61. %outer.middle = %middle;
  62. %outer.inner = %inner;
  63. %outer.horiz = %horiz;
  64. %outer.kawoosh = %kawoosh;
  65. %pos = getWords(%trans, 0, 2);
  66. %for = %outer.getForwardVector();
  67. %up = %outer.getUpVector();
  68. %right = vectorCross(%for, %up);
  69. %hLen = vectorLen(getWords(%for, 0, 1));
  70. %vAng = mAtan(getWord(%for, 2), %hLen) * (180 / $PI);
  71. %hAng = mAtan(getWord(%for, 0), getWord(%for, 1)) * (180 / $PI);
  72. if(mAbs(vectorDot(%up, "0 0 1")) <= 0.999)
  73. {
  74. %hAng += 180; %vAng = 180 - %vAng;
  75. if(mAbs(vectorDot(%for, "0 0 1")) <= 0.999) %rot += 180;
  76. }
  77. for(%i=0;%i<9;%i++)
  78. {
  79. %offset = vectorAdd(vectorScale(%right, mSin(%i*$PI/4.5)*-4.2),
  80. vectorScale(%up, mCos(%i*$PI/4.5)*4.2));
  81. %trans = vectorAdd(%pos, %offset) SPC eulerToAxis(%vAng SPC -360*(%i/9)+%rot SPC -%hAng);
  82. (%shape = new StaticShape() {
  83. datablock = StargateChevronBottomShape;
  84. }).setTransform(%trans);
  85. %shape.setNodeColor("Bottom", "0.3 0.3 0.3 1");
  86. %shape.setNodeColor("LightStrips", "0.2 0.2 0.2 1");
  87. %outer.ChevB[%i] = %shape;
  88. (%shape = new StaticShape() {
  89. datablock = StargateChevronFinShape;
  90. }).setTransform(%trans);
  91. %shape.setNodeColor("LightBody", "0.3 0.3 0.3 1");
  92. %shape.setNodeColor("Fins", "0.3 0.3 0.3 1");
  93. %shape.setNodeColor("Detail", "0.3 0.3 0.3 1");
  94. %outer.ChevF[%i] = %shape;
  95. (%shape = new StaticShape() {
  96. datablock = StargateChevronLightShape;
  97. }).setTransform(%trans);
  98. %shape.setNodeColor("Light", "0.3 0 0 1");
  99. %outer.ChevL[%i] = %shape;
  100. }
  101. StargateNetwork.add(%outer);
  102. return %outer;
  103. }
  104. function MakeDestinyGate(%trans, %address, %origin, %name)
  105. {
  106. if(!isObject(StargateNetwork))
  107. new SimSet(StargateNetwork);
  108. (%gate = new StaticShape()
  109. {
  110. address = %address;
  111. datablock = StargateDestinyShape;
  112. pointOfOrigin = %origin;
  113. worldName = %name;
  114. gateClass = "Destiny";
  115. }).setTransform(%trans);
  116. (%kawoosh = new StaticShape()
  117. {
  118. datablock = StargateKawooshShape;
  119. }).setTransform(%trans);
  120. %kawoosh.setNodeColor("ALL", "0 0.5 1 1");
  121. %kawoosh.hideNode("ALL");
  122. (%horiz = new StaticShape()
  123. {
  124. datablock = StargateHorizonShape;
  125. }).setTransform(%trans);
  126. %horiz.setNodeColor("ALL", "1 1 1 1");
  127. %horiz.hideNode("ALL");
  128. %gate.horiz = %horiz;
  129. (%bearing = new StaticShape()
  130. {
  131. datablock = StargateDestinyBearingShape;
  132. }).setTransform(VectorAdd(%trans, "0 0 5.6"));
  133. %bearing.setNodeColor("ALL", "1 1 1 1");
  134. %gate.bearing = %bearing;
  135. %gate.kawoosh = %kawoosh;
  136. StargateNetwork.add(%gate);
  137. return %gate;
  138. }
  139. function StaticShape::ChevronLockAnim(%obj, %num, %stayOn)
  140. {
  141. %scale = getWord(%obj.getScale(), 2);
  142. if(isObject(%bottom = %obj.ChevB[%num]))
  143. {
  144. %rot = getWords(%bottom.getTransform(), 3, 6);
  145. if(%bottom.ChevronPosition !$= "") %pos = %bottom.ChevronPosition;
  146. else {
  147. %pos = %bottom.getPosition();
  148. %bottom.ChevronPosition = %pos;
  149. }
  150. %dir = vectorNormalize(vectorSub(%obj.getPosition(), %pos));
  151. for(%i=0;%i<12;%i++)
  152. {
  153. cancel(%bottom.ChevLockASched[%i]); cancel(%bottom.ChevLockBSched[%i]);
  154. %bottom.ChevLockASched[%i] = %bottom.schedule(%i * 16, "setTransform", vectorAdd(%pos, vectorScale(%dir, 0.2 * %scale * (%i / 11))) SPC %rot);
  155. %bottom.ChevLockBSched[%i] = %bottom.schedule(%i * 16 + 1200, "setTransform", vectorAdd(%pos, vectorScale(%dir, 0.2 * %scale * (1 - %i / 11))) SPC %rot);
  156. }
  157. }
  158. if(isObject(%light = %obj.ChevL[%num]))
  159. {
  160. %rot = getWords(%light.getTransform(), 3, 6);
  161. if(%light.ChevronPosition !$= "") %pos = %light.ChevronPosition;
  162. else {
  163. %pos = %light.getPosition();
  164. %light.ChevronPosition = %pos;
  165. }
  166. %dir = vectorNormalize(vectorSub(%obj.getPosition(), %pos));
  167. for(%i=0;%i<12;%i++)
  168. {
  169. cancel(%light.ChevLockASched[%i]); cancel(%light.ChevLockBSched[%i]);
  170. %light.ChevLockASched[%i] = %light.schedule(%i * 16, "setTransform", vectorAdd(%pos, vectorScale(%dir, -0.05 * %scale * (%i / 11))) SPC %rot);
  171. %light.ChevLockBSched[%i] = %light.schedule(%i * 16 + 1200, "setTransform", vectorAdd(%pos, vectorScale(%dir, -0.05 * %scale * (1 - %i / 11))) SPC %rot);
  172. }
  173. }
  174. %obj.schedule(384, "ChevronLightAnim", %num, 1, !%stayOn);
  175. }
  176. function StaticShape::ChevronLightAnim(%obj, %num, %on, %off)
  177. {
  178. if(isObject(%bottom = %obj.ChevB[%num]))
  179. %bottom.ObjectLightAnim("LightStrips", %on, %off, 0.2, 0.8, 0.2, 0.5, 0.2, -0.2);
  180. if(isObject(%light = %obj.ChevL[%num]))
  181. %light.ObjectLightAnim("Light", %on, %off, 0.3, 0.7, 0, 0.7, 0, 0);
  182. }
  183. function StaticShape::ObjectLightAnim(%obj, %node, %on, %off, %r0, %r1, %g0, %g1, %b0, %b1)
  184. {
  185. if(%on && %off)
  186. {
  187. for(%i=0;%i<63;%i++)
  188. {
  189. %value = mSin(%i / 62 * $PI);
  190. if(%i > 31 || !%obj.isNodeLit[%node])
  191. %obj.schedule(%i * 16, "setNodeColor", %node, %r0+%r1*%value SPC %g0+%g1*%value SPC %b0-%b1*%value SPC 1);
  192. }
  193. %obj.isNodeLit[%node] = 0;
  194. }
  195. else if(%on && !%obj.isNodeLit[%node])
  196. {
  197. for(%i=0;%i<32;%i++)
  198. {
  199. %value = mSin(%i / 62 * $PI);
  200. %obj.schedule(%i * 16, "setNodeColor", %node, %r0+%r1*%value SPC %g0+%g1*%value SPC %b0-%b1*%value SPC 1);
  201. }
  202. %obj.isNodeLit[%node] = 1;
  203. }
  204. else if(%off && %obj.isNodeLit[%node])
  205. {
  206. for(%i=0;%i<32;%i++)
  207. {
  208. %value = mSin((%i + 31) / 62 * $PI);
  209. %obj.schedule(%i * 16, "setNodeColor", %node, %r0+%r1*%value SPC %g0+%g1*%value SPC %b0-%b1*%value SPC 1);
  210. }
  211. %obj.isNodeLit[%node] = 0;
  212. }
  213. }
  214. function StaticShape::DialStargate(%obj, %address)
  215. {
  216. %obj.setStargateState(1);
  217. %obj.DiallingSequence(%address, %address, -1, -1, 0, 0, 1);
  218. }
  219. function StaticShape::ResetDHD(%obj)
  220. {
  221. for(%i=0;%i<19;%i++)
  222. {
  223. %obj.dhd.ObjectLightAnim("Sym_A_"@%i, 0, 1, 0.2, 0.8, 0.1, 0.6, 0, 0);
  224. %obj.dhd.ObjectLightAnim("Sym_B_"@%i, 0, 1, 0.2, 0.8, 0.1, 0.6, 0, 0);
  225. }
  226. for(%i=0;%i<9;%i++) %obj.ChevronLightAnim(%i, 0, 1);
  227. for(%i=0;%i<3;%i++)
  228. {
  229. %obj.dhd.stopAudio(%i);
  230. %obj.dhd.schedule(0, "playAudio", %i, DialFail_Sound);
  231. }
  232. return;
  233. }
  234. function StaticShape::InstantDial(%obj, %address)
  235. {
  236. %gateFound = 0;
  237. echo(%obj.address);
  238. echo(%address);
  239. echo($gateObjs[%address].pointOfOrigin);
  240. if($gateObjs[%address] && %gate.gateState <= 1 && %address !$= %obj.address)
  241. {
  242. %gate = $gateObjs[%address];
  243. %gateFound = 1;
  244. %obj.dhd.ObjectLightAnim("BUTTON", 1, 0, 0.5, 0.5, 0, 0, 0, 0);
  245. %obj.setStargateState(2);
  246. %gate.setStargateState(2);
  247. %gate.dhd.dialSequence = "";
  248. for(%i=0;%i<9;%i++)
  249. if(%obj.ChevL[%i].isNodeLitLight)
  250. {
  251. %gate.ChevronLockAnim(%i, 1);
  252. serverPlay3D(ChevronLocked_Sound, %gate.getPosition());
  253. }
  254. else %gate.ChevronLockAnim(%i, 0);
  255. %obj.schedule(400, "OpenStargate", %gate, %gate, %pl.client);
  256. %gate.schedule(400, "OpenStargate", %obj);
  257. return;
  258. }
  259. if(%gateFound == 0) return %obj.ResetDHD();
  260. }
  261. function Gate_GetGoalAng(%obj, %goal)
  262. {
  263. switch$(%obj.gateClass)
  264. {
  265. case "Milky_Way":
  266. return (%goal / -39) * 360;
  267. case "Destiny":
  268. return 9.457616760 + %goal * 7.1 + mFloor(%goal / 4) * 40;
  269. }
  270. }
  271. function StaticShape::DiallingSequence(%obj, %address, %origAddr, %last, %spinStart, %accelMode, %angVel, %spinDir)
  272. {
  273. cancel(%obj.DialSched);
  274. if((%words = getWordCount(%address)) == 0) return;
  275. %goal = firstWord(%address);
  276. if(%last == -1)
  277. {
  278. %starting = 1;
  279. %last = getSimTime();
  280. %spinStart = %last;
  281. for(%i=0;%i<2;%i++)
  282. {
  283. %obj.playAudio(%i, GateRoll_Sound);
  284. %obj.GateRollSched[%i] = %obj.schedule(3392, "playAudio", %i, GateRollLoop_Sound);
  285. }
  286. }
  287. %obj.currSpin -= mFloor(%obj.currSpin / 360) * 360;
  288. %time = vectorDist(%last, %now = getSimTime()) / 1000;
  289. %goalAng = Gate_GetGoalAng(%obj, %goal - 1);
  290. %dist = %obj.currSpin - %goalAng;
  291. %dist -= mFloor(%dist / 360) * 360;
  292. switch$(%obj.gateClass)
  293. {
  294. case "Milky_Way":
  295. %spinObj = %obj.Middle;
  296. case "Destiny":
  297. %spinObj = %obj;
  298. }
  299. if(%obj.maxAngularVel < 0.5)
  300. %obj.maxAngularVel = 40;
  301. if(%obj.angularAccelTime > 4 || %obj.angularAccelTime < 0.01)
  302. %obj.angularAccelTime = 1;
  303. %angTopVel = %obj.maxAngularVel;
  304. %accelTime = %obj.angularAccelTime;
  305. //%angTopVel = 40; //40
  306. //%accelTime = 1.0; //1.5
  307. if(%obj.gateState > 1)
  308. {
  309. %accelMode = 2;
  310. %haltGate = 1;
  311. }
  312. if(%accelMode == 0)
  313. {
  314. %accelRate = (%angTopVel / %accelTime) * (%spinDir - 0.5) * 2;
  315. if(mAbs(%angVel + %accelRate * %time) > %angTopVel)
  316. {
  317. %velDiff = %angTopVel - mAbs(%angVel);
  318. %accelDiff = %velDiff / %accelRate;
  319. %coastTime = %time - %accelDiff;
  320. %newRot = (%accelRate / 2) * (%accelDiff * %accelDiff) + %angVel * %accelDiff + %obj.currSpin;
  321. %angVel = %angTopVel * (%spinDir - 0.5) * 2;
  322. %newRot += %angVel * %coastTime;
  323. %obj.currSpin = %newRot;
  324. %accelMode = 1;
  325. }
  326. else
  327. {
  328. %newRot = (%accelRate / 2) * (%time * %time) + %angVel * %time + %obj.currSpin;
  329. %angVel += %accelRate * %time; %obj.currSpin = %newRot;
  330. }
  331. }
  332. else if(%accelMode == 1)
  333. {
  334. if(%spinDir)
  335. {
  336. %deltaPos = 360 - (%obj.currSpin - %goalAng);
  337. if(%deltaPos < 0) %deltaPos += 360;
  338. }
  339. else
  340. {
  341. %deltaPos = %obj.currSpin - %goalAng;
  342. if(%deltaPos > 360) %deltaPos -= 360;
  343. }
  344. %accelRate = %angTopVel / %accelTime;
  345. %decelTime = mAbs(%angVel) / %accelRate;
  346. %decelDist = (mAbs(%angVel) * %decelTime) - (%accelRate * %decelTime * %decelTime / 2);
  347. %deltaTime = (%deltaPos - %decelDist) / mAbs(%angVel);
  348. if(%deltaTime < %time && %deltaTime > 0)
  349. {
  350. %obj.currSpin += %angVel * %deltaTime;
  351. %decelTime = %time - %deltaTime;
  352. %accelRate *= (%spinDir - 0.5) * 2;
  353. %newRot = (%accelRate / -2) * (%time * %time) + %angVel * %time + %obj.currSpin;
  354. %angVel -= %accelRate * %time;
  355. %obj.currSpin = %newRot;
  356. %accelMode = 2;
  357. }
  358. else %obj.currSpin += %angVel * %time;
  359. }
  360. else if(%accelMode == 2)
  361. {
  362. %accelRate = (%angTopVel / %accelTime) * (%spinDir - 0.5) * 2;
  363. if(mAbs(%angVel) - mAbs(%accelRate * %time) < 0)
  364. {
  365. %velDiff = mAbs(%angVel);
  366. %accelDiff = %velDiff / %accelRate;
  367. %newRot = (%accelRate / -2) * (%accelDiff * %accelDiff) + %angVel * %accelDiff + %obj.currSpin;
  368. %obj.currSpin = %newRot;
  369. %accelMode = 3;
  370. %angVel = 0;
  371. if(%haltGate)
  372. {
  373. for(%i=0;%i<2;%i++)
  374. {
  375. %obj.stopAudio(%i);
  376. cancel(%obj.GateRollSched[%i]);
  377. }
  378. return;
  379. }
  380. }
  381. else
  382. {
  383. %newRot = (%accelRate / -2) * (%time * %time) + %angVel * %time + %obj.currSpin;
  384. %angVel -= %accelRate * %time; %obj.currSpin = %newRot;
  385. }
  386. }
  387. else if(%accelMode == 3)
  388. {
  389. for(%i=0;%i<2;%i++)
  390. {
  391. %obj.stopAudio(%i);
  392. cancel(%obj.GateRollSched[%i]);
  393. }
  394. //%rot = ((%goal-1)/-39)*360; %obj.currSpin = %rot;
  395. %rot = %obj.currSpin;
  396. %for = %obj.getForwardVector();
  397. %hLen = vectorLen(getWords(%for, 0, 1));
  398. %vAng = mAtan(getWord(%for, 2), %hLen) * (180 / $PI);
  399. %hAng = mAtan(getWord(%for, 0), getWord(%for, 1)) * (180 / $PI);
  400. if(mAbs(vectorDot(%obj.getUpVector(), "0 0 1")) > 0.999) %hAng *= -1;
  401. %spinObj.setTransform(%obj.getPosition() SPC eulerToAxis(%vAng SPC -%rot SPC %hAng));
  402. %obj.DialSched = %obj.schedule(1520, "DiallingSequence", restWords(%address), %origAddr, -1, -1, 0, 0, !%spinDir);
  403. %obj.ChevronLockAnim(0, %words == 1);
  404. for(%i=0;%i<2;%i++)
  405. serverPlay3D(ChevronLocked_Sound, %obj.ChevF0.getPosition());
  406. if(%words > 1)
  407. {
  408. %sequence = "1 2 3 6 7 8 4 5";
  409. %word = getWordCount(%origAddr) - %words;
  410. %obj.schedule(1040, "ChevronLightAnim", getWord(%sequence, %word), 1, 0);
  411. }
  412. else
  413. {
  414. if(getWord(%origAddr, getWordCount(%origAddr) - 1) != %obj.pointOfOrigin
  415. || getWordCount(%origAddr) <= 1)
  416. {
  417. if(isObject(%dhd = %obj.dhd))
  418. {
  419. %dhd.dialSequence = "";
  420. for(%i=0;%i<19;%i++)
  421. {
  422. %dhd.ObjectLightAnim("Sym_A_"@%i, 0, 1, 0.2, 0.8, 0.1, 0.6, 0, 0);
  423. %dhd.ObjectLightAnim("Sym_B_"@%i, 0, 1, 0.2, 0.8, 0.1, 0.6, 0, 0);
  424. }
  425. }
  426. for(%i=0;%i<9;%i++)
  427. %obj.schedule(1920, "ChevronLightAnim", %i, 0, 1);
  428. %obj.setStargateState(0);
  429. return;
  430. }
  431. %mainAddr = getWords(%origAddr, 0, getWordCount(%origAddr) - 2);
  432. if(%mainAddr $= %obj.address)
  433. {
  434. if(isObject(%dhd = %obj.dhd))
  435. {
  436. %dhd.dialSequence = "";
  437. for(%i=0;%i<19;%i++)
  438. {
  439. %dhd.ObjectLightAnim("Sym_A_"@%i, 0, 1, 0.2, 0.8, 0.1, 0.6, 0, 0);
  440. %dhd.ObjectLightAnim("Sym_B_"@%i, 0, 1, 0.2, 0.8, 0.1, 0.6, 0, 0);
  441. }
  442. }
  443. for(%i=0;%i<9;%i++)
  444. %obj.schedule(1920, "ChevronLightAnim", %i, 0, 1);
  445. %obj.setStargateState(0);
  446. return;
  447. }
  448. %gates = StargateNetwork.getCount();
  449. for(%i=0;%i<%gates;%i++)
  450. {
  451. %gate = StargateNetwork.getObject(%i);
  452. if(%gate.address $= %mainAddr && %gate.gateState <= 1)
  453. {
  454. %obj.setStargateState(2);
  455. %gate.setStargateState(2);
  456. %gate.dhd.dialSequence = "";
  457. //for(%i=0;%i<9;%i++)
  458. // if(%i == 0 || %obj.ChevL[%i].isNodeLitLight)
  459. // {
  460. // %gate.ChevronLockAnim(%i, 1);
  461. // serverPlay3D(ChevronLocked_Sound, %gate.getPosition());
  462. // }
  463. for(%i=0;%i<9;%i++)
  464. if(%i == 0 || %obj.ChevL[%i].isNodeLitLight)
  465. {
  466. %gate.schedule(1520, "ChevronLockAnim", %i, 1);
  467. schedule(1520, 0, "serverPlay3D", ChevronLocked_Sound, %gate.getPosition());
  468. }
  469. else %gate.schedule(1520, "ChevronLockAnim", %i, 0);
  470. %obj.schedule(1920, "OpenStargate", %gate, %gate);
  471. %gate.schedule(1920, "OpenStargate", %obj);
  472. return;
  473. }
  474. }
  475. for(%i=0;%i<3;%i++)
  476. {
  477. %obj.stopAudio(%i);
  478. %obj.schedule(1520, "playAudio", %i, DialFail_Sound);
  479. }
  480. if(isObject(%dhd = %obj.dhd))
  481. {
  482. %dhd.dialSequence = "";
  483. for(%i=0;%i<19;%i++)
  484. {
  485. %dhd.ObjectLightAnim("Sym_A_"@%i, 0, 1, 0.2, 0.8, 0.1, 0.6, 0, 0);
  486. %dhd.ObjectLightAnim("Sym_B_"@%i, 0, 1, 0.2, 0.8, 0.1, 0.6, 0, 0);
  487. }
  488. }
  489. for(%i=0;%i<9;%i++)
  490. %obj.schedule(1920, "ChevronLightAnim", %i, 0, 1);
  491. %obj.setStargateState(0);
  492. if(%obj.autodialOnShutdown)
  493. {
  494. cancel(%obj.autodialSched);
  495. StargateAutodial(%obj, 90);
  496. }
  497. return;
  498. }
  499. return;
  500. }
  501. %for = %obj.getForwardVector();
  502. %hLen = vectorLen(getWords(%for, 0, 1));
  503. %vAng = mAtan(getWord(%for, 2), %hLen) * (180 / $PI);
  504. %hAng = mAtan(getWord(%for, 0), getWord(%for, 1)) * (180 / $PI);
  505. if(mAbs(vectorDot(%obj.getUpVector(), "0 0 1")) > 0.999) %hAng *= -1;
  506. %spinObj.setTransform(%obj.getPosition() SPC eulerToAxis(%vAng SPC -%obj.currSpin SPC %hAng));
  507. %obj.DialSched = %obj.schedule(16, "DiallingSequence", %address, %origAddr, %now, %spinStart, %accelMode, %angVel, %spinDir);
  508. }
  509. function StaticShape::OpenStargate(%obj, %goal, %linked, %cl)
  510. {
  511. cancel(%obj.DialSched);
  512. cancel(%obj.shutSched);
  513. cancel(%obj.hardShutSched);
  514. cancel(%obj.autodialSched);
  515. if(%obj.maxOpenTime > 0 && isObject(%linked))
  516. {
  517. %obj.shutSched = %obj.schedule((%obj.maxOpenTime * 1000) | 0, "CloseStargate");
  518. %obj.maxOpenTime = 0;
  519. }
  520. if(%obj.spawnMalpBotOnLock && isObject(%linked)) //Temporary
  521. {
  522. schedule(3000, 0, "createBotMALP", "0 12 2 0 0 1 3.14159", %obj);
  523. }
  524. for(%i=0;%i<3;%i++)
  525. {
  526. %obj.stopAudio(%i);
  527. cancel(%obj.GateRollSched[%i]);
  528. }
  529. %obj.schedule(0, "setStargateState", 2);
  530. %obj.horiz.setNodeColor("ALL", "1 1 1 1");
  531. %obj.hardShutSched = %obj.schedule(16, "HardShutStargate", 2314, getSimTime());
  532. for(%i=0;%i<3;%i++)
  533. %obj.schedule(0, "playAudio", %i, WormholeOpened_Sound);
  534. for(%i=0;%i<8;%i++)
  535. %obj.horiz.schedule(1008+32*%i, "unhideNode", "Layer"@(7-%i));
  536. %objFor = %obj.getForwardVector();
  537. %objUp = %obj.getUpVector();
  538. %objRight = vectorCross(%objFor, %objUp);
  539. %objPos = %obj.getPosition();
  540. %mask = $Typemasks::fxBrickAlwaysObjectType;
  541. %offset0 = vectorScale(%objUp, 0.05);
  542. %offset1 = vectorScale(%objRight, 0.05);
  543. %offset2 = vectorScale(%objUp, -0.05);
  544. %offset3 = vectorScale(%objRight, -0.05);
  545. %killKawoosh = 1;
  546. for(%i=0;%i<8;%i++)
  547. {
  548. for(%j=0;%j<24;%j++)
  549. {
  550. %killCount = 0;
  551. if(%i == 0 && %j != 0) continue;
  552. %mult = 0.45 * %i; //3.6 (radius of the wormhole) divided by 8 (number of raycast rings)
  553. %uVal = mSin(%j / 12 * $PI) * %mult; %rVal = mCos(%j / 12 * $PI) * %mult;
  554. %pos = vectorAdd(%objPos, vectorAdd(vectorScale(%objUp, %uVal), vectorScale(%objRight, %rVal)));
  555. for(%k=0;%k<4;%k++)
  556. {
  557. %end = vectorAdd(vectorAdd(%pos, %offset[%k]), vectorScale(%objFor, 0.5));
  558. %ray = containerRaycast(%pos, %end, %mask);
  559. if(!isObject(%hit = firstWord(%ray)) || !%hit.isColliding()) %killCount++;
  560. }
  561. if(%killCount == 4) { %killKawoosh = 0; break; }
  562. }
  563. if(!%killKawoosh) break;
  564. }
  565. if(!%killKawoosh)
  566. %obj.kawoosh.schedule(1232, "unhideNode", "ALL");
  567. %scale = getWord(%obj.getScale(), 2);
  568. for(%i=0;%i<120;%i++)
  569. {
  570. if(%i < 30) %colVal = mSin(%i/59*$PI);
  571. else if(!%killKawoosh && %i >= 90) %colVal = mSin((%i-60)/59*$PI);
  572. else %colVal = 1;
  573. if(!%killKawoosh)
  574. {
  575. %obj.kawoosh.schedule(1232+16*%i, "setScale", %scale SPC (mSin(%i/119*$PI)*%scale) SPC %scale);
  576. if(%i & 1) %obj.schedule(1232+16*%i, "SlayNearby", 0, mSin(%i/119*$PI)*13.32);
  577. %obj.kawoosh.schedule(1232+16*%i, "setNodeColor", "ALL", 1-%colVal SPC 1-%colVal/2@" 1 1");
  578. }
  579. %obj.horiz.schedule(1232+16*%i, "setNodeColor", "ALL", 1-%colVal SPC 1-%colVal/2@" 1 1");
  580. }
  581. if(!%killKawoosh)
  582. {
  583. %obj.kawoosh.schedule(3152, "hideNode", "ALL");
  584. for(%i=0;%i<16;%i++)
  585. %obj.horiz.schedule(3152+16*%i, "setNodeColor", "ALL", 1-mSin(%i/31*$PI) SPC 1-mSin(%i/31*$PI)/2@" 1 1");
  586. }
  587. for(%i=0;%i<2;%i++)
  588. %obj.schedule(4000, "playAudio", %i, EventHorizon_Sound);
  589. %obj.schedule(4000, "setStargateState", 3);
  590. %obj.SGWormholeSched = %obj.schedule(3152, "StargateWormhole", %goal, getSimTime());
  591. if(isObject(%linked))
  592. {
  593. cancel(%linked.shutSched);
  594. cancel(%linked.hardShutSched);
  595. initContainerRadiusSearch(%linked.getPosition(), 16, $Typemasks::fxBrickAlwaysObjectType);
  596. while(isObject(%brick = containerSearchNext()))
  597. %brick.WormholeIncoming(%cl);
  598. initContainerRadiusSearch(%obj.getPosition(), 16, $Typemasks::fxBrickAlwaysObjectType);
  599. while(isObject(%brick = containerSearchNext()))
  600. %brick.WormholeOutgoing(%cl);
  601. %origWorldName = %obj.worldName $= "" ? "a Hidden System" : %obj.worldName;
  602. %linkedWorldName = %linked.worldName $= "" ? "a Hidden System" : %linked.worldName;
  603. echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] Wormhole opened from " @ %origWorldName @ " (" @ %obj.address @ ") to " @ %linkedWorldName @ " (" @ %linked.address @ ")");
  604. %obj.linkedGate = %linked;
  605. %linked.masterGate = %obj;
  606. }
  607. }
  608. function StaticShape::CloseStargate(%obj)
  609. {
  610. %obj.setStargateState(4);
  611. cancel(%obj.shutSched);
  612. cancel(%obj.hardShutSched);
  613. cancel(%obj.autodialSched); %hop = %obj;
  614. while(isObject(%nextHop = %hop.redirectToGate))
  615. %hop.redirectToGate = "";
  616. if(isObject(%dhd = %obj.dhd))
  617. {
  618. %dhd.ObjectLightAnim("BUTTON", 0, 1, 0.5, 0.5, 0, 0, 0, 0);
  619. for(%i=0;%i<19;%i++)
  620. {
  621. %dhd.ObjectLightAnim("SYM_A_"@%i, 0, 1, 0.2, 0.8, 0.1, 0.6, 0, 0);
  622. %dhd.ObjectLightAnim("SYM_B_"@%i, 0, 1, 0.2, 0.8, 0.1, 0.6, 0, 0);
  623. }
  624. }
  625. for(%i=0;%i<9;%i++)
  626. %obj.schedule(1680, "ChevronLightAnim", %i, 0, 1);
  627. for(%i=0;%i<3;%i++)
  628. %obj.playAudio(%i, WormholeClosed_Sound);
  629. for(%i=0;%i<80;%i++)
  630. {
  631. %value = mSin((%i + 80)/159*$PI);
  632. %obj.horiz.schedule(16*%i, "setNodeColor", "ALL", 1-%value SPC 1-%value/2@" 1 1");
  633. }
  634. %obj.schedule(1296, "SlayNearby", 1);
  635. for(%i=0;%i<39;%i++)
  636. %obj.horiz.schedule(1296+16*%i, "setNodeColor", "ALL", "1 1 1 "@1-%i/39);
  637. %obj.horiz.schedule(1920, "hideNode", "ALL");
  638. %obj.schedule(1920, "setStargateState", 0);
  639. if(isObject(%linked = %obj.linkedGate))
  640. {
  641. %origWorldName = %obj.worldName $= "" ? "a Hidden System" : %obj.worldName;
  642. %linkedWorldName = %linked.worldName $= "" ? "a Hidden System" : %linked.worldName;
  643. echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] Wormhole closed from " @ %origWorldName @ " (" @ %obj.address @ ") to " @ %linkedWorldName @ " (" @ %linked.address @ ")");
  644. %linked.CloseStargate();
  645. %linked.schedule(1920, "clearLinkedGate");
  646. %obj.schedule(1920, "clearLinkedGate");
  647. }
  648. initContainerRadiusSearch(%obj.getPosition(), 16, $Typemasks::fxBrickAlwaysObjectType);
  649. while(isObject(%brick = containerSearchNext()))
  650. %brick.schedule(1920, "WormholeShutdown", %cl);
  651. if(%obj.autodialOnShutdown)
  652. {
  653. cancel(%obj.autodialSched);
  654. %obj.autodialSched = schedule(4920, 0, "StargateAutodial", %obj, 90);
  655. }
  656. }
  657. function StaticShape::clearLinkedGate(%obj)
  658. { %obj.masterGate = ""; %obj.linkedGate = ""; }
  659. function StaticShape::HardShutStargate(%obj, %timeLeft, %last)
  660. {
  661. if(!isObject(%this)) return;
  662. cancel(%obj.hardShutSched);
  663. %time = vectorDist(%last, %now = getSimTime()) / 1000;
  664. %timeLeft -= %time; if(%timeLeft <= 0) { %obj.CloseStargate(); return; }
  665. %obj.hardShutSched = %obj.schedule(16, "HardShutStargate", %timeLeft, %now);
  666. }
  667. function StaticShape::StargateWormhole(%this, %dest, %last)
  668. {
  669. if(!isObject(%this)) return;
  670. cancel(%this.SGWormholeSched);
  671. %scale = getWord(%this.getScale(), 2);
  672. %time = vectorDist(%last, %now = getSimTime()) / 1000;
  673. %this.SGWormholeSched = %this.schedule(48, "StargateWormhole", %dest, %now);
  674. %mask = $Typemasks::CorpseObjectType | $Typemasks::PlayerObjectType |
  675. $Typemasks::ProjectileObjectType | $Typemasks::VehicleObjectType;
  676. %playerMask = $Typemasks::CorpseObjectType | $Typemasks::PlayerObjectType;
  677. initContainerRadiusSearch(%loc = %this.getPosition(), 16 * %scale, %mask);
  678. while(isObject(%obj = containerSearchNext()))
  679. {
  680. %ignore = 0;
  681. for(%i=0;%i<%this.trackCount;%i++)
  682. if(%this.trackObj[%i] == %obj)
  683. { %ignore = 1; break; }
  684. if(%ignore) continue;
  685. %this.trackObj[-1+%this.trackCount++] = %obj;
  686. }
  687. while(isObject(%nextHop = %dest.redirectToGate) && !%hoppedTo[%nextHop])
  688. {
  689. %hoppedTo[%nextHop] = 1;
  690. %dest = %nextHop;
  691. }
  692. %destFor = %dest.getForwardVector();
  693. %destUp = %dest.getUpVector();
  694. %destPos = %dest.getPosition();
  695. for(%i=0;%i<%this.trackCount;%i++)
  696. {
  697. %obj = %this.trackObj[%i];
  698. if(!isObject(%obj))
  699. { %shift++; continue; }
  700. %type = %obj.getType();
  701. if(!(%type & $Typemasks::ProjectileObjectType) && isObject(%obj.getObjectMount())) continue;
  702. if(%type & %playerMask)
  703. %pos = %obj.getHackPosition();
  704. else if(%type & $Typemasks::VehicleObjectType)
  705. %pos = %obj.getWorldBoxCenter();
  706. else if(%type & $Typemasks::ProjectileObjectType)
  707. %pos = vectorAdd(%obj.getPosition(), vectorScale(%obj.getVelocity(), 0.08));
  708. if(vectorDist(%pos, %loc) > 16 * %scale)
  709. { %shift++; continue; }
  710. else %this.trackObj[%i - %shift] = %this.trackObj[%i];
  711. if((%this.SGLastDetect[%obj] | 0) != (%last | 0))
  712. {
  713. %oPos = %pos;
  714. %this.SGLastVel[%obj] = %obj.getVelocity();
  715. }
  716. else %oPos = %this.SGLastPos[%obj];
  717. %dir = vectorSub(%pos, %loc);
  718. %oDir = vectorSub(%oPos, %loc);
  719. %for = %this.getForwardVector();
  720. %up = %this.getUpVector();
  721. %right = vectorCross(%for, %up);
  722. %rDir = vectorDot(%dir, %for) SPC vectorDot(%dir, %right) SPC vectorDot(%dir, %up);
  723. %roDir = vectorDot(%oDir, %for) SPC vectorDot(%oDir, %right) SPC vectorDot(%oDir, %up);
  724. if(getWord(%rDir, 0) / getWord(%roDir, 0) < 0)
  725. {
  726. %len = getWord(%rDir, 0) / (getWord(%rDir, 0) - getWord(%roDir, 0));
  727. %yDiff = getWord(%rDir, 1) - getWord(%roDir, 1);
  728. %zDiff = getWord(%rDir, 2) - getWord(%roDir, 2);
  729. %hit = "0 "@getWord(%rDir, 1) + %yDiff * %len SPC getWord(%rDir, 2) + %zDiff * %len;
  730. if(vectorLen(%hit) <= 3.6 * %scale)
  731. {
  732. if(getWord(%rDir, 0) <= 0)
  733. {
  734. if(isObject(%this.masterGate))
  735. {
  736. if(%type & %playerMask)
  737. {
  738. %obj.spawnTime = 0;
  739. %obj.damage(%obj, %obj.position, 10000, $DamageType::Stargate_Backwards);
  740. echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] " @ %obj.cl.name @ " died from attempting to go through a Stargate backwards.");
  741. if(%obj.getState() $= "DEAD") { %obj.delete(); }
  742. }
  743. else if(%type & $Typemasks::VehicleObjectType)
  744. {
  745. %mounts = %obj.getDatablock().numMountPoints;
  746. for(%i=0;%i<%mounts;%i++)
  747. {
  748. %passenger = %obj.getMountedObject(%i);
  749. %passenger.spawnTime = 0;
  750. %passenger.damage(%passenger, %passenger.position, 10000, $DamageType::Stargate_Backwards);
  751. echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] " @ %passenger.client.name @ " died on a vehicle from attempting to go through a Stargate backwards.");
  752. if(%passenger.getState() $= "DEAD") { %passenger.delete(); }
  753. }
  754. %spawn = %obj.spawnBrick;
  755. if(isObject(%spawn))
  756. %spawn.respawnVehicle();
  757. else %obj.delete();
  758. }
  759. else if(%type & $Typemasks::ProjectileObjectType)
  760. %obj.delete();
  761. }
  762. else
  763. {
  764. %vel = %this.SGLastVel[%obj];
  765. %rPos = vectorDot(%hit, %right);
  766. %uPos = vectorDot(%hit, %up);
  767. //%destHit = vectorAdd(vectorAdd(vectorScale(%destRight, %rPos), vectorScale(%destUp, %uPos)), %dest);
  768. %destRight = vectorCross(%destFor, %destUp);
  769. %destHit = vectorAdd(%destPos, vectorAdd(vectorAdd(vectorScale(%destFor, -getWord(%rDir, 0)), vectorScale(%destRight, -getWord(%rDir, 1))), vectorScale(%destUp, getWord(%rDir, 2))));
  770. %index = mAbs(getWord(%destFor, 0)) < mAbs(getWord(%destFor, 1));
  771. %destHit = setWord(%destHit, %index, getWord(%destPos, %index));
  772. %objHit = vectorAdd(%this.getPosition(), vectorAdd(
  773. vectorScale(%right, %rPos), vectorScale(%up, %uPos)));
  774. serverPlay3D(ObjectEntrance_Sound, %objHit);
  775. %mask = $Typemasks::fxBrickAlwaysObjectType;
  776. %ray = containerRaycast(%destHit, vectorAdd(%destHit, vectorScale(%destFor, 0.8)), %mask);
  777. if(isObject(%ray) && %ray.isColliding())
  778. {
  779. if(%type & %playerMask)
  780. {
  781. %obj.spawnTime = 0;
  782. for(%j=0;%j<3;%j++) serverPlay3D(IrisImpact_Sound, %destHit);
  783. %obj.damage(%obj, %obj.position, 10000, $DamageType::Stargate_IrisSlam);
  784. echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] " @ %obj.client.name @ " died from attempting to go through a Stargate with its' iris closed.");
  785. if(%obj.getState() $= "DEAD") { %obj.delete(); } continue;
  786. }
  787. else if(%type & $Typemasks::VehicleObjectType)
  788. {
  789. %mounts = %obj.getDatablock().numMountPoints;
  790. for(%i=0;%i<%mounts;%i++)
  791. {
  792. %passenger = %obj.getMountedObject(%i); %passenger.spawnTime = 0;
  793. %passenger.damage(%passenger, %passenger.position, 10000, $DamageType::Stargate_IrisSlam);
  794. echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] " @ %passenger.client.name @ " died from attempting to go through a Stargate with its' iris closed.");
  795. if(%passenger.getState() $= "DEAD") { %passenger.delete(); }
  796. }
  797. for(%j=0;%j<5;%j++) serverPlay3D(IrisImpact_Sound, %destHit);
  798. %spawn = %obj.spawnBrick;
  799. if(isObject(%spawn))
  800. %spawn.respawnVehicle();
  801. else %obj.delete();
  802. continue;
  803. }
  804. else if(%type & $Typemasks::ProjectileObjectType)
  805. { serverPlay3D(IrisImpact_Sound, %destHit); %obj.delete(); continue; }
  806. }
  807. else serverPlay3D(ObjectEntrance_Sound, %destHit);
  808. if(%obj.getClassName() $= "Player" && $Pref::Server::Stargate::EnvironMode)
  809. {
  810. if(!isObject(EnvGuiMaster))
  811. new ScriptObject(EnvGuiMaster)
  812. { isEnvMaster = 1; isAdmin = 1; isSuperAdmin = 1; };
  813. %id = skyTexToIDX(%dest.skyTex);
  814. if(%id != -1) servercmdEnvGui_SetVar(EnvGuiMaster, "SkyIDX", %id);
  815. %id = groundTexToIDX(%dest.groundTex);
  816. if(%id != -1) servercmdEnvGui_SetVar(EnvGuiMaster, "GroundIDX", %id);
  817. if(%dest.dLightColor !$= "") servercmdEnvGui_SetVar(EnvGuiMaster, "DirectLightColor", %dest.dLightColor);
  818. if(%dest.aLightColor !$= "") servercmdEnvGui_SetVar(EnvGuiMaster, "AmbientLightColor", %dest.aLightColor);
  819. if(%dest.shadowColor !$= "") servercmdEnvGui_SetVar(EnvGuiMaster, "ShadowColor", %dest.shadowColor);
  820. if(%dest.sunAzim !$= "" || %dest.sunElev !$= "")
  821. {
  822. if(%dest.sunAzim !$= "") Sun.azimuth = %dest.sunAzim;
  823. if(%dest.sunElev !$= "") Sun.elevation = %dest.sunElev;
  824. Sun.sendUpdate();
  825. }
  826. Sky.visibleDistance = getMin($EnvGuiServer::VisibleDistance, 225);
  827. Sky.sendUpdate();
  828. }
  829. %destRight = vectorCross(%destFor, %destUp);
  830. %tele = vectorAdd(%destPos, vectorAdd(vectorAdd(
  831. vectorScale(%destFor, -getWord(%rDir, 0)),
  832. vectorScale(%destRight, -getWord(%rDir, 1))),
  833. vectorScale(%destUp, getWord(%rDir, 2))));
  834. if(%type & $Typemasks::PlayerObjectType)
  835. %offset = vectorSub(%obj.getHackPosition(), %obj.getPosition());
  836. else if(%type & $Typemasks::PlayerObjectType)
  837. %offset = vectorSub(%obj.getWorldBoxCenter(), %obj.getPosition());
  838. %tele = vectorSub(%tele, %offset);
  839. %oFor = %obj.getForwardVector();
  840. %fFor = vectorDot(%oFor, %for);
  841. %rFor = vectorDot(%oFor, %right);
  842. %uFor = vectorDot(%oFor, %up);
  843. %oFor = vectorAdd(vectorScale(%destFor, -%fFor), vectorScale(%destRight, -%rFor));
  844. %ang = mAtan(getWord(%oFor, 0), getWord(%oFor, 1));
  845. if(%type & $Typemasks::ProjectileObjectType)
  846. {
  847. %fVel = vectorDot(%vel, %for);
  848. %rVel = vectorDot(%vel, %right);
  849. %uVel = vectorDot(%vel, %up);
  850. %outVel = vectorAdd(vectorAdd(vectorScale(%destFor, -%fVel),
  851. vectorScale(%destRight, -%rVel)), vectorScale(%destUp, %uVel));
  852. %obj.setName("SGTeleport_OldProjectile");
  853. %proj = new Projectile(:SGTeleport_OldProjectile)
  854. {
  855. initialPosition = %tele;
  856. initialVelocity = %outVel;
  857. };
  858. MissionCleanup.add(%proj);
  859. %obj.delete();
  860. //if(%this.gateState == 2 || %this.gateState == 3)
  861. //{
  862. // if(getTimeRemaining(%this.shutSched) <= 5000)
  863. // {
  864. // cancel(%this.shutSched);
  865. // %this.shutSched = %this.schedule(5000, "CloseStargate");
  866. // }
  867. //}
  868. }
  869. else if(!isObject(%obj.getObjectMount()))
  870. {
  871. if(%type & $Typemasks::VehicleObjectType)
  872. {
  873. %mounts = %obj.getDatablock().numMountPoints;
  874. for(%i=0;%i<%mounts;%i++)
  875. {
  876. %passenger = %obj.getMountedObject(%i);
  877. if(isObject(%cl = %passenger.client))
  878. {
  879. %origWorldName = %this.worldName $= "" ? "a Hidden System" : %this.worldName;
  880. %linkedWorldName = %this.linkedGate.worldName $= "" ? "a Hidden System" : %this.linkedGate.worldName;
  881. echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] Player " @ %cl.name @ " travelled from " @ %origWorldName @ " (" @ %this.address @ ") to " @ %linkedWorldName @ " ("@ %this.linkedGate.address @ ")");
  882. %cl.Stargate = %this.linkedGate;
  883. %cl.StargatePos = %destPos;
  884. %destAng = mAtan(getWords(%destFor, 0), getWords(%destFor, 1));
  885. %cl.StargateSpawn = vectorAdd(%destPos, vectorScale(%destFor, 4))@" 0 0 1 "@%destAng;
  886. }
  887. }
  888. }
  889. %obj.setTransform(%tele@" 0 0 1 "@%ang);
  890. %fVel = vectorDot(%vel, %for);
  891. %rVel = vectorDot(%vel, %right);
  892. %uVel = vectorDot(%vel, %up);
  893. %obj.setVelocity(vectorAdd(vectorAdd(vectorScale(%destFor, -%fVel),
  894. vectorScale(%destRight, -%rVel)), vectorScale(%destUp, %uVel)));
  895. if(isObject(%cl = %obj.client))
  896. {
  897. %origWorldName = %this.worldName $= "" ? "a Hidden System" : %this.worldName;
  898. %linkedWorldName = %this.linkedGate.worldName $= "" ? "a Hidden System" : %this.linkedGate.worldName;
  899. echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] Player " @ %cl.name @ " travelled from " @ %origWorldName @ " (" @ %this.address @ ") to " @ %linkedWorldName @ " ("@ %this.linkedGate.address @ ")");
  900. %cl.Stargate = %this.linkedGate;
  901. %cl.StargatePos = %destPos;
  902. %destAng = mAtan(getWords(%destFor, 0), getWords(%destFor, 1));
  903. %cl.StargateSpawn = vectorAdd(%destPos, vectorScale(%destFor, 4))@" 0 0 1 "@%destAng;
  904. }
  905. if(%this.gateState == 2 || %this.gateState == 3)
  906. {
  907. if(!(%this.dontCloseOnObjectEnter ||
  908. (%obj.getClassName() $= "AIPlayer" && %this.dontCloseOnBotEnter)))
  909. {
  910. cancel(%this.shutSched);
  911. %this.shutSched = %this.schedule(20000, "CloseStargate");
  912. }
  913. }
  914. }
  915. }
  916. }
  917. else
  918. {
  919. if(%type & $Typemasks::PlayerObjectType)
  920. {
  921. %obj.spawnTime = 0;
  922. %obj.damage(%obj, %obj.position, 10000, $DamageType::Stargate_WrongSide);
  923. echo($obj);
  924. echo(%obj.name);
  925. echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] " @ %obj.client.name @ " died from attempting to go through a Stargate from the other side.");
  926. if(%obj.getState() $= "DEAD") { %obj.delete(); }
  927. }
  928. else if(%type & $Typemasks::VehicleObjectType)
  929. {
  930. %mounts = %obj.getDatablock().numMountPoints;
  931. for(%i=0;%i<%mounts;%i++)
  932. {
  933. %passenger = %obj.getMountedObject(%i);
  934. if(!isObject(%passenger)) continue;
  935. %passenger.spawnTime = 0;
  936. %passenger.damage(%passenger, %passenger.position, 10000, $DamageType::Stargate_WrongSide);
  937. echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] " @ %passenger.client.name @ " died from attempting to go through a Stargate from the other side.");
  938. if(%passenger.getState() $= "DEAD") { %passenger.delete(); }
  939. }
  940. %spawn = %obj.spawnBrick;
  941. if(isObject(%spawn))
  942. %spawn.respawnVehicle();
  943. else %obj.delete();
  944. }
  945. else if(%type & $Typemasks::ProjectileObjectType)
  946. %obj.delete();
  947. }
  948. }
  949. }
  950. if(isObject(%obj))
  951. {
  952. %this.SGLastDetect[%obj] = %now;
  953. %this.SGLastPos[%obj] = %pos;
  954. %this.SGLastVel[%obj] = %obj.getVelocity();
  955. }
  956. else %shift++;
  957. }
  958. %this.trackCount -= %shift;
  959. }
  960. function StaticShape::SlayNearby(%this, %mode, %len)
  961. {
  962. %scale = getWord(%this.getScale(), 2);
  963. if(%mode == 0)
  964. {
  965. %loc = %this.getPosition();
  966. %for = %this.getForwardVector();
  967. %up = %this.getUpVector();
  968. %right = vectorCross(%for, %up);
  969. initContainerRadiusSearch(vectorAdd(%loc, vectorScale(%for, 10)), %scale * 16 + 8, $Typemasks::PlayerObjectType);
  970. while(isObject(%obj = containerSearchNext()))
  971. {
  972. %pos = %obj.getHackPosition();
  973. %dir = vectorSub(%pos, %loc);
  974. %objF = vectorDot(%dir, %for);
  975. %objU = vectorDot(%dir, %up);
  976. %objR = vectorDot(%dir, %right);
  977. %objOffset = vectorLen(%objU SPC %objR);
  978. if(%objOffset > 3.6 * %scale) continue;
  979. if(mAbs(%objF) <= 0.36)
  980. {
  981. %obj.spawnTime = 0;
  982. %obj.damage(%obj, %obj.position, 10000, $DamageType::Stargate_Kawoosh);
  983. echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] " @ %obj.client.name @ " died from attempting to go through a Stargate from the other side.");
  984. if(%obj.getState() $= "DEAD") { %obj.delete(); }
  985. }
  986. %objOffset /= 3.6 * %scale;
  987. %kLen = %len - (%objOffset * %objOffset * %len);
  988. if(%objF < %kLen && %objF > 0)
  989. {
  990. %obj.spawnTime = 0;
  991. %obj.damage(%obj, %obj.position, 10000, $DamageType::Stargate_Kawoosh);
  992. echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] " @ %obj.client.name @ " died from attempting to go through a Stargate from the other side.");
  993. if(%obj.getState() $= "DEAD") { %obj.delete(); }
  994. }
  995. }
  996. }
  997. else if(%mode == 1)
  998. {
  999. initContainerRadiusSearch(%loc = %this.getPosition(), %scale * 10, $Typemasks::PlayerObjectType);
  1000. while(isObject(%obj = containerSearchNext()))
  1001. {
  1002. %pos = %obj.getHackPosition();
  1003. if(vectorDist(%pos, %loc) > 3.6 * %scale) continue;
  1004. %dir = vectorSub(%pos, %loc);
  1005. if(mAbs(vectorDot(%dir, %this.getForwardVector())) <= 0.35)
  1006. {
  1007. %obj.spawnTime = 0;
  1008. %obj.damage(%obj, %obj.position, 10000, $DamageType::Stargate_Telefrag);
  1009. echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] " @ %obj.client.name @ " died in a closing wormhole.");
  1010. if(%obj.getState() $= "DEAD") { %obj.delete(); }
  1011. }
  1012. }
  1013. cancel(%this.SGWormholeSched);
  1014. }
  1015. }
  1016. function StaticShape::setStargateState(%obj, %state)
  1017. {
  1018. if(%state == 0)
  1019. {
  1020. %obj.isOpened = 0;
  1021. %obj.isOpening = 0;
  1022. %obj.isClosed = 1;
  1023. %obj.isClosing = 0;
  1024. %obj.isDialing = 0;
  1025. %obj.gateState = 0;
  1026. }
  1027. else if(%state == 1)
  1028. {
  1029. %obj.isOpened = 0;
  1030. %obj.isOpening = 0;
  1031. %obj.isClosed = 0;
  1032. %obj.isClosing = 0;
  1033. %obj.isDialing = 1;
  1034. %obj.gateState = 1;
  1035. }
  1036. else if(%state == 2)
  1037. {
  1038. %obj.isOpened = 0;
  1039. %obj.isOpening = 1;
  1040. %obj.isClosed = 0;
  1041. %obj.isClosing = 0;
  1042. %obj.isDialing = 0;
  1043. %obj.gateState = 2;
  1044. }
  1045. else if(%state == 3)
  1046. {
  1047. %obj.isOpened = 1;
  1048. %obj.isOpening = 0;
  1049. %obj.isClosed = 0;
  1050. %obj.isClosing = 0;
  1051. %obj.isDialing = 0;
  1052. %obj.gateState = 3;
  1053. }
  1054. else if(%state == 4)
  1055. {
  1056. %obj.isOpened = 0;
  1057. %obj.isOpening = 0;
  1058. %obj.isClosed = 0;
  1059. %obj.isClosing = 1;
  1060. %obj.isDialing = 0;
  1061. %obj.gateState = 4;
  1062. }
  1063. }
  1064. function StaticShape::DeleteStargate(%obj)
  1065. {
  1066. for(%i=0;%i<3;%i++)
  1067. %obj.stopAudio(%i);
  1068. for(%i=0;%i<9;%i++)
  1069. {
  1070. %obj.ChevB[%i].delete();
  1071. %obj.ChevF[%i].delete();
  1072. %obj.ChevL[%i].delete();
  1073. }
  1074. %obj.kawoosh.delete();
  1075. %obj.horiz.delete();
  1076. %obj.inner.delete();
  1077. %obj.middle.delete();
  1078. %obj.dhd.delete();
  1079. %obj.delete();
  1080. }
  1081. function StaticShape::UpdateStargateTrans(%obj, %trans)
  1082. {
  1083. %obj.setTransform(%trans);
  1084. %obj.middle.setTransform(%trans);
  1085. %obj.inner.setTransform(%trans);
  1086. %obj.horiz.setTransform(%trans);
  1087. %obj.kawoosh.setTransform(%trans);
  1088. %pos = getWords(%trans, 0, 2);
  1089. %for = %obj.getForwardVector();
  1090. %up = %obj.getUpVector();
  1091. %right = vectorCross(%for, %up);
  1092. %hLen = vectorLen(getWords(%for, 0, 1));
  1093. %vAng = mAtan(getWord(%for, 2), %hLen) * (180 / $PI);
  1094. %hAng = mAtan(getWord(%for, 0), getWord(%for, 1)) * (180 / $PI);
  1095. %radius = getWord(%obj.getScale(), 2) * 4.2;
  1096. if(mAbs(vectorDot(%up, "0 0 1")) <= 0.999)
  1097. {
  1098. %hAng += 180; %vAng = 180 - %vAng;
  1099. if(mAbs(vectorDot(%for, "0 0 1")) <= 0.999) %rot += 180;
  1100. }
  1101. for(%i=0;%i<9;%i++)
  1102. {
  1103. %offset = vectorAdd(vectorScale(%right, mSin(%i*$PI/4.5)*-%radius),
  1104. vectorScale(%up, mCos(%i*$PI/4.5)*%radius));
  1105. %trans = vectorAdd(%pos, %offset) SPC eulerToAxis(%vAng SPC -360*(%i/9)+%rot SPC -%hAng);
  1106. %obj.ChevB[%i].setTransform(%trans);
  1107. %obj.ChevF[%i].setTransform(%trans);
  1108. %obj.ChevL[%i].setTransform(%trans);
  1109. %obj.ChevB[%i].ChevronPosition = getWords(%trans, 0, 3);
  1110. %obj.ChevL[%i].ChevronPosition = getWords(%trans, 0, 3);
  1111. }
  1112. }
  1113. function StaticShape::UpdateStargateScale(%obj, %scalar)
  1114. {
  1115. %scalar = getWord(%scalar, 0) * 1;
  1116. %scale = %scalar SPC %scalar SPC %scalar;
  1117. %obj.setScale(%scale);
  1118. %obj.middle.setScale(%scale);
  1119. %obj.inner.setScale(%scale);
  1120. %obj.horiz.setScale(%scale);
  1121. %obj.kawoosh.setScale(%scale);
  1122. %pos = getWords(%trans, 0, 2);
  1123. %for = %obj.getForwardVector();
  1124. %up = %obj.getUpVector();
  1125. %right = vectorCross(%for, %up);
  1126. %hLen = vectorLen(getWords(%for, 0, 1));
  1127. %vAng = mAtan(getWord(%for, 2), %hLen) * (180 / $PI);
  1128. %hAng = mAtan(getWord(%for, 0), getWord(%for, 1)) * (180 / $PI);
  1129. %radius = getWord(%obj.getScale(), 2) * 4.2;
  1130. if(mAbs(vectorDot(%up, "0 0 1")) <= 0.999)
  1131. {
  1132. %hAng += 180; %vAng = 180 - %vAng;
  1133. if(mAbs(vectorDot(%for, "0 0 1")) <= 0.999) %rot += 180;
  1134. }
  1135. for(%i=0;%i<9;%i++)
  1136. {
  1137. %offset = vectorAdd(vectorScale(%right, mSin(%i*$PI/4.5)*-%radius),
  1138. vectorScale(%up, mCos(%i*$PI/4.5)*%radius));
  1139. %trans = vectorAdd(%pos, %offset) SPC eulerToAxis(%vAng SPC -360*(%i/9)+%rot SPC -%hAng);
  1140. %obj.ChevB[%i].setScale(%scale);
  1141. %obj.ChevF[%i].setScale(%scale);
  1142. %obj.ChevL[%i].setScale(%scale);
  1143. %obj.ChevB[%i].setTransform(%trans);
  1144. %obj.ChevF[%i].setTransform(%trans);
  1145. %obj.ChevL[%i].setTransform(%trans);
  1146. %obj.ChevB[%i].ChevronPosition = getWords(%trans, 0, 3);
  1147. %obj.ChevL[%i].ChevronPosition = getWords(%trans, 0, 3);
  1148. }
  1149. }
  1150. function StaticShape::copyEnvironment(%gate)
  1151. {
  1152. %gate.skyTex = Sky.materialList;
  1153. %gate.groundTex = GroundPlane.topTexture;
  1154. %gate.dLightColor = Sun.color;
  1155. %gate.aLightColor = Sun.ambient;
  1156. %gate.shadowColor = Sun.shadowColor;
  1157. %gate.sunAzim = Sun.azimuth;
  1158. %gate.sunElev = Sun.elevation;
  1159. }
  1160. //Destiny gate symbols
  1161. //Symbol 1: 9.457616760
  1162. //Symbol 2: 16.557627498
  1163. //Delta: 7.100010738
  1164. //Symbol 5: 49.457612532
  1165. //Delta: 39.999995772
  1166. //MakeDHD(MakeStargate("0 0.25 4.5"), "0 20 1 1 0 0 0");
  1167. //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);
  1168. //%hit.DialStargate("27 7 15 32 12 30 1"); Abydos
  1169. //%hit.DialStargate("9 18 27 15 21 36 1"); Final Destination
  1170. //%hit.DialStargate("11 27 23 16 33 3 9 1"); Othala
  1171. //2 9 11 14 29 35
  1172. //%hit.DialStargate("6 0 0 0 0 0 5 0 1"); //Destiny - known symbols
  1173. //%hit.DialStargate("6 35 11 2 14 9 5 29 1"); //Destiny - assumed address
  1174. function MakeGates()
  1175. {
  1176. if(!$MadeGates)
  1177. {
  1178. $MadeGates = 1;
  1179. %earthGate = MakeStargate("0 0.25 5.3 "@eulerToAxis("0 0 0"), "28 26 5 36 11 29", 1, "Earth");
  1180. $gateObjs["28 26 5 36 11 29"] = %earthGate;
  1181. if(!isWriteableFileName("config/List.txt")) pathCopy("./List.txt", "config/List.txt", true);
  1182. if(isFile("config/List.txt")) {
  1183. %file = new FileObject();
  1184. %file.openForRead("config/List.txt");
  1185. echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] Loading planets in List.txt");
  1186. while(!%file.isEOF())
  1187. {
  1188. %line = %file.readLine();
  1189. echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] Loading line " @ %line);
  1190. %addresses[-1+%addresses++] = %line;
  1191. }
  1192. %file.close();
  1193. %file.delete();
  1194. echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] Planets successfully loaded");
  1195. } else {
  1196. error("ERROR: MakeGates(): Failed to open file List.txt for reading");
  1197. return;
  1198. }
  1199. //%address[-1+%address++] = "9-18-27-15-21-36 21";
  1200. //%address[-1+%address++] = "11-27-23-16-33-3-9 1 Othala";
  1201. //%address[-1+%address++] = "6-35-11-2-14-9-5-29 1 Destiny";
  1202. // Please add a BIGGER seed than 671.... and preferably a prime one over 100k+...
  1203. %id = createRandContext($Pref::Server::Stargate::RNGSeed); //*Magick* Mage's BL_ID
  1204. %dupcheck = $Pref::Server::Stargate::DuplicateCheck ? "duplicate check on" : "duplicate check off";
  1205. echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] Generating " @ $Pref::Server::Stargate::MaxHiddenAddresses @ " random addresses using seed " @ $Pref::Server::Stargate::RNGSeed @ ", " @ %dupcheck);
  1206. while(%addresses < $Pref::Server::Stargate::MaxHiddenAddresses)
  1207. {
  1208. %randAddr = "";
  1209. for(%i=0;%i<6;%i++)
  1210. {
  1211. %symbol = mFloor(rand(%id, 2, 40));
  1212. if(%symbol >= 40) %symbol = 39;
  1213. %flag = 1;
  1214. while(%flag)
  1215. {
  1216. %flag = 0;
  1217. for(%j=0;%j<%i;%j++)
  1218. if(getWord(%randAddr, %j) == %symbol)
  1219. {
  1220. %symbol = mFloor(rand(%id, 2, 40));
  1221. if(%symbol >= 40) %symbol = 39;
  1222. %flag = 1;
  1223. }
  1224. }
  1225. %randAddr = trim(%randAddr SPC %symbol);
  1226. }
  1227. %randAddr = strReplace(%randAddr, " ", "-");
  1228. if($Pref::Server::Stargate::DuplicateCheck) {
  1229. %duplicate = 0;
  1230. if($gateObjs[%randAddr]) %duplicate = 1;
  1231. if(%duplicate == 1) {
  1232. %randAddr = "";
  1233. for(%i=0;%i<6;%i++)
  1234. {
  1235. %symbol = mFloor(rand(%id, 2, 40));
  1236. if(%symbol >= 40) %symbol = 39;
  1237. %flag = 1;
  1238. while(%flag)
  1239. {
  1240. %flag = 0;
  1241. for(%j=0;%j<%i;%j++)
  1242. if(getWord(%randAddr, %j) == %symbol)
  1243. {
  1244. %symbol = mFloor(rand(%id, 2, 40));
  1245. if(%symbol >= 40) %symbol = 39;
  1246. %flag = 1;
  1247. }
  1248. }
  1249. %randAddr = trim(%randAddr SPC %symbol);
  1250. }
  1251. %randAddr = strReplace(%randAddr, " ", "-");
  1252. }
  1253. }
  1254. %addresses[-1+%addresses++] = %randAddr;
  1255. $gateObjs[%randAddr] = %randAddr;
  1256. }
  1257. echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] Generation complete; creating Stargates");
  1258. for(%y=0;%y<33;%y++)
  1259. {
  1260. %nVal = mFloatLength((%y - 16) * 443.405 * 2, 0) / 2;
  1261. %width = 33 - mAbs(%y - 16);
  1262. for(%x=0;%x<%width;%x++)
  1263. {
  1264. %eVal = (%x * 512) - ((%width - 1) * 256);
  1265. if(%nVal == 0 && %eVal == 0) continue;
  1266. %addrID = mFloor(rand(%id, 0, %addresses));
  1267. if(%addrID >= %addresses) %addrID = %addresses - 1;
  1268. %gateAddr = strReplace(getWord(%addr = %addresses[%addrID], 0), "-", " ");
  1269. if(getWord(%addr, 1) !$= "")
  1270. {
  1271. %origin = getWord(%addr, 1);
  1272. rand(%id, 2, 40);
  1273. }
  1274. else
  1275. {
  1276. %origin = mFloor(rand(%id, 2, 40));
  1277. if(%origin >= 40)
  1278. %origin = 39;
  1279. }
  1280. %ang = mFloor(rand(%id, 0, 4)) * 90;
  1281. %gateName = strReplace(getWord(%addr, 2), "_", " ");
  1282. %shift = 0;
  1283. for(%i=0;%i<%addresses;%i++)
  1284. if(%i == %addrID) %shift++;
  1285. else %addresses[%i - %shift] = %addresses[%i];
  1286. %addresses -= %shift;
  1287. %gate = MakeStargate(vectorAdd(%eVal SPC %nVal SPC 4.7,
  1288. vectorScale(-mSin(%ang/180*$PI) SPC mCos(%ang/180*$PI), -0.25))
  1289. SPC eulerToAxis("0 0 "@%ang), %gateAddr, %origin, %gateName);
  1290. %dhd = MakeDHD(%gate, vectorAdd(%eVal SPC %nVal SPC 1.2,
  1291. vectorScale(-mSin(%ang/180*$PI) SPC mCos(%ang/180*$PI), 20))
  1292. SPC eulerToAxis("0 0 "@%ang));
  1293. $gateObjs[%gateAddr] = %gate;
  1294. switch(%addrID)
  1295. {
  1296. case 0:
  1297. %gate.groundTex = "./TTasphalt01.jpg";
  1298. %gate.skyTex = "./Slate_Storm.dml";
  1299. %gate.sunAzim = 0;
  1300. %gate.sunElev = 90;
  1301. }
  1302. }
  1303. }
  1304. %earthGate.groundTex = "./cement-pebbled.jpg";
  1305. %earthGate.skyTex = "./Blue2.dml";
  1306. %earthGate.sunAzim = 0;
  1307. %earthGate.sunElev = 30;
  1308. %earthGate.autodialOnShutdown = 1;
  1309. %earthGate.spawnMalpBotOnLock = 1; //Temporary
  1310. %earthGate.dontCloseOnObjectEnter = 0;
  1311. %earthGate.dontCloseOnBotEnter = 1;
  1312. schedule(15000, 0, "StargateAutodial", %earthGate, 90);
  1313. echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] Stargates successfully created");
  1314. }
  1315. }
  1316. function StargateAutodial(%gate, %openTime)
  1317. {
  1318. if(!isObject(%gate)) return;
  1319. if(%gate.gateState != 0) return;
  1320. %gates = StargateNetwork.getCount();
  1321. for(%i=0;%i<%gates;%i++)
  1322. {
  1323. %obj = StargateNetwork.getObject(%i);
  1324. if(%obj.worldName !$= "")
  1325. {
  1326. if(%obj == %gate) continue;
  1327. %list[-1+%list++] = %obj;
  1328. }
  1329. }
  1330. if(%list > 0)
  1331. {
  1332. %gate.maxOpenTime = %openTime;
  1333. %dialGate = %list[getRandom(0, %list - 1)];
  1334. MessageAllInRange(%gate.getPosition(), "\c2"@trim(%gate.worldName SPC "Autodialler")@"\c6: Dialling to "@%dialGate.worldName@".");
  1335. echo("[" @ getWord(getDateTime(), 1) @ "] [Stargate] " @ %gate.worldName @ " autodialling to "@%dialGate.worldName);
  1336. %gate.DialStargate(%dialGate.address SPC %gate.pointOfOrigin);
  1337. for(%i=0;%i<3;%i++) %gate.lastAutodial[%i + 1] = %gate.lastAutodial[%i];
  1338. %gate.lastAutodial0 = %dialGate;
  1339. }
  1340. }
  1341. if(!isObject(StargateNetwork))
  1342. new SimSet(StargateNetwork);
  1343. MakeGates();