Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Script] Survival Timer

1508334154

Edited 1518105694
My first script posted on the forums! All feedback is appreciated. This Script was created for RPGs in general, some tweaking will almost certainly be needed to adjust to your campaign.&nbsp; EDIT: script also was written when I was way less experienced, approach installing it with patience.&nbsp; 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. * 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 need to be introduced into the API manually once, in the ID list at the top. If new players are added, manually updating is required again. * 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 respectively by eating and resting. * 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:&nbsp;Maps with only one time COLD/HOT will only get the temperature to a certain level, not being enough to harm the players.&nbsp; 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 &gt; 30, All rolls with disadvantage * Exhausted, Exhaustion &gt; 30, All rolls with disadvantage * Hot, Temperature &gt; 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 &lt; -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 &gt; 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 &gt; 60 (absolute value), fainting sets in, putting HP at 0. Time Jumps: * If the team does a time jump, this needs to be done manually for now. Each player should be affected the same. * you probably can still automate this pretty easily yourself with a multiple choice macro (so with elements like ?{question|default answer}) * 1 hour will raise hunger by 0.4167, exhaustion by 1.2501. * 1 hour will raise wetness by 0.2167/1.2501/1.875 for a WETx1/WETx2/WETx3 map, and lower it by 0.4167/0.5834/0.8750 for a DRYx1/DRYx2/DRYx3 map. * 1 hour will raise temperature by 0.4167/0.8334/1.2501 for a HOTx1/HOTx2/HOTx3 map, and lower it by 0.4167/0.8334/1.2501 in a COLDx1/COLDx2/COLDx3 map. * with HOTx1/COLDx1 maps, temperature should not go over 15 in absolute value, no matter how long the party stays there. * 1 hour of frostbite/overheating will lower HP by 15% / 20% of the max HP. * 1 hour multiply the absolute value of your temperature by 0.95 for MILD maps. EX1: this means that for 5 hours you need to multiply the initial temperature by (0.95)^5. Github Link: <a href="https://gist.github.com/gui8311/2a2027f6c0d38c619fcd0dd7cbc0e4a2" rel="nofollow">https://gist.github.com/gui8311/2a2027f6c0d38c619fcd0dd7cbc0e4a2</a>
It seems very interesting but after installation console gives me an error message. A syntax error message.&nbsp;
1508348501

Edited 1508350429
ah man... It should be fixed now. Btw, this script does not work if you do not&nbsp;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.
1508350450

Edited 1508352418
I just noticed still need to patch something up. script will be functional soon. EDIT: everything fixed! Sorry about the rough start, I had forgotten that I had given my test characters the survival attributes manually. the Script now add them if they are not already there.
A couple of questions: How can I find a player id? I found just mine (GM id) but I don't know how to find the ids of my players.&nbsp; Character id is unique or is associated with every individual token?
1508371071

Edited 1508371413
Character ID is not associated with a token, but with a character. So each token has a different token_id, but they can share the same character_id if they are linked to the same character.&nbsp; To find ID of a character, create a character, get a token associated with it, select token and input into chat: @{selected|character_id} I find the player ID like this: 1) add player to campaign as normal. 2) run another API script that logs player IDs to the API console: on('ready',function(){ 'use strict'; var players=findObjs({_type:'player'}); _.each(players,function (obj){ log('Player '+obj.get('displayname')+' has id: '+obj.get('id')); }); });
Yes, sorry it was late at night and get confused about tokens and players ids. Silly question. What about player id of a non-GM player? I need my players to login and then make 'em use the same script I used for finding GM id? on('ready',function(){ &nbsp; "use strict"; &nbsp; on('chat:message',function(msg){ &nbsp; &nbsp; if('api' === msg.type && '!getmyid' === msg.content){ &nbsp; &nbsp; &nbsp; sendChat('Your Player ID is','&lt;b&gt;'+msg.playerid+'&lt;/b&gt;'); &nbsp; &nbsp; } &nbsp; }); });
1508404094

Edited 1508404869
on('ready',function(){ &nbsp; "use strict"; &nbsp; on('chat:message',function(msg){ &nbsp; &nbsp; if('api' === msg.type && '!getmyid' === msg.content){ &nbsp; &nbsp; &nbsp; sendChat('Your Player ID is','&lt;b&gt;'+msg.playerid+'&lt;/b&gt;'); &nbsp; &nbsp; } &nbsp; }); }); this script will output their IDs as long as they are in the campaign, so they do not need to be online for you to get their IDs. You are the one that needs to run it, at the API page. Just copy and paste it into the API Editor, save it and that's it. It should now output the player's IDs into the console. It will output something like this: "Player Name1 has id: -KsZ2gcTh3A7GaZzsqLN" "Player Name2 has id: -KtfNyS2STTTTvbkiBOc" "Player Name3 has id: -KtfOJ3rPGqthX0Zcyxn"
So I put this in the Api console: //GM exclusive var P1 = findObjs({_type: "player", _id: "-KbLuBypgJEdgS1DTXjN" })[0]; //GM Player ID, not to be confused with character ID. Counts as Player 1 //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: "-KjmQdfmLheTR88AHn7R" })[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 = "-KjmQdfmLheTR88AHn7R"//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: "-Kk6efHb8p8XtT20Bct8" })[0]; //Player3, Player ID, leave empty ("") if there are no more players var P3_C1_id = "-Kk6efHb8p8XtT20Bct8"//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: "-Kkw5ITKvKic52lM9fY-" })[0]; //Player4, Player ID, leave empty ("") if there are no more players var P4_C1_id = "-KkmLm1dfouZz8EZRW6H"//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. I've set up a test map with the key words WET COLD in the name. As sessions could need temporal jumps to avoid downtime, is there a way to manually add conditions? I mean, for Roll20 a game session could be 4 hours, but inside the game those hours could be days. How can I cope with this? Another question is, how can I see actual conditions for a character? Is there any chat command?
1508423260

Edited 1508516779
Still havent implemented code for timejumps, for now you would have to manually change the attributes. once some effect settles in, like frostbite, whenever the script updates it will send a message saying that frostbite hits. this is the way to know, for now. Appreciate you trying the script out btw! EDIT: added new info to help with timejumps. This info is at the post that links to the script and in the script itself.
So everything is automatic? This is a cool idea&nbsp;
1508427193

Edited 1508429161
what is automated: * adding survival attributes to characters, if missing. * Change of hunger, exhaustion, temperature and wetness over time. * Warning messages about effects that settle in at 30 * Randomizing the effects that settle in * HP depletion from overheating and frostbite * Fainting messages at 60 * HP set to 0 from fainting A small macro to check the attribute values at will: /w gm @{selected|token_name} survival status! /w gm hunger: [[@{selected|hunger}]],&nbsp; /w gm exhaustion: [[@{selected|exhaustion}]],&nbsp; /w gm temperature: [[@{selected|temperature}]],&nbsp; /w gm wetness [[@{selected|wetness}]].
Wow this is actually really neat
Thanks Dylan :)