/**************************************** Druid Shift **************************************** This is for the 5E OGL sheet in Roll20. It will probably not work with any others without some modification. Also, I didn't do much in the way of error checking. The GM must make character named Druid X, where X is the creature being shifted into. It is suggested that the GM duplicate existing creatures, rename them, and assign to the druid player. The images for the characters must be uploaded and assigned to the avatar of the druid form characters. The easiest way I've found it to open the character sheet, edit, right click the picture in the avatar, copy, paste into your image program, save, upload and put it back in. Maybe you could just upload it back into the avatar directly. Anyways, this won't work if you don't first upload the image to your library. Either the druid player should have a general macro, or the forms characters should each have a token action with the body !DSBaseChar It's helpful if the druid character has token actions for each desired form. If you use multiple druids, or shapeshifters, add another check for !DSCharName for them. I put in several example forms in the code. Delete or add as needed. In the !DSBaseChar part of the code, you must replace 'Druid Char Name' with '<the druid character's name, exactly>'. *********************************************************************************************/ on("ready", function() { var getCleanImgsrc = function (imgsrc) { var parts = imgsrc.match(/(.*\/images\/.*)(thumb|med|original|max)([^\?]*)(\?[^?]+)?$/); if(parts) { return parts[1]+'thumb'+parts[3]+(parts[4]?parts[4]:`?${Math.round(Math.random()*9999999)}`); } return; }; on("chat:message", function (msg) { // Make sure to copy your druid character's name exactly in CharacterGet parameter. if (msg.type === "api" && msg.content === "!DSBaseChar") { CharacterGet('Lightbringer Doomstar', msg, 'Normal', 0); } if (msg.type === "api" && msg.content === "!DSBaseChar2") { CharacterGet('Harbek Liadon', msg, 'Normal', 60); } if (msg.type === "api" && msg.content === "!DSApe") { CharacterGet('Druid Ape', msg, 'Normal', 0); } if (msg.type === "api" && msg.content === "!DSAxeBeak") { CharacterGet('Druid Axe Beak', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSBrownBear") { CharacterGet('Druid Brown Bear', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSBlackBear") { CharacterGet('Druid Black Bear', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSCrocodile") { CharacterGet('Druid Crocodile', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSDireWolf") { CharacterGet('Druid Dire Wolf', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantBadger") { CharacterGet('Druid Giant Badger', msg, 'Normal', 0); } if (msg.type === "api" && msg.content === "!DSGiantCentipede") { CharacterGet('Druid Giant Centipede', msg, 'Normal', 0); } if (msg.type === "api" && msg.content === "!DSGiantEagle") { CharacterGet('Druid Giant Eagle', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantGoat") { CharacterGet('Druid Giant Goat', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantHyena") { CharacterGet('Druid Giant Hyena', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantOctopus") { CharacterGet('Druid Giant Octopus', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantSeaHorse") { CharacterGet('Druid Giant Sea Horse', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantSpider") { CharacterGet('Druid Giant Spider', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantWolfSpider") { CharacterGet('Druid Giant Wolf Spider', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantPoisonousSnake") { CharacterGet('Druid Giant Poisonous Snake', msg, 'Normal', 0); } if (msg.type === "api" && msg.content === "!DSGiantToad") { CharacterGet('Druid Giant Toad', msg, 'Large', 30); } if (msg.type === "api" && msg.content === "!DSPanther") { CharacterGet('Druid Panther', msg, 'Normal', 60); } if (msg.type === "api" && msg.content === "!DSReefShark") { CharacterGet('Druid Reef Shark', msg, 'Large', 30); } if (msg.type === "api" && msg.content === "!DSWarhorse") { CharacterGet('Druid Warhorse', msg, 'Large', 30); } if (msg.type === "api" && msg.content === "!DSGiantVulture") { CharacterGet('Druid Giant Vulture', msg, 'Large', 30); } if (msg.type === "api" && msg.content === "!DSTiger") { CharacterGet('Druid Tiger', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSLion") { CharacterGet('Druid Lion', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantAnt") { CharacterGet('Druid Giant Ant', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSCaveBear") { CharacterGet('Druid Cave Bear', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantBoar") { CharacterGet('Druid Giant Boar', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantConstrictorSnake") { CharacterGet('Druid Giant Constrictor Snake', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSConstrictorSnake") { CharacterGet('Druid Constrictor Snake', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantWasp") { CharacterGet('Druid Giant Wasp', msg, 'Normal', 60); } if (msg.type === "api" && msg.content === "!DSHunterShark") { CharacterGet('Druid Hunter Shark', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSPlesiosaurus") { CharacterGet('Druid Plesiosaurus', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSPolarBear") { CharacterGet('Druid Polar Bear', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSQuetzalcoatlus") { CharacterGet('Druid Quetzalcoatlus', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSRhinoceros") { CharacterGet('Druid Rhinoceros', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSSaberToothedTiger") { CharacterGet('Druid Saber-Toothed Tiger', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSAmphiptere") { CharacterGet('Druid Amphiptere', msg, 'Normal', 60); } if (msg.type === "api" && msg.content === "!DSAnkylosaurus") { CharacterGet('Druid Ankylosaurus', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSMbielu") { CharacterGet('Druid Mbielu', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSGiantScorpion") { CharacterGet('Druid Giant Scorpion', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSKillerWhale") { CharacterGet('Druid Killer Whale', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSNightScorpion") { CharacterGet('Druid Night Scorpion', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSStygianFatTailedScorpion") { CharacterGet('Druid Stygian Fat-Tailed Scorpion', msg, 'Normal', 60); } if (msg.type === "api" && msg.content === "!DSJbaFofiSpider") { CharacterGet('Druid Jba Fofi Spider', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantAntQueen") { CharacterGet('Druid Giant Ant Queen', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSCarrionBeetle") { CharacterGet('Druid Carrion Beetle', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSElephant") { CharacterGet('Druid Elephant', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSSerpopard") { CharacterGet('Druid Serpopard', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSStegosaurus") { CharacterGet('Druid Stegosaurus', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSBrontosaurus") { CharacterGet('Druid Brontosaurus', msg, 'Gargantuan', 60); } if (msg.type === "api" && msg.content === "!DSNgobou") { CharacterGet('Druid Ngobou', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSDrakon") { CharacterGet('Druid Drakon', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantCrocodile") { CharacterGet('Druid Giant Crocodile', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSGiantShark") { CharacterGet('Druid Giant Shark', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSKongamato") { CharacterGet('Druid Kongamato', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSTriceratops") { CharacterGet('Druid Triceratops', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSGbahali") { CharacterGet('Druid Gbahali', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSMammoth") { CharacterGet('Druid Mammoth', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSSandSpider") { CharacterGet('Druid Sand Spider', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantApe") { CharacterGet('Druid Giant Ape', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSTriceratops") { CharacterGet('Druid Triceratops', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSSavager") { CharacterGet('Druid Savager', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSTyrannosaurusRex") { CharacterGet('Druid Tyrannosaurus Rex', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSEarthElemental") { CharacterGet('Druid Earth Elemental', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSFireElemental") { CharacterGet('Druid Fire Elemental', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSWaterElemental") { CharacterGet('Druid Water Elemental', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSAirElemental") { CharacterGet('Druid Air Elemental', msg, 'Large', 60); } }); function Size(charSize, msg) { if (charSize === "Normal"){ _.each(msg.selected,function (o) { getObj(o._type,o._id).set("height", 70); getObj(o._type,o._id).set("width", 70); });} if (charSize === "Large"){ _.each(msg.selected,function (o) { getObj(o._type,o._id).set("height", 140); getObj(o._type,o._id).set("width", 140); });} if (charSize === "Huge"){ _.each(msg.selected,function (o) { getObj(o._type,o._id).set("height", 210); getObj(o._type,o._id).set("width", 210); });} if (charSize === "Gargantuan"){ _.each(msg.selected,function (o) { getObj(o._type,o._id).set("height", 280); getObj(o._type,o._id).set("width", 280); });} } function CharacterGet(characterName, msg, charSize, darkvision) { var ShiftCharacter = findObjs({ type: 'character', name: characterName })[0]; //sendChat("", "ShiftChar is: " + ShiftCharacter.get('name')); if(getAttrByName(ShiftCharacter.get('id'), 'npc', 'current') == 1) { //sendChat("", "NPC thing happened"); _.each(msg.selected,function (o) { getObj(o._type,o._id).set({ imgsrc: getCleanImgsrc(ShiftCharacter.get('avatar')), bar1_link: 'None', bar3_link: 'None', represents: ShiftCharacter.id, bar1_value: getAttrByName(ShiftCharacter.get('id'), 'hp', 'max'), bar1_max: getAttrByName(ShiftCharacter.get('id'), 'hp', 'max'), bar3_value: getAttrByName(ShiftCharacter.get('id'), 'npc_ac', 'current'), bar3_current: getAttrByName(ShiftCharacter.get('id'), 'npc_ac', 'current'), light_radius: darkvision, light_dimradius: 0, light_otherplayers: false }); }); } else { //sendChat("", "PC thing happened"); _.each(msg.selected,function (o) { getObj(o._type,o._id).set({ imgsrc: getCleanImgsrc(ShiftCharacter.get('avatar')), represents: ShiftCharacter.id, bar1_value: getAttrByName(ShiftCharacter.get('id'), "hp", 'current'), bar1_max: getAttrByName(ShiftCharacter.get('id'), "hp", 'max'), bar1_link: findObjs({type: "attribute", characterid: ShiftCharacter.get('id'), name: 'hp'})[0].id, bar3_value: getAttrByName(ShiftCharacter.get('id'), "ac", 'current'), bar3_max: getAttrByName(ShiftCharacter.get('id'), "ac", 'max'), bar3_link: findObjs({type: "attribute", characterid: ShiftCharacter.get('id'), name: 'ac'})[0].id, light_radius: darkvision, light_dimradius: 0, light_otherplayers: false }); }); } Size(charSize, msg); } });