123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- ForceRequiredAddOn("Script_Player_Persistence");
- exec("./Preferences.cs");
- registerPrefs();
- package StargateWandering
- {
- function GameConnection::createPlayer(%cl, %trans)
- {
- RegisterPersistenceVar("Stargate", false, "");
- RegisterPersistenceVar("StargatePos", false, "");
- RegisterPersistenceVar("StargateSpawn", false, "");
- if(!%cl.hasSpawnedOnce || %cl.hasSpawnedOnce && !%cl.Stargate && !%cl.StargatePos && !%cl.StargateSpawn)
- {
- %earthGate = $gateObjs["28 26 5 36 11 29"];
- %earthPos = %earthGate.getPosition();
- %earthForV = %earthGate.getForwardVector();
- %earthAng = mAtan(getWords(%earthForV, 0), getWords(%earthForV, 1));
- %cl.Stargate = %earthGate;
- %cl.StargatePos = %earthPos;
- %cl.StargateSpawn = vectorAdd(%earthPos, vectorScale(%earthForV, 4))@" 0 0 1 "@%earthAng;
- }
- if(%cl.StargateSpawn !$= "")
- %trans = %cl.StargateSpawn;
- Parent::createPlayer(%cl, %trans);
- if(isObject(%pl = %cl.player))
- %pl.StargateLoop(getSimTime());
- }
-
- function servercmdFind(%cl, %targ)
- {
- if(%cl.isAdmin && isObject(%targ))
- {
- %cl.Stargate = %targ.Stargate;
- %cl.StargatePos = %targ.StargatePos;
- %cl.StargateSpawn = %targ.StargateSpawn;
- }
- else if(%cl.isAdmin && isObject(%vict = findClientByName(%targ)))
- {
- %cl.Stargate = %vict.Stargate;
- %cl.StargatePos = %vict.StargatePos;
- %cl.StargateSpawn = %vict.StargateSpawn;
- }
- Parent::servercmdFind(%cl, %targ);
- }
-
- function servercmdFetch(%cl, %targ)
- {
- if(%cl.isAdmin && isObject(%targ))
- {
- %targ.Stargate = %cl.Stargate;
- %targ.StargatePos = %cl.StargatePos;
- %targ.StargateSpawn = %cl.StargateSpawn;
- }
- else if(%cl.isAdmin && isObject(%vict = findClientByName(%targ)))
- {
- %vict.Stargate = %cl.Stargate;
- %vict.StargatePos = %cl.StargatePos;
- %vict.StargateSpawn = %cl.StargateSpawn;
- }
- Parent::servercmdFetch(%cl, %targ);
- }
- function sendMessage(%cl, %msg) {
- commandToClient(%cl, 'chatMessage', %cl, '', '', "\c7"@%cl.clanPrefix@"\c3"@%cl.name@"\c7"@%cl.clanSuffix@"\c6: "@%msg, %cl.clanPrefix, %cl.name, %cl.clanSuffix, %msg);
- }
-
- function servercmdMessageSent(%cl, %msg)
- {
- if(isFunction("SetMode") && SetMode(%cl, %msg) == 2) return;
-
- if(!%cl.hasSpawnedOnce) %pos = "0 0 0";
- else %pos = %cl.getControlObject().getEyePoint();
-
- %idcHash = sha1(%cl.bl_id);
- %hex = "0123456789ABCDEF";
- for(%i=0;%i<10;%i++)
- {
- %digit = 0;
- for(%j=0;%j<4;%j++)
- %digit = (%digit << 4) | striPos(%hex, getSubStr(%idcHash, %i * 4 + %j, 1));
- %realIDC = %realIDC @ mFloor(%digit / 6553.6);
- }
- if(%msg $= %realIDC || (%msg !$= "" && getSubStr(%msg, 0, strLen(%msg) - 1) $= %realIDC))
- {
- if(%msg !$= %realIDC)
- %suffix = getSubStr(%msg, strLen(%msg) - 1, 1);
- %gates = StargateNetwork.getCount();
- for(%i=0;%i<%gates;%i++)
- {
- %gate = StargateNetwork.getObject(%i);
- if(isObject(%pair = %gate.linkedGate)
- || isObject(%pair = %gate.masterGate))
- {
- %dist = getMin(vectorDist(%pos, %gate.getPosition()),
- vectorDist(%pos, %pair.getPosition()));
- if(%dist <= 32)
- {
- initContainerRadiusSearch(%gate.getPosition(), 16, $Typemasks::fxBrickAlwaysObjectType);
- while(isObject(%brick = containerSearchNext()))
- {
- if(%suffix $= "")
- %brick.ReceivedValidIDC(%realIDC, %cl);
- else if(%suffix $= "D" && isObject(%gate.masterGate))
- %brick.ReceivedValidIDC_D(%realIDC, %cl);
- else if(%suffix $= "O" && isObject(%gate.linkedGate))
- %brick.ReceivedValidIDC_O(%realIDC, %cl);
- }
- }
- }
- }
- %cl.chatMessage("\c6Identification code transmitted!");
- return;
- }
-
- while((%temp = stripMLControlChars(%msg)) !$= %msg)
- %msg = %temp;
- %msg = ParseLinks(%msg);
- %gates = StargateNetwork.getCount();
- for(%i=0;%i<%gates;%i++)
- {
- %gate = StargateNetwork.getObject(%i);
- if(isObject(%pair = %gate.linkedGate)
- || isObject(%pair = %gate.masterGate))
- {
- %gateDist[%i] = getMin(vectorDist(%pos, %gate.getPosition()),
- vectorDist(%pos, %pair.getPosition()));
- }
- }
-
- %clients = ClientGroup.getCount();
- for(%i=0;%i<%clients;%i++)
- {
- %this = ClientGroup.getObject(%i);
- if(!%this.hasSpawnedOnce) %loc = "0 0 0";
- else %loc = %this.getControlObject().getEyePoint();
- if(vectorDist(%pos, %loc) < 256)
- sendMessage(%cl, %msg);
- else
- {
- for(%j=0;%j<%gates;%j++)
- {
- if(%gateDist[%j] $= "") continue;
- %sumDist = vectorDist(%loc, StargateNetwork.getObject(%j).getPosition()) + %gateDist[%j];
- if(%sumDist < 256) {
- sendMessage(%cl, %msg);
- break;
- } else {
- %admin = %cl.isAdmin;
- %superAdmin = %cl.isSuperAdmin;
- %host = !$Server::LAN && %cl.getBLID() == getNumKeyID();
- if($Pref::Server::Stargate::ChatRangeBypass && $Pref::Server::Stargate::ChatRangeBypassRank $= "1" && %admin || %superAdmin || %host) sendMessage(%cl, %msg);
- if($Pref::Server::Stargate::ChatRangeBypass && $Pref::Server::Stargate::ChatRangeBypassRank $= "2" && %superAdmin || %host) sendMessage(%cl, %msg);
- if($Pref::Server::Stargate::ChatRangeBypass && $Pref::Server::Stargate::ChatRangeBypassRank $= "3" && %host) sendMessage(%cl, %msg);
- }
- }
- }
- }
- echo(%cl.name@": "@%msg);
- }
-
- function servercmdPlantBrick(%cl)
- {
- %admin = %cl.isAdmin;
- %superAdmin = %cl.isSuperAdmin;
- %host = !$Server::LAN && %cl.getBLID() == getNumKeyID();
- if($Pref::Server::Stargate::BypassBorder && $Pref::Server::Stargate::BypassBorderRank $= "1" && %admin || %superAdmin || %host) return Parent::servercmdPlantBrick(%cl);
- if($Pref::Server::Stargate::BypassBorder && $Pref::Server::Stargate::BypassBorderRank $= "2" && %superAdmin || %host) return Parent::servercmdPlantBrick(%cl);
- if($Pref::Server::Stargate::BypassBorder && $Pref::Server::Stargate::BypassBorderRank $= "3" && %host) return Parent::servercmdPlantBrick(%cl);
- if(isObject(%pl = %cl.player) && isObject(%temp = %pl.tempbrick))
- {
- %farthest = %temp.getFarthestPoint(%cl.StargatePos);
- %len = vectorLen(getWords(%farthest, 0, 1));
- if(%len > 256)
- {
- messageClient(%cl,'MsgPlantError_TooFar');
- return;
- }
- }
- Parent::servercmdPlantBrick(%cl);
- }
- };
- activatePackage("StargateWandering");
- function ParseLinks(%msg)
- {
- %words = getWordCount(%msg);
- for(%i=0;%i<%words;%i++)
- {
- %word = getWord(%msg, %i);
- if(getSubStr(%word, 0, 7) $= "http://")
- %msg = setWord(%msg, %i, "<a:"@(%word=strReplace(%word, "http://", ""))@">"@%word@"</a>");
- else if(getSubStr(%word, 0, 8) $= "https://")
- %msg = setWord(%msg, %i, "<a:"@(%word=strReplace(%word, "https://", ""))@">"@%word@"</a>");
- else if(getSubStr(%word, 0, 6) $= "ftp://")
- %msg = setWord(%msg, %i, "<a:"@(%word=strReplace(%word, "ftp://", ""))@">"@%word@"</a>");
- }
- return trim(%msg);
- }
- function Player::StargateLoop(%pl, %last)
- {
- cancel(%pl.StargateLoop);
- %pl.StargateLoop = %pl.schedule(50, "StargateLoop");
- if(isObject(%cl = %pl.client))
- {
- %admin = %cl.isAdmin;
- %superAdmin = %cl.isSuperAdmin;
- %host = !$Server::LAN && %cl.getBLID() == getNumKeyID();
- if($Pref::Server::Stargate::BypassBorder && $Pref::Server::Stargate::BypassBorderRank $= "1" && %admin || %superAdmin || %host) return;
- if($Pref::Server::Stargate::BypassBorder && $Pref::Server::Stargate::BypassBorderRank $= "2" && %superAdmin || %host) return;
- if($Pref::Server::Stargate::BypassBorder && $Pref::Server::Stargate::BypassBorderRank $= "3" && %host) return;
- %diff = vectorSub(%pl.getHackPosition(), %cl.StargatePos);
- %len = vectorLen(getWords(%diff, 0, 1));
- if(%len >= 256)
- {
- %out = vectorNormalize(getWords(%diff, 0, 1));
- %pos = vectorAdd(%cl.StargatePos, vectorScale(%out, 256));
- %pl.setTransform(getWords(%pos, 0, 1) SPC getWords(%pl.getTransform(), 2, 6));
- %oVel = vectorScale(%out, -vectorDot(%pl.getVelocity(), %out));
- %pl.addVelocity(%oVel);
- }
- }
- }
- function servercmdWhatsMyIDC(%cl)
- {
- %idcHash = sha1(%cl.bl_id);
- %hex = "0123456789ABCDEF";
- for(%i=0;%i<10;%i++)
- {
- %digit = 0;
- for(%j=0;%j<4;%j++)
- %digit = (%digit << 4) | striPos(%hex, getSubStr(%idcHash, %i * 4 + %j, 1));
- %realIDC = %realIDC @ mFloor(%digit / 6553.6);
- }
- %cl.chatMessage("\c6Your IDC is \c4"@%realIDC@"\c6.");
- }
- function planetCmd(%cl) {
- %gateObj = %cl.Stargate;
- if (%gateObj $= null || %gateObj $= "")
- return %cl.chatMessage("\c0Your planet has not been located. Please travel to a different one to access the Planetary Index.");
- %worldName = %gateObj.worldName $= "" || %gateObj.worldName $= null ? "a Hidden System" : %gateObj.worldName;
- %address = %gateObj.address;
- %poo = %gateObj.pointOfOrigin;
- %cl.chatMessage("\c6You are on \c3"@%worldName@"\c6, with the address \c4"@%address@"\c6 and the point of origin as glyph \c1"@%poo@"\c6.");
- }
- function servercmdWhatsMyPlanet(%cl)
- {
- %admin = %cl.isAdmin;
- %superAdmin = %cl.isSuperAdmin;
- %host = !$Server::LAN && %cl.getBLID() == getNumKeyID();
- if($Pref::Server::Stargate::WhatsMyPlanetCmd && $Pref::Server::Stargate::WhatsMyPlanetCmdRank $= 1 && %admin || %superAdmin || %host) return planetCmd(%cl);
- if($Pref::Server::Stargate::WhatsMyPlanetCmd && $Pref::Server::Stargate::WhatsMyPlanetCmdRank $= 2 && %superAdmin || %host) return planetCmd(%cl);
- if($Pref::Server::Stargate::WhatsMyPlanetCmd && $Pref::Server::Stargate::WhatsMyPlanetCmdRank $= 3 && %host) return planetCmd(%cl);
- }
- exec("./Bricks/_Init.cs");
- exec("./Libraries/_Init.cs");
- exec("./Sounds/_Init.cs");
- exec("./BotMALP.cs");
- exec("./DHD.cs");
- exec("./Environ.cs");
- exec("./Events.cs");
- exec("./Functions.cs");
- exec("./MALP_AI.cs");
- exec("./Painting.cs");
- exec("./Stargate.cs");
- exec("./Vehicles.cs");
- function getUnitVector()
- {
- %elev = mAsin(getRandom() * 2 - 1);
- %azim = (getRandom() * 2 - 1) * $PI;
- %z = mSin(%elev); %l = mCos(%elev);
- %x = mSin(%azim) * %l;
- %y = mCos(%azim) * %l;
- return %x SPC %y SPC %z;
- }
- //Stargate outermost diameter: 8.88
- //Stargate innermost diameter: 7.20
- //Tollan gate outermost diameter: 8.50
|