torment.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. function statusSet(%status, %blid, %value) { $Pref::Server::Status_[%status, %blid] = %value; }
  2. function statusGet(%status, %blid) { return $Pref::Server::Status_[%status, %blid]; }
  3. function statusGetClient(%status, %client) { return %client.bl_id !$= "" ? statusGet(%status, %client.bl_id) : ""; }
  4. function statusSetName(%status, %client, %name, %val, %toggle) {
  5. if(!%client.isAdmin) { messageClient(%client, 0, "You must be admin to use this command."); return; }
  6. if(%name+0 == 0) { // name
  7. if(%name $= "") %target = %client;
  8. else %target = findClientByName(%name);
  9. if(!isObject(%target)) { messageClient(%client, 0, "No client with that name."); return; }
  10. %blid = %target.bl_id; if(%blid $= "") { messageClient(%client, 0, "Target has no bl_id"); return; }
  11. %targetName = %target.name @ " (" @ %blid @ ")";
  12. } else { // blid
  13. %target = "";
  14. %blid = %name;
  15. %targetName = "BL_ID " @ %blid;
  16. }
  17. if(%toggle && %val$="") {
  18. statusSet(%status, %blid, statusGet(%status, %blid) ? "" : "1");
  19. } else if(%toggle) {
  20. statusSet(%status, %blid, statusGet(%status, %blid)$=%val ? "" : %val);
  21. } else {
  22. statusSet(%status, %blid, %val);
  23. }
  24. %newstatus = statusGet(%status, %blid);
  25. messageClient(%client, 0, %targetName @ ": " @ %status @ " set to " @ (%newstatus$="" ? "None" : %newstatus));
  26. return %target;
  27. }
  28. function statusToggleName(%status, %client, %name) {
  29. return statusSetName(%status, %client, %name, "", 1);
  30. }
  31. $Status_List[ 0] = "Killer";
  32. $Status_List[ 1] = "Harmless";
  33. $Status_List[ 2] = "Vulnerable";
  34. $Status_List[ 3] = "Invincible";
  35. $Status_List[ 4] = "SpawnBan";
  36. $Status_List[ 5] = "SuicideBan";
  37. $Status_List[ 6] = "BuildBan";
  38. $Status_List[ 7] = "ToolBan";
  39. $Status_List[ 8] = "ForceDatablock";
  40. $Status_List[ 9] = "Mute";
  41. $Status_List[10] = "ForceRespawn";
  42. $Status_List[11] = "Spiky";
  43. $Status_List[12] = "Piercing";
  44. $Status_List[13] = "LogicBan";
  45. $Status_List[14] = "DupBan";
  46. $Status_List[15] = "Gag";
  47. $Status_ListCount = 16;
  48. function serverCmdStatus(%client, %name) {
  49. if(!%client.isAdmin) { messageClient(%client, 0, "You must be admin to use this command."); return; }
  50. if(%name+0 == 0) { // name
  51. if(%name $= "") %target = %client;
  52. else %target = findClientByName(%name);
  53. if(!isObject(%target)) { messageClient(%client, 0, "No client with that name."); return; }
  54. %blid = %target.bl_id; if(%blid $= "") { messageClient(%client, 0, "Target has no bl_id"); return; }
  55. %targetName = %target.name @ " (" @ %blid @ ")";
  56. } else {
  57. %target = "";
  58. %blid = %name;
  59. %targetName = "BL_ID " @ %blid;
  60. }
  61. %list = "";
  62. for(%i=0; %i<$Status_ListCount; %i++) {
  63. %statusname = $Status_List[%i];
  64. %status = statusGet(%statusname, %blid);
  65. if (%status==1 ) %list = %list @ %statusname @ ", ";
  66. else if(%status!$="" && %status!$="0") %list = %list @ %statusname @ "=" @ %status @ ", ";
  67. }
  68. if(%list $= "") %list = "None";
  69. else %list = getSubStr(%list, 0, strLen(%list)-2);
  70. messageClient(%client, 0, %targetName @ " status: " @ %list);
  71. }
  72. function serverCmdDA(%client) { if(%client.isAdmin) { $canDamageAll = !$canDamageAll; messageClient(%client, 0, "canDamageAll = " @ $canDamageAll); } }
  73. function serverCmdKiller (%client, %name) { statusToggleName("Killer" , %client, %name); }
  74. function serverCmdHarmless (%client, %name) { statusToggleName("Harmless" , %client, %name); }
  75. function serverCmdVulnerable (%client, %name) { statusToggleName("Vulnerable" , %client, %name); }
  76. function serverCmdInvincible (%client, %name) { %c = statusToggleName("Invincible" , %client, %name); if(isObject(%c) && isObject(%c.player)) { %c.player.invulnerable = statusGetClient("Invincible", %c); cancel(%c.player.reinvulnSched); } }
  77. function serverCmdSpawnBan (%client, %name) { %c = statusToggleName("SpawnBan" , %client, %name); if(isObject(%c)) %c.spawnPlayer(); }
  78. function serverCmdSuicideBan (%client, %name) { statusToggleName("SuicideBan" , %client, %name); }
  79. function serverCmdBuildBan (%client, %name) { statusToggleName("BuildBan" , %client, %name); }
  80. function serverCmdToolBan (%client, %name) { %c = statusToggleName("ToolBan" , %client, %name); if(isObject(%c) && isObject(%c.player)) %c.player.unmountImage(0); }
  81. function serverCmdMute (%client, %name) { statusToggleName("Mute" , %client, %name); }
  82. function serverCmdGag (%client, %name) { statusToggleName("Gag" , %client, %name); }
  83. function serverCmdForceRespawn(%client, %name) { %c = statusToggleName("ForceRespawn" , %client, %name); if(isObject(%c) && !isObject(%c.player)) %c.instantRespawn(); }
  84. function serverCmdSpiky (%client, %name) { statusToggleName("Spiky" , %client, %name); }
  85. function serverCmdPiercing (%client, %name) { statusToggleName("Piercing" , %client, %name); }
  86. function serverCmdLogicBan (%client, %name) { statusToggleName("LogicBan" , %client, %name); }
  87. function serverCmdDupBan (%client, %name) { statusToggleName("DupBan" , %client, %name); }
  88. function serverCmdNoJet (%client, %name) { %c = statusSetName("ForceDatablock", %client, %name, "PlayerNoJet" , 1); statusUpdateDatablock(%c); }
  89. function serverCmdHorse (%client, %name) { %c = statusSetName("ForceDatablock", %client, %name, "HorseArmor" , 1); statusUpdateDatablock(%c); }
  90. function spawnBanDeletePlayer(%client) {
  91. if(isObject(%client.player)) %client.player.delete();
  92. }
  93. function setInvulnerable(%player, %status) {
  94. %player.invulnerable = %status;
  95. }
  96. function statusUpdateDatablock(%client) {
  97. if(isObject(%client) && isObject(%player = %client.player)) {
  98. %client.player.setDatablock(%player.desiredDatablock!$="" ? %player.desiredDatablock : "PlayerStandardArmor");
  99. }
  100. }
  101. function gagMessage(%msg) {
  102. %newMsg = "";
  103. for(%i=0; %i<strLen(%msg); %i++) {
  104. %c = getSubStr(%msg, %i, 1);
  105. if(%c $= " ") %newMsg = %newMsg @ " ";
  106. else if(strPos(strUpr(%c), %c) == -1) %newMsg = %newMsg @ "m";
  107. else if(strPos(strLwr(%c), %c) == -1) %newMsg = %newMsg @ "M";
  108. else if(strPos("0123456789", %c) != -1) %newMsg = %newMsg @ "n";
  109. else %newMsg = %newMsg @ %c;
  110. }
  111. return %newMsg;
  112. }
  113. package Torment {
  114. function GameConnection::spawnPlayer(%client){
  115. if(statusGetClient("SpawnBan", %client)){
  116. schedule(33, 0, spawnBanDeletePlayer, %client);
  117. }
  118. return parent::spawnPlayer(%client);
  119. }
  120. function serverCmdSuicide(%client){
  121. if(statusGetClient("SuicideBan", %client)) return;
  122. if(%client.player.invulnerable) %client.player.invulnerable = 0;
  123. parent::serverCmdSuicide(%client);
  124. }
  125. function serverCmdPlantBrick(%client){
  126. if(statusGetClient("BuildBan", %client) || statusGetClient("ToolBan", %client)) return;
  127. if(isObject(%client.player) && isObject(%client.player.tempBrick) &&
  128. %client.player.tempBrick.getDatablock().isLogic && statusGetClient("LogicBan", %client)) return;
  129. parent::serverCmdPlantBrick(%client);
  130. }
  131. function serverCmdCreateMinigame(%client, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8){
  132. if(statusGetClient("SuicideBan", %client) || statusGetClient("SpawnBan", %client)) return;
  133. parent::serverCmdCreateMinigame(%client, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8);
  134. }
  135. function serverCmdJoinMinigame(%client, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8){
  136. if(statusGetClient("SuicideBan", %client) || statusGetClient("SpawnBan", %client)) return;
  137. parent::serverCmdJoinMinigame(%client, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8);
  138. }
  139. function serverCmdAcceptMinigameInvite(%client, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8){
  140. if(statusGetClient("SuicideBan", %client) || statusGetClient("SpawnBan", %client)) return;
  141. parent::serverCmdAcceptMinigameInvite(%client, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8);
  142. }
  143. function serverCmdClearCheckpoint(%client) {
  144. if(statusGetClient("SuicideBan", %client) || statusGetClient("SpawnBan", %client)) return;
  145. parent::serverCmdClearCheckpoint(%client);
  146. }
  147. function serverCmdMessageSent(%client, %msg){
  148. if(statusGetClient("Mute", %client)) return;
  149. if(statusGetClient("Gag", %client)) %msg = gagMessage(%msg);
  150. parent::serverCmdMessageSent(%client, %msg);
  151. }
  152. function serverCmdTeamMessageSent(%client, %msg){
  153. if(statusGetClient("Mute", %client)) return;
  154. parent::serverCmdTeamMessageSent(%client, %msg);
  155. }
  156. function serverCmdStartTalking(%client) {
  157. if(statusGetClient("Mute", %client)) return;
  158. parent::serverCmdStartTalking(%client);
  159. }
  160. function GameConnection::onDeath(%client, %sourceObject, %sourceClient, %damageType, %location) {
  161. parent::onDeath(%client, %sourceObject, %sourceClient, %damageType, %location);
  162. if(statusGetClient("ForceRespawn", %client)) {
  163. %client.schedule(0, instantRespawn);
  164. }
  165. }
  166. function GameConnection::createPlayer(%client, %spawnpoint) {
  167. parent::createPlayer(%client, %spawnpoint);
  168. %forcedb = statusGetClient("ForceDatablock", %client);
  169. if(%forcedb!$="") {
  170. %player = %client.player;
  171. if(isObject(%player)) {
  172. %player.setDatablock(%player.getDatablock());
  173. }
  174. }
  175. if(statusGetClient("Invincible", %client)) {
  176. %player = %client.player;
  177. if(isObject(%player)) {
  178. %player.invulnerable = 1;
  179. }
  180. }
  181. }
  182. function Player::setDatablock(%player, %datablock) {
  183. if(isObject(%player.client) && (%forcedb = statusGetClient("ForceDatablock", %player.client))!$="") {
  184. %player.desiredDatablock = %datablock;
  185. %datablock = %forcedb;
  186. }
  187. parent::setDatablock(%player, %datablock);
  188. }
  189. function minigameCanDamage(%attacker, %target) {
  190. if(%attacker.getClassName() $= "fxDtsBrick") {
  191. %mg1 = getMinigameFromObject(%attacker);
  192. if(!%mg1.brickDamage){ return 0; }
  193. }
  194. %attackerclient = %attacker.getClassName() $= "GameConnection" ? %attacker : %attacker.client;
  195. %targetclient = %target .getClassName() $= "GameConnection" ? %target : %target .client;
  196. if(statusGetClient("Piercing" , %attackerclient) && isObject(%targetclient.player) && %targetclient.player.invulnerable) {
  197. %targetclient.player.invulnerable = 0;
  198. cancel(%targetclient.player.reinvulnSched);
  199. %targetclient.player.reinvulnSched = schedule(1, 0, setInvulnerable, %targetclient.player, 1);
  200. }
  201. if(statusGetClient("Invincible", %targetclient ) && !statusGetClient("Piercing", %attackerclient)) { return 0; }
  202. if(statusGetClient("Harmless" , %attackerclient) && %attackerclient != %targetclient) { return 0; }
  203. if($canDamageAll) { return 1; }
  204. if(statusGetClient("Killer" , %attackerclient)) { return 1; }
  205. if(statusGetClient("Vulnerable", %targetclient )) { return 1; }
  206. if(parent::minigameCanDamage(%attacker, %target) == 1) { return 1; }
  207. return 0;
  208. }
  209. function serverCmdUseTool(%client, %slot) {
  210. if(statusGetClient("ToolBan", %client)) return;
  211. parent::serverCmdUseTool(%client, %slot);
  212. }
  213. function serverCmdUseSprayCan(%client, %index) {
  214. if(statusGetClient("ToolBan", %client)) return;
  215. parent::serverCmdUseSprayCan(%client, %index);
  216. }
  217. function Player::mountImage(%player, %image, %slot) {
  218. if(isObject(%client = %player.client) && isObject(%image)) {
  219. if(statusGetClient("ToolBan", %client)) return;
  220. %name = %image.getName();
  221. if((getSubStr(%name, 0, 8) $= "ND_Image" || %name $= "fillcanImage") &&
  222. (statusGetClient("BuildBan", %client) || statusGetClient("DupBan", %client))) return;
  223. if(statusGetClient("BuildBan", %client) &&
  224. (%name $= "brickImage" || getSubStr(%name, strLen(%name)-13, strLen(%name)) $= "SprayCanImage" || %name $= "fillcanImage")) return;
  225. }
  226. parent::mountImage(%player, %image, %slot);
  227. }
  228. function Armor::onCollision(%data, %player, %col, %vec, %speed) {
  229. parent::onCollision(%data, %player, %col, %vec, %speed);
  230. if(%col.getType() & $TypeMasks::PlayerObjectType) {
  231. if(statusGetClient("Spiky", %player.client)) {
  232. %col.damage(%player, %player.getPosition(), 100, $DamageType::Fall);
  233. }
  234. }
  235. }
  236. function serverCmdRespawn(%client, %name) {
  237. if(!%client.isAdmin) { messageClient(%client, 0, "You must be admin to use this command."); return; }
  238. if(%name $= "") %target = %client; else %target = findClientByName(%name);
  239. if(!isObject(%target)) { messageClient(%client, 0, "No client named " @ %name @ " found."); return; }
  240. %target.instantRespawn();
  241. messageClient(%client, 0, "Respawned " @ %target.name);
  242. }
  243. };
  244. schedule(0, 0, activatePackage, Torment);
  245. schedule(100, 0, resetAllOpCallFunc);