Guest User

Untitled

a guest
Oct 20th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 46.76 KB | None | 0 0
  1. /*
  2.  
  3. [work_in_progress]
  4. [work_in_progress]
  5. [work_in_progress]
  6.  
  7. UPDATE IDs up here and for !TimeJump, line 500
  8.  
  9.  
  10. Author: gui8312
  11. API Name: SurvivalTimer
  12. Date: 18th of October 2017
  13. General description:
  14. * This API allows for survival factors to affect players over time. Only affects online players.
  15. * Created for RPGs in general, some tweaking will almost certainly be needed to adjust to your campaign.
  16. * The statuses are: Hunger, Exhaustion, Temperature, Wetness. If these Statuses surpass 30 (absolute value), negative effects kick in. Over 60 and character faints.
  17. * One last attribute is included to give an idea of all statuses together: survival_status=240-(hunger+exhaustion+math.abs(temperature)+wetness)
  18. * Statuses are updated every 10 minutes (can be changed at the bottom of the script)
  19. * Player actions like eating food to lower hunger need to be done manually, this script only affects over time effects.
  20. * Works for campaigns with up to 10 players+GM, each player controlling up to 5 Characters. Player IDs and their respective character IDS need to be introduced into the API manually once, in the ID list at the top.
  21. * To be sure the API works: provide at the very least the GM's player ID, the ID of one non-GM player and the ID of one character that the non-GM Player controls.
  22. Statuses described:
  23. * Hunger and Exhaustion are lost over time and recovered by eating and resting respectively.
  24. * Temperature and Wetness are affected by the map. To control this you need to include the following keywords in the maps name: HOT,MILD,COLD,DRY,WET. Keywords that are repeated intesify the effects.
  25. ex1: Black Forest COLD DRY (This map will reduce the Temperature of the players and it will reduce their wetness)
  26. ex2: Snowy Peak COLD COLD COLD WET (This Map will strongly reduce the Temperature of players over time and slowly raise their wetness)
  27. ex3: White Blossoms MILD DRY DRY (This map will get Temperature closer to optimal value as time passes and will dry up players pretty fast)
  28. Note1: Maps with no keywords will only affect hunger and exhaustion, the rest will stay as it is.
  29. Note2: Maps with only one time COLD/HOT will only get the temperature to a certain level, not being enough to harm the players.
  30. Pacing:
  31. * Hunger is raised by 10 every 4 hours of gameplay. Exhaustion is raised by 30 in the same time.
  32. * Temperature is changed based on the map name. Same for Wetness. Best to test the pace before the Session.
  33. Default effects:
  34. * Starving, Hunger > 30, All rolls with disadvantage
  35. * Exhausted, Exhaustion > 30, All rolls with disadvantage
  36. * Hot, Temperature > 30, Heatstroke sets in, damaging player for around 10% of their max HP every 10mins; chance of food rotting; chance of getting sick, strongly reducing Movement abilities (MP) and Action abailities (AP)
  37. * Cold, Temperature < -30, Frostbite sets in, damaging player for around 10% of their max HP every 10mins; chance of getting sick slighty reducing Movement abilities (MP) and Action abailities (AP)
  38. * Drenched, Wetness > 30, Chance of food rotting pretty high, chance of getting very sick (strongly reducing Movement abilities (MP) and Action abailities (AP)) or almost dying from sickness (blocks Movement abilities (MP) and Action abailities (AP))
  39. * Any of the stats above > 60 (absolute value), fainting sets in, putting HP at 0.
  40. */
  41.  
  42. on("ready", function() {
  43.  
  44. //To find ID of a character, create a character, get a token associated with it, select token and input into chat: @{selected|character_id}
  45. //GM can put some characters in his name here, for testing purposes. Leave quotes!
  46. var P1_C1_id = ""//character 1 ID of GM
  47. var P1_C2_id = ""//you can add here character 2 ID of GM, just put the ID between the quotes. If GM controls no other characters leave empty quotes.
  48. var P1_C3_id = ""//you can add here character 3 ID of GM, just put the ID between the quotes. If GM controls no other characters leave empty quotes.
  49. var P1_C4_id = ""//you can add here character 4 ID of GM, just put the ID between the quotes. If GM controls no other characters leave empty quotes.
  50. var P1_C5_id = ""//you can add here character 5 ID of GM, just put the ID between the quotes. If GM controls no other characters leave empty quotes.
  51.  
  52. //Players
  53. var P2 = findObjs({_type: "player", _id: "" })[0]; //Player2, Player ID. Not to be confused with character IDs.
  54. //Insert Player Character IDs that should suffer from survival factors in here. Leave Quotes!
  55. //To find ID of a character, create a character, get a token associated with it, select token and input into chat: @{selected|character_id} var P2_C1_id = "-KteLQkakNut7vI8zoJR"//character ID of Avarin
  56.  
  57. var P2_C1_id = ""//character 1 ID of Player 2
  58. var P2_C2_id = ""//you can add here character 2 ID of Player2, just put the ID between the quotes. If Player 2 controls no other characters leave empty quotes.
  59. var P2_C3_id = ""//you can add here character 3 ID of Player2, just put the ID between the quotes. If Player 2 controls no other characters leave empty quotes.
  60. var P2_C4_id = ""//you can add here character 4 ID of Player2, just put the ID between the quotes. If Player 2 controls no other characters leave empty quotes.
  61. var P2_C5_id = ""//you can add here character 5 ID of Player2, just put the ID between the quotes. If Player 2 controls no other characters leave empty quotes.
  62. var P3 = findObjs({_type: "player", _id: "" })[0]; //Player3, Player ID, leave empty ("") if there are no more players
  63. var P3_C1_id = ""//you can add here character 1 ID of Player3, just put the ID between the quotes. If Player 3 controls no other characters leave empty quotes.
  64. var P3_C2_id = ""//
  65. var P3_C3_id = ""//
  66. var P3_C4_id = ""//
  67. var P3_C5_id = ""//
  68. var P4 = findObjs({_type: "player", _id: "" })[0]; //Player4, Player ID, leave empty ("") if there are no more players
  69. var P4_C1_id = ""//you can add here character 1 ID of Player4, just put the ID between the quotes. If Player 4 controls no other characters leave empty quotes.
  70. var P4_C2_id = ""//
  71. var P4_C3_id = ""//
  72. var P4_C4_id = ""//
  73. var P4_C5_id = ""//
  74. var P5 = findObjs({_type: "player", _id: "" })[0]; //Player5, Player ID, leave empty ("") if there are no more players
  75. var P5_C1_id = ""//you can add here character 1 ID of Player5, just put the ID between the quotes. If Player 5 controls no other characters leave empty quotes.
  76. var P5_C2_id = ""//
  77. var P5_C3_id = ""//
  78. var P5_C4_id = ""//
  79. var P5_C5_id = ""//
  80. var P6 = findObjs({_type: "player", _id: "" })[0]; //Player6, Player ID, leave empty ("") if there are no more players
  81. var P6_C1_id = ""//you can add here character 1 ID of Player6, just put the ID between the quotes. If Player 6 controls no other characters leave empty quotes.
  82. var P6_C2_id = ""//
  83. var P6_C3_id = ""//
  84. var P6_C4_id = ""//
  85. var P6_C5_id = ""//
  86. var P7 = findObjs({_type: "player", _id: "" })[0]; //Player7, Player ID, leave empty ("") if there are no more players
  87. var P7_C1_id = ""//you can add here character 1 ID of Player7, just put the ID between the quotes. If Player 7 controls no other characters leave empty quotes.
  88. var P7_C2_id = ""//
  89. var P7_C3_id = ""//
  90. var P7_C4_id = ""//
  91. var P7_C5_id = ""//
  92. var P8 = findObjs({_type: "player", _id: "" })[0]; //Player8, Player ID, leave empty ("") if there are no more players
  93. var P8_C1_id = ""//you can add here character 1 ID of Player8, just put the ID between the quotes. If Player 8 controls no other characters leave empty quotes.
  94. var P8_C2_id = ""//
  95. var P8_C3_id = ""//
  96. var P8_C4_id = ""//
  97. var P8_C5_id = ""//
  98. var P9 = findObjs({_type: "player", _id: "" })[0]; //Player9, Player ID, leave empty ("") if there are no more players
  99. var P9_C1_id = ""//you can add here character 1 ID of Player9, just put the ID between the quotes. If Player 9 controls no other characters leave empty quotes.
  100. var P9_C2_id = ""//
  101. var P9_C3_id = ""//
  102. var P9_C4_id = ""//
  103. var P9_C5_id = ""//
  104. var P10 = findObjs({_type: "player", _id: "" })[0]; //Player10, Player ID, leave empty ("") if there are no more players
  105. var P10_C1_id = ""//you can add here character 1 ID of Player10, just put the ID between the quotes. If Player 10 controls no other characters leave empty quotes.
  106. var P10_C2_id = ""//
  107. var P10_C3_id = ""//
  108. var P10_C4_id = ""//
  109. var P10_C5_id = ""//
  110. var P11 = findObjs({_type: "player", _id: "" })[0]; //Player11, Player ID, leave empty ("") if there are no more players
  111. var P11_C1_id = ""//you can add here character 1 ID of Player11, just put the ID between the quotes. If Player 11 controls no other characters leave empty quotes.
  112. var P11_C2_id = ""//
  113. var P11_C3_id = ""//
  114. var P11_C4_id = ""//
  115. var P11_C5_id = ""//
  116.  
  117. setInterval(function() {
  118.  
  119. var Basic_Format_While_Loop;
  120. /*
  121. var P = ["0",P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11];
  122. var i=1;
  123. while(i <= 11) {
  124. sendChat("", "P[" + i + "]_name = " + P[i].get("_displayname"));
  125. i++;
  126. }
  127. sendChat("", "123");
  128. */
  129.  
  130. var Print_List_1;
  131. /*
  132. var P = ["0",P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11];
  133. var i=1;
  134. while(i <= 11) {
  135. j=2;
  136. while (j>=2&&j<=5){
  137. //var P1_C4_id = ""//character ID of NULL
  138. sendChat("", "var P" + i + "_C" + j +"_id = \"\"//character ID of NULL");
  139. j++;
  140. }
  141. i++;
  142. }
  143. */
  144.  
  145. var Print_List_2;
  146. /*var P = ["0",P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11];
  147. var i=1;
  148. while(i <= 11) {
  149. j=1;
  150. while (j>=1&&j<=5){
  151. //var P1_C4_id = ""//character ID of NULL
  152. sendChat("", "P"+ i + "_C" + j + "_id,");
  153. j++;
  154. }
  155. i++;
  156. }
  157. */
  158.  
  159. var correct_sequencer;
  160. /*var P = ["0",P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11];
  161. var i=1;
  162. while(i <= 11) {
  163. sendChat("", "Active Player (for i=" + i + ") is " + P[i].get("_displayname"));
  164. P_C = ["0",P1_C1_id,P1_C2_id,P1_C3_id,P1_C4_id,P1_C5_id,P2_C1_id,P2_C2_id,P2_C3_id,P2_C4_id,P2_C5_id,P3_C1_id,P3_C2_id,P3_C3_id,P3_C4_id,P3_C5_id,P4_C1_id,P4_C2_id,P4_C3_id,P4_C4_id,P4_C5_id,P5_C1_id,P5_C2_id,P5_C3_id,P5_C4_id,P5_C5_id,P6_C1_id,P6_C2_id,P6_C3_id,P6_C4_id,P6_C5_id,P7_C1_id,P7_C2_id,P7_C3_id,P7_C4_id,P7_C5_id,P8_C1_id,P8_C2_id,P8_C3_id,P8_C4_id,P8_C5_id,P9_C1_id,P9_C2_id,P9_C3_id,P9_C4_id,P9_C5_id,P10_C1_id,P10_C2_id,P10_C3_id,P10_C4_id,P10_C5_id,P11_C1_id,P11_C2_id,P11_C3_id,P11_C4_id,P11_C5_id,];
  165. j=1;
  166. while (j>=1&&j<=5){
  167. //var P1_C4_id = ""//character ID of NULL
  168. if(P_C[-5+5*i+j] !="") {sendChat("", "Active Character (for i=" + i + " and j=" + j +") is " + P_C[i])};
  169. j++;
  170. }
  171. i++;
  172. }
  173. sendChat("", "123");
  174. */
  175.  
  176. var PageNameGM = findObjs({_type: "page", _id: P1.get("lastpage")})[0];
  177. //sendChat("", "Current Page for " + P1.get("_displayname") + "(GM) is called " + PageNameGM.get("name") );
  178.  
  179. var CountWet = (PageNameGM.get("name").match(/WET/g) || []).length;
  180. var CountDry = (PageNameGM.get("name").match(/DRY/g) || []).length;
  181. var CountHot = (PageNameGM.get("name").match(/HOT/g) || []).length;
  182. var CountCold = (PageNameGM.get("name").match(/COLD/g) || []).length;
  183. var CountMild = (PageNameGM.get("name").match(/MILD/g) || []).length;
  184. var EffectCount = {wet: CountWet, dry: CountDry, hot: CountHot, cold: CountCold, mild: CountMild};
  185.  
  186. var P = ["0",P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11];
  187. var i=1;
  188. while(i <= 11) {
  189. //sendChat("", "Active Player (for i=" + i + ") is " + P[i].get("_displayname"));
  190. P_C = ["0",P1_C1_id,P1_C2_id,P1_C3_id,P1_C4_id,P1_C5_id,P2_C1_id,P2_C2_id,P2_C3_id,P2_C4_id,P2_C5_id,P3_C1_id,P3_C2_id,P3_C3_id,P3_C4_id,P3_C5_id,P4_C1_id,P4_C2_id,P4_C3_id,P4_C4_id,P4_C5_id,P5_C1_id,P5_C2_id,P5_C3_id,P5_C4_id,P5_C5_id,P6_C1_id,P6_C2_id,P6_C3_id,P6_C4_id,P6_C5_id,P7_C1_id,P7_C2_id,P7_C3_id,P7_C4_id,P7_C5_id,P8_C1_id,P8_C2_id,P8_C3_id,P8_C4_id,P8_C5_id,P9_C1_id,P9_C2_id,P9_C3_id,P9_C4_id,P9_C5_id,P10_C1_id,P10_C2_id,P10_C3_id,P10_C4_id,P10_C5_id,P11_C1_id,P11_C2_id,P11_C3_id,P11_C4_id,P11_C5_id,];
  191. j=1;
  192.  
  193. while (j>=1&&j<=5&&P[i]!=undefined){
  194. //var P1_C4_id = ""//character ID of NULL
  195. if(P_C[-5+5*i+j] !=""){
  196. if(P[i].get("online")){
  197. //raises hunger by 10/day, so by 10 every 4 hours of gameplay, 0.4167 each 10 minutes = 600*1000ms
  198. //sendChat("", P[i].get("_displayname") + " is online.");
  199. var P_C_j = findObjs({_type: "character", _id: P_C[j] })[0]; //get character object
  200.  
  201. if ((findObjs({_type: "attribute", name: "hunger", _characterid: P_C[j] })[0])==undefined) {
  202. createObj("attribute", {
  203. name: "hunger",
  204. current: 0,
  205. max: 60,
  206. characterid: P_C[j]
  207. });
  208. };
  209.  
  210. var HungerP_i = findObjs({_type: "attribute", name: "hunger", _characterid: P_C[j] })[0]; //character of Player ID
  211. HungerP_i.set({
  212. current: (HungerP_i.get("current")*1+0.4167)
  213. });
  214. if(HungerP_i.get("current")<0){
  215. HungerP_i.set({
  216. current: 0
  217. });
  218. };
  219. if(HungerP_i.get("current")>30){
  220. sendChat("", "/w gm ***** " + P_C_j.get("name") + " is starving. All his rolls are done with disadvantage!")
  221. };
  222. if(HungerP_i.get("current")>=60){
  223. sendChat("", "/w gm ***** " + P_C_j.get("name") + " faints from starvation");
  224. /*var HealthP_i = findObjs({_type: "attribute", name: "HP", _characterid: P_C[j] })[0];
  225. if(HealthP_i.get("current")!=0){
  226. HealthP_i.set({
  227. current: 0
  228. });
  229. };*/
  230. if(HungerP_i.get("current")>60) {HungerP_i.set({current: 60})};
  231. };
  232.  
  233. if ((findObjs({_type: "attribute", name: "exhaustion", _characterid: P_C[j] })[0])==undefined) {
  234. createObj("attribute", {
  235. name: "exhaustion",
  236. current: 0,
  237. max: 60,
  238. characterid: P_C[j]
  239. });
  240. };
  241.  
  242.  
  243. var ExhaustionP_i = findObjs({_type: "attribute", name: "exhaustion", _characterid: P_C[j] })[0]; //character of Player ID
  244. ExhaustionP_i.set({
  245. current: (ExhaustionP_i.get("current")*1+3*0.4167)
  246. });
  247. if(ExhaustionP_i.get("current")<0){
  248. ExhaustionP_i.set({
  249. current: 0
  250. });
  251. };
  252. if(ExhaustionP_i.get("current")>30){
  253. sendChat("", "/w gm ***** " + P_C_j.get("name") + " is exhausted. All his rolls are done with disadvantage!")
  254. };
  255. if(ExhaustionP_i.get("current")>=60){
  256. sendChat("", "/w gm ***** " + P_C_j.get("name") + " faints by colapsing from exhaustion");
  257. /*var HealthP_i = findObjs({_type: "attribute", name: "HP", _characterid: P_C[j] })[0];
  258. if(HealthP_i.get("current")!=0){
  259. HealthP_i.set({
  260. current: 0
  261. });
  262. };*/
  263. if(ExhaustionP_i.get("current")>60) {ExhaustionP_i.set({current: 60})};
  264.  
  265. };
  266.  
  267. if ((findObjs({_type: "attribute", name: "temperature", _characterid: P_C[j] })[0])==undefined) {
  268. createObj("attribute", {
  269. name: "temperature",
  270. current: 0,
  271. max: 60,
  272. characterid: P_C[j]
  273. });
  274. };
  275.  
  276.  
  277. //EffectCount = {wet: CountWet, dry: CountDry, hot: CountHot, cold: CountCold, mild: CountMild};
  278. if ((findObjs({_type: "attribute", name: "current_WET", _characterid: P_C[j] })[0])==undefined) {
  279. createObj("attribute", {
  280. name: "current_WET",
  281. current: EffectCount.wet,
  282. max: 5,
  283. characterid: P_C[j]
  284. });
  285. };
  286. if ((findObjs({_type: "attribute", name: "current_WET", _characterid: P_C[j] })[0])!=undefined) {
  287. var current_WET = findObjs({_type: "attribute", name: "current_WET", _characterid: P_C[j] })[0];
  288. current_WET.set({
  289. current: EffectCount.wet
  290. });
  291. };
  292.  
  293. if ((findObjs({_type: "attribute", name: "current_DRY", _characterid: P_C[j] })[0])==undefined) {
  294. createObj("attribute", {
  295. name: "current_DRY",
  296. current: EffectCount.dry,
  297. max: 5,
  298. characterid: P_C[j]
  299. });
  300. };
  301. if ((findObjs({_type: "attribute", name: "current_DRY", _characterid: P_C[j] })[0])!=undefined) {
  302. var current_DRY = findObjs({_type: "attribute", name: "current_DRY", _characterid: P_C[j] })[0];
  303. current_DRY.set({
  304. current: EffectCount.dry
  305. });
  306. };
  307.  
  308. if ((findObjs({_type: "attribute", name: "current_HOT", _characterid: P_C[j] })[0])==undefined) {
  309. createObj("attribute", {
  310. name: "current_HOT",
  311. current: EffectCount.hot,
  312. max: 5,
  313. characterid: P_C[j]
  314. });
  315. };
  316. if ((findObjs({_type: "attribute", name: "current_HOT", _characterid: P_C[j] })[0])!=undefined) {
  317. var current_HOT = findObjs({_type: "attribute", name: "current_HOT", _characterid: P_C[j] })[0];
  318. current_HOT.set({
  319. current: EffectCount.hot
  320. });
  321. };
  322.  
  323. if ((findObjs({_type: "attribute", name: "current_COLD", _characterid: P_C[j] })[0])==undefined) {
  324. createObj("attribute", {
  325. name: "current_COLD",
  326. current: EffectCount.cold,
  327. max: 5,
  328. characterid: P_C[j]
  329. });
  330. };
  331. if ((findObjs({_type: "attribute", name: "current_COLD", _characterid: P_C[j] })[0])!=undefined) {
  332. var current_COLD = findObjs({_type: "attribute", name: "current_COLD", _characterid: P_C[j] })[0];
  333. current_COLD.set({
  334. current: EffectCount.cold
  335. });
  336. };
  337.  
  338. if ((findObjs({_type: "attribute", name: "current_MILD", _characterid: P_C[j] })[0])==undefined) {
  339. createObj("attribute", {
  340. name: "current_MILD",
  341. current: EffectCount.mild,
  342. max: 5,
  343. characterid: P_C[j]
  344. });
  345. };
  346. if ((findObjs({_type: "attribute", name: "current_MILD", _characterid: P_C[j] })[0])!=undefined) {
  347. var current_MILD = findObjs({_type: "attribute", name: "current_MILD", _characterid: P_C[j] })[0];
  348. current_MILD.set({
  349. current: EffectCount.mild
  350. });
  351. };
  352.  
  353.  
  354.  
  355. var TemperatureP_i = findObjs({_type: "attribute", name: "temperature", _characterid: P_C[j] })[0]; //character of Player ID
  356. if(EffectCount.cold>0){
  357. if(EffectCount.cold==1&&TemperatureP_i.get("current")>-15){
  358. TemperatureP_i.set({
  359. current: (TemperatureP_i.get("current")*1-0.4167)
  360. });
  361. };
  362. if(EffectCount.cold>1){
  363. TemperatureP_i.set({
  364. current: (TemperatureP_i.get("current")*1-0.4167*EffectCount.cold)
  365. });
  366. };
  367. };
  368.  
  369. if(TemperatureP_i.get("current")<-30){
  370. sendChat("", "/w gm ***** " + P_C_j.get("name") + " is dangerously cold. Frostbite is damaging him.")
  371. var HealthP_i = findObjs({_type: "attribute", name: "HP", _characterid: P_C[j] })[0];
  372. if(HealthP_i.get("current")>0){
  373. HealthP_i.set({
  374. current: Math.floor(HealthP_i.get("current")*1-HealthP_i.get("max")*1*0.15)
  375. });
  376. };
  377. var ColdFlu = Math.random();
  378. if (ColdFlu > 0.6){
  379. sendChat("", "/w gm ***** " + P_C_j.get("name") + " got sick - AP and MP reduced by 2")
  380. };
  381.  
  382. };
  383. if(EffectCount.hot>0){
  384. if(EffectCount.hot==1&&TemperatureP_i.get("current")<15){
  385. TemperatureP_i.set({
  386. current: (TemperatureP_i.get("current")*1+0.4167)
  387. });
  388. };
  389. if(EffectCount.hot>1){
  390. TemperatureP_i.set({
  391. current: (TemperatureP_i.get("current")*1+0.4167*EffectCount.hot)
  392. });
  393. };
  394. };
  395. if(TemperatureP_i.get("current")>30){
  396. sendChat("", "/w gm ***** " + P_C_j.get("name") + " is dangerously hot. Heatstroke is damaging him.")
  397. var HealthP_i = findObjs({_type: "attribute", name: "HP", _characterid: P_C[j] })[0];
  398. if(HealthP_i.get("current")>0){
  399. HealthP_i.set({
  400. current: Math.floor(HealthP_i.get("current")*1-HealthP_i.get("max")*1*0.2)
  401. });
  402. };
  403. var HotRot = Math.random();
  404. if (HotRot > 0.7 && HotRot < 0.9){
  405. sendChat("", "/w gm ***** " + P_C_j.get("name") + "'s food is rotting away - one of his inventory slots with food is spoiled")
  406. };
  407. if (HotRot > 0.9){
  408. sendChat("", "/w gm ***** " + P_C_j.get("name") + " almost blacks out with the heat! his AP and MP are reduced to 1")
  409. };
  410. };
  411. if(EffectCount.mild>0){
  412. TemperatureP_i.set({
  413. current: (TemperatureP_i.get("current")*1*0.95)
  414. });
  415. };
  416. if(Math.abs(TemperatureP_i.get("current"))>=60){
  417. sendChat("", "/w gm ***** " + P_C_j.get("name") + " faints from the adverse temperatures");
  418. /*var HealthP_i = findObjs({_type: "attribute", name: "HP", _characterid: P_C[j] })[0];
  419. if(HealthP_i.get("current")!=0){
  420. HealthP_i.set({
  421. current: 0
  422. });
  423. };
  424. */
  425.  
  426. if(TemperatureP_i.get("current")>60) {TemperatureP_i.set({current: 60})};
  427. if(TemperatureP_i.get("current")<-60) {TemperatureP_i.set({current: -60})};
  428. };
  429.  
  430. if ((findObjs({_type: "attribute", name: "wetness", _characterid: P_C[j] })[0])==undefined) {
  431. createObj("attribute", {
  432. name: "wetness",
  433. current: 0,
  434. max: 60,
  435. characterid: P_C[j]
  436. });
  437. };
  438.  
  439.  
  440. var WetnessP_i = findObjs({_type: "attribute", name: "wetness", _characterid: P_C[j] })[0]; //character of Player ID
  441. if(EffectCount.wet>0){
  442. if(EffectCount.wet==1){
  443. WetnessP_i.set({
  444. current: (WetnessP_i.get("current")*1+0.2167)
  445. });
  446. };
  447. if(EffectCount.wet>1){
  448. WetnessP_i.set({
  449. current: (WetnessP_i.get("current")*1+1.5*0.4167*EffectCount.wet)
  450. });
  451. };
  452. };
  453. if(EffectCount.dry>0){
  454. if(EffectCount.dry==1&&WetnessP_i.get("current")>0){
  455. WetnessP_i.set({
  456. current: (WetnessP_i.get("current")*1-0.4167)
  457. });
  458. };
  459. if(EffectCount.wet>1&&WetnessP_i.get("current")>0){
  460. WetnessP_i.set({
  461. current: (WetnessP_i.get("current")*1-0.7*0.4167*EffectCount.wet)
  462. });
  463. };
  464. if(WetnessP_i.get("current")<0){
  465. WetnessP_i.set({
  466. current: 0
  467. });
  468. };
  469. };
  470. if(WetnessP_i.get("current")>30){
  471. sendChat("", "/w gm ***** " + P_C_j.get("name") + " is drenched. He feels very unconfortable.")
  472. var HotRot = Math.random();
  473.  
  474. if (HotRot > 0.4 && HotRot < 0.7){
  475. sendChat("", "/w gm ***** " + P_C_j.get("name") + " gets a cold: MP and AP reduced by 1")
  476. };
  477. if (HotRot > 0.7 && HotRot < 0.8){
  478. sendChat("", "/w gm ***** " + P_C_j.get("name") + "'s food is rotting away - one of his inventory slots with food is spoiled")
  479. };
  480. if (HotRot > 0.8 && HotRot < 0.9){
  481. sendChat("", "/w gm ***** " + P_C_j.get("name") + "'s food is rotting away - two of his inventory slots with food are spoiled")
  482. };
  483. if (HotRot > 0.9){
  484. sendChat("", "/w gm ***** " + P_C_j.get("name") + " gets a horrible fever! AP and MP are set to 0.")
  485. };
  486. };
  487. if(WetnessP_i.get("current")>=60){
  488. sendChat("", "/w gm ***** " + P_C_j.get("name") + " faints from disease");
  489. /*var HealthP_i = findObjs({_type: "attribute", name: "HP", _characterid: P_C[j] })[0];
  490. if(HealthP_i.get("current")!=0){
  491. HealthP_i.set({
  492. current: 0
  493. });
  494. };
  495. */
  496. if(WetnessP_i.get("current")>60) {WetnessP_i.set({current: 60})};
  497. };
  498.  
  499. if ((findObjs({_type: "attribute", name: "survival_status", _characterid: P_C[j] })[0])==undefined) {
  500. createObj("attribute", {
  501. name: "survival_status",
  502. current: 0,
  503. max: 30,
  504. characterid: P_C[j]
  505. });
  506. };
  507.  
  508.  
  509. var SurvivalStatusP_i = findObjs({_type: "attribute", name: "survival_status", _characterid: P_C[j] })[0];
  510. if(SurvivalStatusP_i.get("current")>=0){
  511. SurvivalStatusP_i.set({
  512. current: 30-Math.floor(Math.max(HungerP_i.get("current")*1,ExhaustionP_i.get("current")*1,Math.abs(TemperatureP_i.get("current")),WetnessP_i.get("current")*1))
  513. });
  514. };
  515. if(SurvivalStatusP_i.get("current")<0){
  516. SurvivalStatusP_i.set({
  517. current: 0
  518. });
  519. };
  520.  
  521. };
  522. }
  523. j++;
  524. }
  525. i++;
  526. }
  527. }, 10*60*1000); //take an action every 10 minutes - 10*60*1000 / 10s for testing 1*10*1000
  528. });
  529.  
  530.  
  531. on("chat:message", function(msg) {
  532. if(msg.type == "api" && msg.content.indexOf("!TimeJump ") !== -1) {
  533. var cleanedMsg = msg.content.replace("!TimeJump ", "");
  534. var TimeJumped = cleanedMsg;
  535. sendChat("", "/w gm ***** " + TimeJumped + "hours passed")
  536.  
  537. //To find ID of a character, create a character, get a token associated with it, select token and input into chat: @{selected|character_id}
  538. //GM can put some characters in his name here, for testing purposes. Leave quotes!
  539. var P1_C1_id = ""//character 1 ID of GM
  540. var P1_C2_id = ""//you can add here character 2 ID of GM, just put the ID between the quotes. If GM controls no other characters leave empty quotes.
  541. var P1_C3_id = ""//you can add here character 3 ID of GM, just put the ID between the quotes. If GM controls no other characters leave empty quotes.
  542. var P1_C4_id = ""//you can add here character 4 ID of GM, just put the ID between the quotes. If GM controls no other characters leave empty quotes.
  543. var P1_C5_id = ""//you can add here character 5 ID of GM, just put the ID between the quotes. If GM controls no other characters leave empty quotes.
  544.  
  545. //Players
  546. var P2 = findObjs({_type: "player", _id: "" })[0]; //Player2, Player ID. Not to be confused with character IDs.
  547. //Insert Player Character IDs that should suffer from survival factors in here. Leave Quotes!
  548. //To find ID of a character, create a character, get a token associated with it, select token and input into chat: @{selected|character_id} var P2_C1_id = "-KteLQkakNut7vI8zoJR"//character ID of Avarin
  549.  
  550. var P2_C1_id = ""//character 1 ID of Player 2
  551. var P2_C2_id = ""//you can add here character 2 ID of Player2, just put the ID between the quotes. If Player 2 controls no other characters leave empty quotes.
  552. var P2_C3_id = ""//you can add here character 3 ID of Player2, just put the ID between the quotes. If Player 2 controls no other characters leave empty quotes.
  553. var P2_C4_id = ""//you can add here character 4 ID of Player2, just put the ID between the quotes. If Player 2 controls no other characters leave empty quotes.
  554. var P2_C5_id = ""//you can add here character 5 ID of Player2, just put the ID between the quotes. If Player 2 controls no other characters leave empty quotes.
  555. var P3 = findObjs({_type: "player", _id: "" })[0]; //Player3, Player ID, leave empty ("") if there are no more players
  556. var P3_C1_id = ""//you can add here character 1 ID of Player3, just put the ID between the quotes. If Player 3 controls no other characters leave empty quotes.
  557. var P3_C2_id = ""//
  558. var P3_C3_id = ""//
  559. var P3_C4_id = ""//
  560. var P3_C5_id = ""//
  561. var P4 = findObjs({_type: "player", _id: "" })[0]; //Player4, Player ID, leave empty ("") if there are no more players
  562. var P4_C1_id = ""//you can add here character 1 ID of Player4, just put the ID between the quotes. If Player 4 controls no other characters leave empty quotes.
  563. var P4_C2_id = ""//
  564. var P4_C3_id = ""//
  565. var P4_C4_id = ""//
  566. var P4_C5_id = ""//
  567. var P5 = findObjs({_type: "player", _id: "" })[0]; //Player5, Player ID, leave empty ("") if there are no more players
  568. var P5_C1_id = ""//you can add here character 1 ID of Player5, just put the ID between the quotes. If Player 5 controls no other characters leave empty quotes.
  569. var P5_C2_id = ""//
  570. var P5_C3_id = ""//
  571. var P5_C4_id = ""//
  572. var P5_C5_id = ""//
  573. var P6 = findObjs({_type: "player", _id: "" })[0]; //Player6, Player ID, leave empty ("") if there are no more players
  574. var P6_C1_id = ""//you can add here character 1 ID of Player6, just put the ID between the quotes. If Player 6 controls no other characters leave empty quotes.
  575. var P6_C2_id = ""//
  576. var P6_C3_id = ""//
  577. var P6_C4_id = ""//
  578. var P6_C5_id = ""//
  579. var P7 = findObjs({_type: "player", _id: "" })[0]; //Player7, Player ID, leave empty ("") if there are no more players
  580. var P7_C1_id = ""//you can add here character 1 ID of Player7, just put the ID between the quotes. If Player 7 controls no other characters leave empty quotes.
  581. var P7_C2_id = ""//
  582. var P7_C3_id = ""//
  583. var P7_C4_id = ""//
  584. var P7_C5_id = ""//
  585. var P8 = findObjs({_type: "player", _id: "" })[0]; //Player8, Player ID, leave empty ("") if there are no more players
  586. var P8_C1_id = ""//you can add here character 1 ID of Player8, just put the ID between the quotes. If Player 8 controls no other characters leave empty quotes.
  587. var P8_C2_id = ""//
  588. var P8_C3_id = ""//
  589. var P8_C4_id = ""//
  590. var P8_C5_id = ""//
  591. var P9 = findObjs({_type: "player", _id: "" })[0]; //Player9, Player ID, leave empty ("") if there are no more players
  592. var P9_C1_id = ""//you can add here character 1 ID of Player9, just put the ID between the quotes. If Player 9 controls no other characters leave empty quotes.
  593. var P9_C2_id = ""//
  594. var P9_C3_id = ""//
  595. var P9_C4_id = ""//
  596. var P9_C5_id = ""//
  597. var P10 = findObjs({_type: "player", _id: "" })[0]; //Player10, Player ID, leave empty ("") if there are no more players
  598. var P10_C1_id = ""//you can add here character 1 ID of Player10, just put the ID between the quotes. If Player 10 controls no other characters leave empty quotes.
  599. var P10_C2_id = ""//
  600. var P10_C3_id = ""//
  601. var P10_C4_id = ""//
  602. var P10_C5_id = ""//
  603. var P11 = findObjs({_type: "player", _id: "" })[0]; //Player11, Player ID, leave empty ("") if there are no more players
  604. var P11_C1_id = ""//you can add here character 1 ID of Player11, just put the ID between the quotes. If Player 11 controls no other characters leave empty quotes.
  605. var P11_C2_id = ""//
  606. var P11_C3_id = ""//
  607. var P11_C4_id = ""//
  608. var P11_C5_id = ""//
  609.  
  610. var PageNameGM = findObjs({_type: "page", _id: P1.get("lastpage")})[0];
  611. //sendChat("", "Current Page for " + P1.get("_displayname") + "(GM) is called " + PageNameGM.get("name") );
  612.  
  613. var CountWet = (PageNameGM.get("name").match(/WET/g) || []).length;
  614. var CountDry = (PageNameGM.get("name").match(/DRY/g) || []).length;
  615. var CountHot = (PageNameGM.get("name").match(/HOT/g) || []).length;
  616. var CountCold = (PageNameGM.get("name").match(/COLD/g) || []).length;
  617. var CountMild = (PageNameGM.get("name").match(/MILD/g) || []).length;
  618. var EffectCount = {wet: CountWet, dry: CountDry, hot: CountHot, cold: CountCold, mild: CountMild};
  619.  
  620. var P = ["0",P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11];
  621.  
  622. var i=1;
  623. while(i <= 11) {
  624. //sendChat("", "Active Player (for i=" + i + ") is " + P[i].get("_displayname"));
  625. P_C = ["0",P1_C1_id,P1_C2_id,P1_C3_id,P1_C4_id,P1_C5_id,P2_C1_id,P2_C2_id,P2_C3_id,P2_C4_id,P2_C5_id,P3_C1_id,P3_C2_id,P3_C3_id,P3_C4_id,P3_C5_id,P4_C1_id,P4_C2_id,P4_C3_id,P4_C4_id,P4_C5_id,P5_C1_id,P5_C2_id,P5_C3_id,P5_C4_id,P5_C5_id,P6_C1_id,P6_C2_id,P6_C3_id,P6_C4_id,P6_C5_id,P7_C1_id,P7_C2_id,P7_C3_id,P7_C4_id,P7_C5_id,P8_C1_id,P8_C2_id,P8_C3_id,P8_C4_id,P8_C5_id,P9_C1_id,P9_C2_id,P9_C3_id,P9_C4_id,P9_C5_id,P10_C1_id,P10_C2_id,P10_C3_id,P10_C4_id,P10_C5_id,P11_C1_id,P11_C2_id,P11_C3_id,P11_C4_id,P11_C5_id,];
  626. j=1;
  627.  
  628. while (j>=1&&j<=5&&P[i]!=undefined){
  629. //var P1_C4_id = ""//character ID of NULL
  630. if(P_C[-5+5*i+j] !=""){
  631. if(P[i].get("online")){
  632. //raises hunger by 10/day, so by 10 every 4 hours of gameplay, 0.4167 each 10 minutes = 600*1000ms
  633. //sendChat("", P[i].get("_displayname") + " is online.");
  634. var P_C_j = findObjs({_type: "character", _id: P_C[j] })[0]; //get character object
  635.  
  636.  
  637. if ((findObjs({_type: "attribute", name: "hunger", _characterid: P_C[j] })[0])==undefined) {
  638. createObj("attribute", {
  639. name: "hunger",
  640. current: 0,
  641. max: 60,
  642. characterid: P_C[j]
  643. });
  644. };
  645.  
  646. var HungerP_i = findObjs({_type: "attribute", name: "hunger", _characterid: P_C[j] })[0]; //character of Player ID
  647. HungerP_i.set({
  648. current: (HungerP_i.get("current")*1+0.4167*TimeJumped)
  649. });
  650.  
  651.  
  652. if ((findObjs({_type: "attribute", name: "exhaustion", _characterid: P_C[j] })[0])==undefined) {
  653. createObj("attribute", {
  654. name: "exhaustion",
  655. current: 0,
  656. max: 60,
  657. characterid: P_C[j]
  658. });
  659. };
  660.  
  661.  
  662. var ExhaustionP_i = findObjs({_type: "attribute", name: "exhaustion", _characterid: P_C[j] })[0]; //character of Player ID
  663. ExhaustionP_i.set({
  664. current: (ExhaustionP_i.get("current")*1+3*0.4167*TimeJumped)
  665. });
  666.  
  667. if ((findObjs({_type: "attribute", name: "temperature", _characterid: P_C[j] })[0])==undefined) {
  668. createObj("attribute", {
  669. name: "temperature",
  670. current: 0,
  671. max: 60,
  672. characterid: P_C[j]
  673. });
  674. };
  675.  
  676. var TemperatureP_i = findObjs({_type: "attribute", name: "temperature", _characterid: P_C[j] })[0]; //character of Player ID
  677. if(EffectCount.cold>0){
  678. if(EffectCount.cold==1&&TemperatureP_i.get("current")>-15){
  679. TemperatureP_i.set({
  680. current: (TemperatureP_i.get("current")*1-0.4167*TimeJumped)
  681. });
  682. if(TemperatureP_i.get("current")<-15){
  683. TemperatureP_i.set({
  684. current: -15
  685. });
  686. }
  687.  
  688. };
  689. if(EffectCount.cold>1){
  690. TemperatureP_i.set({
  691. current: (TemperatureP_i.get("current")*1-0.4167*EffectCount.cold*TimeJumped)
  692. });
  693. };
  694. };
  695.  
  696. if(TemperatureP_i.get("current")<-30){
  697. var HealthP_i = findObjs({_type: "attribute", name: "HP", _characterid: P_C[j] })[0];
  698. if(HealthP_i.get("current")>0){
  699. HealthP_i.set({
  700. current: Math.floor(HealthP_i.get("current")*1-HealthP_i.get("max")*1*0.15*TimeJumped)
  701. });
  702. };
  703.  
  704. };
  705. if(EffectCount.hot>0){
  706. if(EffectCount.hot==1&&TemperatureP_i.get("current")<15){
  707. TemperatureP_i.set({
  708. current: (TemperatureP_i.get("current")*1+0.4167*TimeJumped)
  709. });
  710. if(TemperatureP_i.get("current")>15){
  711. TemperatureP_i.set({
  712. current: 15
  713. });
  714. }
  715.  
  716. };
  717. if(EffectCount.hot>1){
  718. TemperatureP_i.set({
  719. current: (TemperatureP_i.get("current")*1+0.4167*EffectCount.hot*TimeJumped)
  720. });
  721. };
  722. };
  723. if(TemperatureP_i.get("current")>30){
  724. var HealthP_i = findObjs({_type: "attribute", name: "HP", _characterid: P_C[j] })[0];
  725. if(HealthP_i.get("current")>0){
  726. HealthP_i.set({
  727. current: Math.floor(HealthP_i.get("current")*1-HealthP_i.get("max")*1*0.2*TimeJumped)
  728. });
  729. };
  730. };
  731. if(EffectCount.mild>0){
  732. TemperatureP_i.set({
  733. current: (TemperatureP_i.get("current")*1*0.95**TimeJumped)
  734. });
  735. };
  736.  
  737. if ((findObjs({_type: "attribute", name: "wetness", _characterid: P_C[j] })[0])==undefined) {
  738. createObj("attribute", {
  739. name: "wetness",
  740. current: 0,
  741. max: 60,
  742. characterid: P_C[j]
  743. });
  744. };
  745.  
  746.  
  747. var WetnessP_i = findObjs({_type: "attribute", name: "wetness", _characterid: P_C[j] })[0]; //character of Player ID
  748. if(EffectCount.wet>0){
  749. if(EffectCount.wet==1){
  750. WetnessP_i.set({
  751. current: (WetnessP_i.get("current")*1+0.2167*TimeJumped)
  752. });
  753. };
  754. if(EffectCount.wet>1){
  755. WetnessP_i.set({
  756. current: (WetnessP_i.get("current")*1+1.5*0.4167*EffectCount.wet*TimeJumped)
  757. });
  758. };
  759. };
  760. if(EffectCount.dry>0){
  761. if(EffectCount.dry==1&&WetnessP_i.get("current")>0){
  762. WetnessP_i.set({
  763. current: (WetnessP_i.get("current")*1-0.4167*TimeJumped)
  764. });
  765. };
  766. if(EffectCount.wet>1&&WetnessP_i.get("current")>0){
  767. WetnessP_i.set({
  768. current: (WetnessP_i.get("current")*1-0.7*0.4167*EffectCount.wet*TimeJumped)
  769. });
  770. };
  771. if(WetnessP_i.get("current")<0){
  772. WetnessP_i.set({
  773. current: 0
  774. });
  775. };
  776. };
  777.  
  778. if ((findObjs({_type: "attribute", name: "survival_status", _characterid: P_C[j] })[0])==undefined) {
  779. createObj("attribute", {
  780. name: "survival_status",
  781. current: 0,
  782. max: 30,
  783. characterid: P_C[j]
  784. });
  785. };
  786.  
  787.  
  788. };
  789. };
  790. j++;
  791. };
  792. i++;
  793. };
  794. };
  795.  
  796. });
Add Comment
Please, Sign In to add comment