Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- [work_in_progress]
- [work_in_progress]
- [work_in_progress]
- UPDATE IDs up here and for !TimeJump, line 500
- Author: gui8312
- API Name: SurvivalTimer
- Date: 18th of October 2017
- General description:
- * This API allows for survival factors to affect players over time. Only affects online players.
- * Created for RPGs in general, some tweaking will almost certainly be needed to adjust to your campaign.
- * The statuses are: Hunger, Exhaustion, Temperature, Wetness. If these Statuses surpass 30 (absolute value), negative effects kick in. Over 60 and character faints.
- * One last attribute is included to give an idea of all statuses together: survival_status=240-(hunger+exhaustion+math.abs(temperature)+wetness)
- * Statuses are updated every 10 minutes (can be changed at the bottom of the script)
- * Player actions like eating food to lower hunger need to be done manually, this script only affects over time effects.
- * 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.
- * 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.
- Statuses described:
- * Hunger and Exhaustion are lost over time and recovered by eating and resting respectively.
- * 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.
- ex1: Black Forest COLD DRY (This map will reduce the Temperature of the players and it will reduce their wetness)
- ex2: Snowy Peak COLD COLD COLD WET (This Map will strongly reduce the Temperature of players over time and slowly raise their wetness)
- 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)
- Note1: Maps with no keywords will only affect hunger and exhaustion, the rest will stay as it is.
- Note2: Maps with only one time COLD/HOT will only get the temperature to a certain level, not being enough to harm the players.
- Pacing:
- * Hunger is raised by 10 every 4 hours of gameplay. Exhaustion is raised by 30 in the same time.
- * Temperature is changed based on the map name. Same for Wetness. Best to test the pace before the Session.
- Default effects:
- * Starving, Hunger > 30, All rolls with disadvantage
- * Exhausted, Exhaustion > 30, All rolls with disadvantage
- * 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)
- * 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)
- * 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))
- * Any of the stats above > 60 (absolute value), fainting sets in, putting HP at 0.
- */
- on("ready", function() {
- //To find ID of a character, create a character, get a token associated with it, select token and input into chat: @{selected|character_id}
- //GM can put some characters in his name here, for testing purposes. Leave quotes!
- var P1_C1_id = ""//character 1 ID of GM
- 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.
- 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.
- 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.
- 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.
- //Players
- var P2 = findObjs({_type: "player", _id: "" })[0]; //Player2, Player ID. Not to be confused with character IDs.
- //Insert Player Character IDs that should suffer from survival factors in here. Leave Quotes!
- //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
- var P2_C1_id = ""//character 1 ID of Player 2
- 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.
- 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.
- 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.
- 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.
- var P3 = findObjs({_type: "player", _id: "" })[0]; //Player3, Player ID, leave empty ("") if there are no more players
- 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.
- var P3_C2_id = ""//
- var P3_C3_id = ""//
- var P3_C4_id = ""//
- var P3_C5_id = ""//
- var P4 = findObjs({_type: "player", _id: "" })[0]; //Player4, Player ID, leave empty ("") if there are no more players
- 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.
- var P4_C2_id = ""//
- var P4_C3_id = ""//
- var P4_C4_id = ""//
- var P4_C5_id = ""//
- var P5 = findObjs({_type: "player", _id: "" })[0]; //Player5, Player ID, leave empty ("") if there are no more players
- 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.
- var P5_C2_id = ""//
- var P5_C3_id = ""//
- var P5_C4_id = ""//
- var P5_C5_id = ""//
- var P6 = findObjs({_type: "player", _id: "" })[0]; //Player6, Player ID, leave empty ("") if there are no more players
- 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.
- var P6_C2_id = ""//
- var P6_C3_id = ""//
- var P6_C4_id = ""//
- var P6_C5_id = ""//
- var P7 = findObjs({_type: "player", _id: "" })[0]; //Player7, Player ID, leave empty ("") if there are no more players
- 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.
- var P7_C2_id = ""//
- var P7_C3_id = ""//
- var P7_C4_id = ""//
- var P7_C5_id = ""//
- var P8 = findObjs({_type: "player", _id: "" })[0]; //Player8, Player ID, leave empty ("") if there are no more players
- 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.
- var P8_C2_id = ""//
- var P8_C3_id = ""//
- var P8_C4_id = ""//
- var P8_C5_id = ""//
- var P9 = findObjs({_type: "player", _id: "" })[0]; //Player9, Player ID, leave empty ("") if there are no more players
- 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.
- var P9_C2_id = ""//
- var P9_C3_id = ""//
- var P9_C4_id = ""//
- var P9_C5_id = ""//
- var P10 = findObjs({_type: "player", _id: "" })[0]; //Player10, Player ID, leave empty ("") if there are no more players
- 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.
- var P10_C2_id = ""//
- var P10_C3_id = ""//
- var P10_C4_id = ""//
- var P10_C5_id = ""//
- var P11 = findObjs({_type: "player", _id: "" })[0]; //Player11, Player ID, leave empty ("") if there are no more players
- 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.
- var P11_C2_id = ""//
- var P11_C3_id = ""//
- var P11_C4_id = ""//
- var P11_C5_id = ""//
- setInterval(function() {
- var Basic_Format_While_Loop;
- /*
- var P = ["0",P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11];
- var i=1;
- while(i <= 11) {
- sendChat("", "P[" + i + "]_name = " + P[i].get("_displayname"));
- i++;
- }
- sendChat("", "123");
- */
- var Print_List_1;
- /*
- var P = ["0",P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11];
- var i=1;
- while(i <= 11) {
- j=2;
- while (j>=2&&j<=5){
- //var P1_C4_id = ""//character ID of NULL
- sendChat("", "var P" + i + "_C" + j +"_id = \"\"//character ID of NULL");
- j++;
- }
- i++;
- }
- */
- var Print_List_2;
- /*var P = ["0",P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11];
- var i=1;
- while(i <= 11) {
- j=1;
- while (j>=1&&j<=5){
- //var P1_C4_id = ""//character ID of NULL
- sendChat("", "P"+ i + "_C" + j + "_id,");
- j++;
- }
- i++;
- }
- */
- var correct_sequencer;
- /*var P = ["0",P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11];
- var i=1;
- while(i <= 11) {
- sendChat("", "Active Player (for i=" + i + ") is " + P[i].get("_displayname"));
- 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,];
- j=1;
- while (j>=1&&j<=5){
- //var P1_C4_id = ""//character ID of NULL
- if(P_C[-5+5*i+j] !="") {sendChat("", "Active Character (for i=" + i + " and j=" + j +") is " + P_C[i])};
- j++;
- }
- i++;
- }
- sendChat("", "123");
- */
- var PageNameGM = findObjs({_type: "page", _id: P1.get("lastpage")})[0];
- //sendChat("", "Current Page for " + P1.get("_displayname") + "(GM) is called " + PageNameGM.get("name") );
- var CountWet = (PageNameGM.get("name").match(/WET/g) || []).length;
- var CountDry = (PageNameGM.get("name").match(/DRY/g) || []).length;
- var CountHot = (PageNameGM.get("name").match(/HOT/g) || []).length;
- var CountCold = (PageNameGM.get("name").match(/COLD/g) || []).length;
- var CountMild = (PageNameGM.get("name").match(/MILD/g) || []).length;
- var EffectCount = {wet: CountWet, dry: CountDry, hot: CountHot, cold: CountCold, mild: CountMild};
- var P = ["0",P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11];
- var i=1;
- while(i <= 11) {
- //sendChat("", "Active Player (for i=" + i + ") is " + P[i].get("_displayname"));
- 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,];
- j=1;
- while (j>=1&&j<=5&&P[i]!=undefined){
- //var P1_C4_id = ""//character ID of NULL
- if(P_C[-5+5*i+j] !=""){
- if(P[i].get("online")){
- //raises hunger by 10/day, so by 10 every 4 hours of gameplay, 0.4167 each 10 minutes = 600*1000ms
- //sendChat("", P[i].get("_displayname") + " is online.");
- var P_C_j = findObjs({_type: "character", _id: P_C[j] })[0]; //get character object
- if ((findObjs({_type: "attribute", name: "hunger", _characterid: P_C[j] })[0])==undefined) {
- createObj("attribute", {
- name: "hunger",
- current: 0,
- max: 60,
- characterid: P_C[j]
- });
- };
- var HungerP_i = findObjs({_type: "attribute", name: "hunger", _characterid: P_C[j] })[0]; //character of Player ID
- HungerP_i.set({
- current: (HungerP_i.get("current")*1+0.4167)
- });
- if(HungerP_i.get("current")<0){
- HungerP_i.set({
- current: 0
- });
- };
- if(HungerP_i.get("current")>30){
- sendChat("", "/w gm ***** " + P_C_j.get("name") + " is starving. All his rolls are done with disadvantage!")
- };
- if(HungerP_i.get("current")>=60){
- sendChat("", "/w gm ***** " + P_C_j.get("name") + " faints from starvation");
- /*var HealthP_i = findObjs({_type: "attribute", name: "HP", _characterid: P_C[j] })[0];
- if(HealthP_i.get("current")!=0){
- HealthP_i.set({
- current: 0
- });
- };*/
- if(HungerP_i.get("current")>60) {HungerP_i.set({current: 60})};
- };
- if ((findObjs({_type: "attribute", name: "exhaustion", _characterid: P_C[j] })[0])==undefined) {
- createObj("attribute", {
- name: "exhaustion",
- current: 0,
- max: 60,
- characterid: P_C[j]
- });
- };
- var ExhaustionP_i = findObjs({_type: "attribute", name: "exhaustion", _characterid: P_C[j] })[0]; //character of Player ID
- ExhaustionP_i.set({
- current: (ExhaustionP_i.get("current")*1+3*0.4167)
- });
- if(ExhaustionP_i.get("current")<0){
- ExhaustionP_i.set({
- current: 0
- });
- };
- if(ExhaustionP_i.get("current")>30){
- sendChat("", "/w gm ***** " + P_C_j.get("name") + " is exhausted. All his rolls are done with disadvantage!")
- };
- if(ExhaustionP_i.get("current")>=60){
- sendChat("", "/w gm ***** " + P_C_j.get("name") + " faints by colapsing from exhaustion");
- /*var HealthP_i = findObjs({_type: "attribute", name: "HP", _characterid: P_C[j] })[0];
- if(HealthP_i.get("current")!=0){
- HealthP_i.set({
- current: 0
- });
- };*/
- if(ExhaustionP_i.get("current")>60) {ExhaustionP_i.set({current: 60})};
- };
- if ((findObjs({_type: "attribute", name: "temperature", _characterid: P_C[j] })[0])==undefined) {
- createObj("attribute", {
- name: "temperature",
- current: 0,
- max: 60,
- characterid: P_C[j]
- });
- };
- //EffectCount = {wet: CountWet, dry: CountDry, hot: CountHot, cold: CountCold, mild: CountMild};
- if ((findObjs({_type: "attribute", name: "current_WET", _characterid: P_C[j] })[0])==undefined) {
- createObj("attribute", {
- name: "current_WET",
- current: EffectCount.wet,
- max: 5,
- characterid: P_C[j]
- });
- };
- if ((findObjs({_type: "attribute", name: "current_WET", _characterid: P_C[j] })[0])!=undefined) {
- var current_WET = findObjs({_type: "attribute", name: "current_WET", _characterid: P_C[j] })[0];
- current_WET.set({
- current: EffectCount.wet
- });
- };
- if ((findObjs({_type: "attribute", name: "current_DRY", _characterid: P_C[j] })[0])==undefined) {
- createObj("attribute", {
- name: "current_DRY",
- current: EffectCount.dry,
- max: 5,
- characterid: P_C[j]
- });
- };
- if ((findObjs({_type: "attribute", name: "current_DRY", _characterid: P_C[j] })[0])!=undefined) {
- var current_DRY = findObjs({_type: "attribute", name: "current_DRY", _characterid: P_C[j] })[0];
- current_DRY.set({
- current: EffectCount.dry
- });
- };
- if ((findObjs({_type: "attribute", name: "current_HOT", _characterid: P_C[j] })[0])==undefined) {
- createObj("attribute", {
- name: "current_HOT",
- current: EffectCount.hot,
- max: 5,
- characterid: P_C[j]
- });
- };
- if ((findObjs({_type: "attribute", name: "current_HOT", _characterid: P_C[j] })[0])!=undefined) {
- var current_HOT = findObjs({_type: "attribute", name: "current_HOT", _characterid: P_C[j] })[0];
- current_HOT.set({
- current: EffectCount.hot
- });
- };
- if ((findObjs({_type: "attribute", name: "current_COLD", _characterid: P_C[j] })[0])==undefined) {
- createObj("attribute", {
- name: "current_COLD",
- current: EffectCount.cold,
- max: 5,
- characterid: P_C[j]
- });
- };
- if ((findObjs({_type: "attribute", name: "current_COLD", _characterid: P_C[j] })[0])!=undefined) {
- var current_COLD = findObjs({_type: "attribute", name: "current_COLD", _characterid: P_C[j] })[0];
- current_COLD.set({
- current: EffectCount.cold
- });
- };
- if ((findObjs({_type: "attribute", name: "current_MILD", _characterid: P_C[j] })[0])==undefined) {
- createObj("attribute", {
- name: "current_MILD",
- current: EffectCount.mild,
- max: 5,
- characterid: P_C[j]
- });
- };
- if ((findObjs({_type: "attribute", name: "current_MILD", _characterid: P_C[j] })[0])!=undefined) {
- var current_MILD = findObjs({_type: "attribute", name: "current_MILD", _characterid: P_C[j] })[0];
- current_MILD.set({
- current: EffectCount.mild
- });
- };
- var TemperatureP_i = findObjs({_type: "attribute", name: "temperature", _characterid: P_C[j] })[0]; //character of Player ID
- if(EffectCount.cold>0){
- if(EffectCount.cold==1&&TemperatureP_i.get("current")>-15){
- TemperatureP_i.set({
- current: (TemperatureP_i.get("current")*1-0.4167)
- });
- };
- if(EffectCount.cold>1){
- TemperatureP_i.set({
- current: (TemperatureP_i.get("current")*1-0.4167*EffectCount.cold)
- });
- };
- };
- if(TemperatureP_i.get("current")<-30){
- sendChat("", "/w gm ***** " + P_C_j.get("name") + " is dangerously cold. Frostbite is damaging him.")
- var HealthP_i = findObjs({_type: "attribute", name: "HP", _characterid: P_C[j] })[0];
- if(HealthP_i.get("current")>0){
- HealthP_i.set({
- current: Math.floor(HealthP_i.get("current")*1-HealthP_i.get("max")*1*0.15)
- });
- };
- var ColdFlu = Math.random();
- if (ColdFlu > 0.6){
- sendChat("", "/w gm ***** " + P_C_j.get("name") + " got sick - AP and MP reduced by 2")
- };
- };
- if(EffectCount.hot>0){
- if(EffectCount.hot==1&&TemperatureP_i.get("current")<15){
- TemperatureP_i.set({
- current: (TemperatureP_i.get("current")*1+0.4167)
- });
- };
- if(EffectCount.hot>1){
- TemperatureP_i.set({
- current: (TemperatureP_i.get("current")*1+0.4167*EffectCount.hot)
- });
- };
- };
- if(TemperatureP_i.get("current")>30){
- sendChat("", "/w gm ***** " + P_C_j.get("name") + " is dangerously hot. Heatstroke is damaging him.")
- var HealthP_i = findObjs({_type: "attribute", name: "HP", _characterid: P_C[j] })[0];
- if(HealthP_i.get("current")>0){
- HealthP_i.set({
- current: Math.floor(HealthP_i.get("current")*1-HealthP_i.get("max")*1*0.2)
- });
- };
- var HotRot = Math.random();
- if (HotRot > 0.7 && HotRot < 0.9){
- sendChat("", "/w gm ***** " + P_C_j.get("name") + "'s food is rotting away - one of his inventory slots with food is spoiled")
- };
- if (HotRot > 0.9){
- sendChat("", "/w gm ***** " + P_C_j.get("name") + " almost blacks out with the heat! his AP and MP are reduced to 1")
- };
- };
- if(EffectCount.mild>0){
- TemperatureP_i.set({
- current: (TemperatureP_i.get("current")*1*0.95)
- });
- };
- if(Math.abs(TemperatureP_i.get("current"))>=60){
- sendChat("", "/w gm ***** " + P_C_j.get("name") + " faints from the adverse temperatures");
- /*var HealthP_i = findObjs({_type: "attribute", name: "HP", _characterid: P_C[j] })[0];
- if(HealthP_i.get("current")!=0){
- HealthP_i.set({
- current: 0
- });
- };
- */
- if(TemperatureP_i.get("current")>60) {TemperatureP_i.set({current: 60})};
- if(TemperatureP_i.get("current")<-60) {TemperatureP_i.set({current: -60})};
- };
- if ((findObjs({_type: "attribute", name: "wetness", _characterid: P_C[j] })[0])==undefined) {
- createObj("attribute", {
- name: "wetness",
- current: 0,
- max: 60,
- characterid: P_C[j]
- });
- };
- var WetnessP_i = findObjs({_type: "attribute", name: "wetness", _characterid: P_C[j] })[0]; //character of Player ID
- if(EffectCount.wet>0){
- if(EffectCount.wet==1){
- WetnessP_i.set({
- current: (WetnessP_i.get("current")*1+0.2167)
- });
- };
- if(EffectCount.wet>1){
- WetnessP_i.set({
- current: (WetnessP_i.get("current")*1+1.5*0.4167*EffectCount.wet)
- });
- };
- };
- if(EffectCount.dry>0){
- if(EffectCount.dry==1&&WetnessP_i.get("current")>0){
- WetnessP_i.set({
- current: (WetnessP_i.get("current")*1-0.4167)
- });
- };
- if(EffectCount.wet>1&&WetnessP_i.get("current")>0){
- WetnessP_i.set({
- current: (WetnessP_i.get("current")*1-0.7*0.4167*EffectCount.wet)
- });
- };
- if(WetnessP_i.get("current")<0){
- WetnessP_i.set({
- current: 0
- });
- };
- };
- if(WetnessP_i.get("current")>30){
- sendChat("", "/w gm ***** " + P_C_j.get("name") + " is drenched. He feels very unconfortable.")
- var HotRot = Math.random();
- if (HotRot > 0.4 && HotRot < 0.7){
- sendChat("", "/w gm ***** " + P_C_j.get("name") + " gets a cold: MP and AP reduced by 1")
- };
- if (HotRot > 0.7 && HotRot < 0.8){
- sendChat("", "/w gm ***** " + P_C_j.get("name") + "'s food is rotting away - one of his inventory slots with food is spoiled")
- };
- if (HotRot > 0.8 && HotRot < 0.9){
- sendChat("", "/w gm ***** " + P_C_j.get("name") + "'s food is rotting away - two of his inventory slots with food are spoiled")
- };
- if (HotRot > 0.9){
- sendChat("", "/w gm ***** " + P_C_j.get("name") + " gets a horrible fever! AP and MP are set to 0.")
- };
- };
- if(WetnessP_i.get("current")>=60){
- sendChat("", "/w gm ***** " + P_C_j.get("name") + " faints from disease");
- /*var HealthP_i = findObjs({_type: "attribute", name: "HP", _characterid: P_C[j] })[0];
- if(HealthP_i.get("current")!=0){
- HealthP_i.set({
- current: 0
- });
- };
- */
- if(WetnessP_i.get("current")>60) {WetnessP_i.set({current: 60})};
- };
- if ((findObjs({_type: "attribute", name: "survival_status", _characterid: P_C[j] })[0])==undefined) {
- createObj("attribute", {
- name: "survival_status",
- current: 0,
- max: 30,
- characterid: P_C[j]
- });
- };
- var SurvivalStatusP_i = findObjs({_type: "attribute", name: "survival_status", _characterid: P_C[j] })[0];
- if(SurvivalStatusP_i.get("current")>=0){
- SurvivalStatusP_i.set({
- 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))
- });
- };
- if(SurvivalStatusP_i.get("current")<0){
- SurvivalStatusP_i.set({
- current: 0
- });
- };
- };
- }
- j++;
- }
- i++;
- }
- }, 10*60*1000); //take an action every 10 minutes - 10*60*1000 / 10s for testing 1*10*1000
- });
- on("chat:message", function(msg) {
- if(msg.type == "api" && msg.content.indexOf("!TimeJump ") !== -1) {
- var cleanedMsg = msg.content.replace("!TimeJump ", "");
- var TimeJumped = cleanedMsg;
- sendChat("", "/w gm ***** " + TimeJumped + "hours passed")
- //To find ID of a character, create a character, get a token associated with it, select token and input into chat: @{selected|character_id}
- //GM can put some characters in his name here, for testing purposes. Leave quotes!
- var P1_C1_id = ""//character 1 ID of GM
- 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.
- 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.
- 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.
- 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.
- //Players
- var P2 = findObjs({_type: "player", _id: "" })[0]; //Player2, Player ID. Not to be confused with character IDs.
- //Insert Player Character IDs that should suffer from survival factors in here. Leave Quotes!
- //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
- var P2_C1_id = ""//character 1 ID of Player 2
- 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.
- 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.
- 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.
- 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.
- var P3 = findObjs({_type: "player", _id: "" })[0]; //Player3, Player ID, leave empty ("") if there are no more players
- 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.
- var P3_C2_id = ""//
- var P3_C3_id = ""//
- var P3_C4_id = ""//
- var P3_C5_id = ""//
- var P4 = findObjs({_type: "player", _id: "" })[0]; //Player4, Player ID, leave empty ("") if there are no more players
- 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.
- var P4_C2_id = ""//
- var P4_C3_id = ""//
- var P4_C4_id = ""//
- var P4_C5_id = ""//
- var P5 = findObjs({_type: "player", _id: "" })[0]; //Player5, Player ID, leave empty ("") if there are no more players
- 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.
- var P5_C2_id = ""//
- var P5_C3_id = ""//
- var P5_C4_id = ""//
- var P5_C5_id = ""//
- var P6 = findObjs({_type: "player", _id: "" })[0]; //Player6, Player ID, leave empty ("") if there are no more players
- 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.
- var P6_C2_id = ""//
- var P6_C3_id = ""//
- var P6_C4_id = ""//
- var P6_C5_id = ""//
- var P7 = findObjs({_type: "player", _id: "" })[0]; //Player7, Player ID, leave empty ("") if there are no more players
- 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.
- var P7_C2_id = ""//
- var P7_C3_id = ""//
- var P7_C4_id = ""//
- var P7_C5_id = ""//
- var P8 = findObjs({_type: "player", _id: "" })[0]; //Player8, Player ID, leave empty ("") if there are no more players
- 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.
- var P8_C2_id = ""//
- var P8_C3_id = ""//
- var P8_C4_id = ""//
- var P8_C5_id = ""//
- var P9 = findObjs({_type: "player", _id: "" })[0]; //Player9, Player ID, leave empty ("") if there are no more players
- 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.
- var P9_C2_id = ""//
- var P9_C3_id = ""//
- var P9_C4_id = ""//
- var P9_C5_id = ""//
- var P10 = findObjs({_type: "player", _id: "" })[0]; //Player10, Player ID, leave empty ("") if there are no more players
- 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.
- var P10_C2_id = ""//
- var P10_C3_id = ""//
- var P10_C4_id = ""//
- var P10_C5_id = ""//
- var P11 = findObjs({_type: "player", _id: "" })[0]; //Player11, Player ID, leave empty ("") if there are no more players
- 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.
- var P11_C2_id = ""//
- var P11_C3_id = ""//
- var P11_C4_id = ""//
- var P11_C5_id = ""//
- var PageNameGM = findObjs({_type: "page", _id: P1.get("lastpage")})[0];
- //sendChat("", "Current Page for " + P1.get("_displayname") + "(GM) is called " + PageNameGM.get("name") );
- var CountWet = (PageNameGM.get("name").match(/WET/g) || []).length;
- var CountDry = (PageNameGM.get("name").match(/DRY/g) || []).length;
- var CountHot = (PageNameGM.get("name").match(/HOT/g) || []).length;
- var CountCold = (PageNameGM.get("name").match(/COLD/g) || []).length;
- var CountMild = (PageNameGM.get("name").match(/MILD/g) || []).length;
- var EffectCount = {wet: CountWet, dry: CountDry, hot: CountHot, cold: CountCold, mild: CountMild};
- var P = ["0",P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11];
- var i=1;
- while(i <= 11) {
- //sendChat("", "Active Player (for i=" + i + ") is " + P[i].get("_displayname"));
- 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,];
- j=1;
- while (j>=1&&j<=5&&P[i]!=undefined){
- //var P1_C4_id = ""//character ID of NULL
- if(P_C[-5+5*i+j] !=""){
- if(P[i].get("online")){
- //raises hunger by 10/day, so by 10 every 4 hours of gameplay, 0.4167 each 10 minutes = 600*1000ms
- //sendChat("", P[i].get("_displayname") + " is online.");
- var P_C_j = findObjs({_type: "character", _id: P_C[j] })[0]; //get character object
- if ((findObjs({_type: "attribute", name: "hunger", _characterid: P_C[j] })[0])==undefined) {
- createObj("attribute", {
- name: "hunger",
- current: 0,
- max: 60,
- characterid: P_C[j]
- });
- };
- var HungerP_i = findObjs({_type: "attribute", name: "hunger", _characterid: P_C[j] })[0]; //character of Player ID
- HungerP_i.set({
- current: (HungerP_i.get("current")*1+0.4167*TimeJumped)
- });
- if ((findObjs({_type: "attribute", name: "exhaustion", _characterid: P_C[j] })[0])==undefined) {
- createObj("attribute", {
- name: "exhaustion",
- current: 0,
- max: 60,
- characterid: P_C[j]
- });
- };
- var ExhaustionP_i = findObjs({_type: "attribute", name: "exhaustion", _characterid: P_C[j] })[0]; //character of Player ID
- ExhaustionP_i.set({
- current: (ExhaustionP_i.get("current")*1+3*0.4167*TimeJumped)
- });
- if ((findObjs({_type: "attribute", name: "temperature", _characterid: P_C[j] })[0])==undefined) {
- createObj("attribute", {
- name: "temperature",
- current: 0,
- max: 60,
- characterid: P_C[j]
- });
- };
- var TemperatureP_i = findObjs({_type: "attribute", name: "temperature", _characterid: P_C[j] })[0]; //character of Player ID
- if(EffectCount.cold>0){
- if(EffectCount.cold==1&&TemperatureP_i.get("current")>-15){
- TemperatureP_i.set({
- current: (TemperatureP_i.get("current")*1-0.4167*TimeJumped)
- });
- if(TemperatureP_i.get("current")<-15){
- TemperatureP_i.set({
- current: -15
- });
- }
- };
- if(EffectCount.cold>1){
- TemperatureP_i.set({
- current: (TemperatureP_i.get("current")*1-0.4167*EffectCount.cold*TimeJumped)
- });
- };
- };
- if(TemperatureP_i.get("current")<-30){
- var HealthP_i = findObjs({_type: "attribute", name: "HP", _characterid: P_C[j] })[0];
- if(HealthP_i.get("current")>0){
- HealthP_i.set({
- current: Math.floor(HealthP_i.get("current")*1-HealthP_i.get("max")*1*0.15*TimeJumped)
- });
- };
- };
- if(EffectCount.hot>0){
- if(EffectCount.hot==1&&TemperatureP_i.get("current")<15){
- TemperatureP_i.set({
- current: (TemperatureP_i.get("current")*1+0.4167*TimeJumped)
- });
- if(TemperatureP_i.get("current")>15){
- TemperatureP_i.set({
- current: 15
- });
- }
- };
- if(EffectCount.hot>1){
- TemperatureP_i.set({
- current: (TemperatureP_i.get("current")*1+0.4167*EffectCount.hot*TimeJumped)
- });
- };
- };
- if(TemperatureP_i.get("current")>30){
- var HealthP_i = findObjs({_type: "attribute", name: "HP", _characterid: P_C[j] })[0];
- if(HealthP_i.get("current")>0){
- HealthP_i.set({
- current: Math.floor(HealthP_i.get("current")*1-HealthP_i.get("max")*1*0.2*TimeJumped)
- });
- };
- };
- if(EffectCount.mild>0){
- TemperatureP_i.set({
- current: (TemperatureP_i.get("current")*1*0.95**TimeJumped)
- });
- };
- if ((findObjs({_type: "attribute", name: "wetness", _characterid: P_C[j] })[0])==undefined) {
- createObj("attribute", {
- name: "wetness",
- current: 0,
- max: 60,
- characterid: P_C[j]
- });
- };
- var WetnessP_i = findObjs({_type: "attribute", name: "wetness", _characterid: P_C[j] })[0]; //character of Player ID
- if(EffectCount.wet>0){
- if(EffectCount.wet==1){
- WetnessP_i.set({
- current: (WetnessP_i.get("current")*1+0.2167*TimeJumped)
- });
- };
- if(EffectCount.wet>1){
- WetnessP_i.set({
- current: (WetnessP_i.get("current")*1+1.5*0.4167*EffectCount.wet*TimeJumped)
- });
- };
- };
- if(EffectCount.dry>0){
- if(EffectCount.dry==1&&WetnessP_i.get("current")>0){
- WetnessP_i.set({
- current: (WetnessP_i.get("current")*1-0.4167*TimeJumped)
- });
- };
- if(EffectCount.wet>1&&WetnessP_i.get("current")>0){
- WetnessP_i.set({
- current: (WetnessP_i.get("current")*1-0.7*0.4167*EffectCount.wet*TimeJumped)
- });
- };
- if(WetnessP_i.get("current")<0){
- WetnessP_i.set({
- current: 0
- });
- };
- };
- if ((findObjs({_type: "attribute", name: "survival_status", _characterid: P_C[j] })[0])==undefined) {
- createObj("attribute", {
- name: "survival_status",
- current: 0,
- max: 30,
- characterid: P_C[j]
- });
- };
- };
- };
- j++;
- };
- i++;
- };
- };
- });
Add Comment
Please, Sign In to add comment