ok, im not going to worry about it for now - but here is the reversed script just so you have it. var BloodSpatterAndStatusMarkers = {
version: '0.04',
wiki: '<a href="https://wiki.roll20.net/Script:Blood_And_Honor:_Automatic_blood_spatter,_pooling_and_trail_effects" rel="nofollow">https://wiki.roll20.net/Script:Blood_And_Honor:_Automatic_blood_spatter,_pooling_and_trail_effects</a>',
hpBar: 3, //1, 2, or 3
// This will make it so only the GM can use the !clearblood command. Change to "true" if you want to check for authorization.
onlyAllowGMtoRunCommands: true,
// YOU MUST ADD YOUR OWN SPATTERS AND POOLS TO YOUR LIBRARY AND GET THE IMAGE LINK VIA YOUR WEB BROWSER. FOLLOW THE INSTRUCTIONS HERE: <a href="https://wiki.roll20.net/API:Objects#imgsrc_and_avatar_property_restrictions" rel="nofollow">https://wiki.roll20.net/API:Objects#imgsrc_and_avatar_property_restrictions</a>
// You can add as many as you'd like to either category. Spatters are also used for blood trails.
spatters: [
{
'src': '<a href="https://s3.amazonaws.com/files.d20.io/images/11308495/wgpCBVKLA9xkZBPLZs2Jfw/thumb.png?1438782756" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11308495/wgpCBVKLA9xkZBPLZs2Jfw/thumb.png?1438782756</a>',
'width': 200,
'height': 171
},
{
'src': '<a href="https://s3.amazonaws.com/files.d20.io/images/11308515/JPJbvubaL7Fbj7jCmMLRdw/thumb.png?1438782875" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11308515/JPJbvubaL7Fbj7jCmMLRdw/thumb.png?1438782875</a>',
'width': 200,
'height': 171
},
{
'src': '<a href="https://s3.amazonaws.com/files.d20.io/images/11308554/wO9ME0h45T74xq29GpTlxw/thumb.png?1438783132" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11308554/wO9ME0h45T74xq29GpTlxw/thumb.png?1438783132</a>',
'width': 200,
'height': 171
},
{
'src': '<a href="https://s3.amazonaws.com/files.d20.io/images/11308568/YV9GDW2btgqpGf9LbCi8Og/thumb.png?1438783190" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11308568/YV9GDW2btgqpGf9LbCi8Og/thumb.png?1438783190</a>',
'width': 200,
'height': 127
},
{
'src': '<a href="https://s3.amazonaws.com/files.d20.io/images/11308599/07Znimavzx-DqON9R2NtrA/thumb.png?1438783373" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11308599/07Znimavzx-DqON9R2NtrA/thumb.png?1438783373</a>',
'width': 141,
'height': 200
},
{
'src': '<a href="https://s3.amazonaws.com/files.d20.io/images/11308621/IRkRSt7rxYUzu9df2XSBVw/thumb.png?1438783490" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11308621/IRkRSt7rxYUzu9df2XSBVw/thumb.png?1438783490</a>',
'width': 200,
'height': 150
},
{
'src': '<a href="https://s3.amazonaws.com/files.d20.io/images/11308646/5rvvjhNrq2f-yDpOP4QvhQ/thumb.png?1438783656" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11308646/5rvvjhNrq2f-yDpOP4QvhQ/thumb.png?1438783656</a>',
'width': 200,
'height': 172
},
{
'src': '<a href="https://s3.amazonaws.com/files.d20.io/images/11308660/y29gFvkPhkbzqmXQTZiHfg/thumb.png?1438783726" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11308660/y29gFvkPhkbzqmXQTZiHfg/thumb.png?1438783726</a>',
'width': 143,
'height': 200
},
{
'src': '<a href="https://s3.amazonaws.com/files.d20.io/images/11308636/jWVMPfRh_eFiEy75AZ27Ng/thumb.png?1438783602" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11308636/jWVMPfRh_eFiEy75AZ27Ng/thumb.png?1438783602</a>',
'width': 200,
'height': 142
}
],
pools: [
{
'src': '<a href="https://s3.amazonaws.com/files.d20.io/images/11308586/mVAuc41Amb78bnO5iTMSPg/thumb.png?1438783301" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11308586/mVAuc41Amb78bnO5iTMSPg/thumb.png?1438783301</a>',
'width': 185,
'height': 200
},
{
'src': '<a href="https://s3.amazonaws.com/files.d20.io/images/11308609/G8y5VJNFrMZzwer_Gth8QA/thumb.png?1438783421" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11308609/G8y5VJNFrMZzwer_Gth8QA/thumb.png?1438783421</a>',
'width': 160,
'height': 200,
//'sizeAdjustment': 1.4
}
],
chooseBlood: function (type) {
if (type === 'spatter') {
return BloodSpatterAndStatusMarkers.spatters[randomInteger(BloodSpatterAndStatusMarkers.spatters.length) - 1];
}
if (type === 'pool') {
return BloodSpatterAndStatusMarkers.pools[randomInteger(BloodSpatterAndStatusMarkers.pools.length) - 1];
}
},
getOffset: function () {
return Math.random() < 0.5 ? 1 : -1;
},
bloodColor: function (gmnotes) {
if (gmnotes.indexOf('bloodcolor_purple') !== -1) {
return '#0000ff';
} else if (gmnotes.indexOf('bloodcolor_blue') !== -1) {
return '#00ffff';
} else if (gmnotes.indexOf('bloodcolor_orange') !== -1) {
return '#ffff00';
} else {
return 'transparent';
}
},
createBlood: function (token, multiplier, bloodType) {
var pages = _.union([Campaign().get('playerpageid')], _.values(Campaign().get('playerspecificpages'))),
dropBlood = _.contains(pages, token.get('pageid')),
gmNotes = token.get('gmnotes');
if(!dropBlood || token.get('layer') !== 'objects' || gmNotes.indexOf('noblood') !== -1) {
return;
}
var size = Math.floor(BloodSpatterAndStatusMarkers.getTokenSize(token) * multiplier),
bloodImage = BloodSpatterAndStatusMarkers.chooseBlood(bloodType),
bloodTokenSource = bloodImage,
bloodTokenWidth = size * multiplier,
bloodTokenHeight = size * multiplier;
if(bloodImage !== null && typeof(bloodImage) === 'object') {
bloodTokenSource = bloodImage.src;
var bloodImageAspectRatio = bloodImage.width / bloodImage.height,
widthRatioMultiplier = 1,
heightRatioMultiplier = 1,
sizeAdjustment = 1;
if(bloodImage.sizeAdjustment) {
sizeAdjustment = bloodImage.sizeAdjustment;
}
if(bloodImageAspectRatio < 1) {
widthRatioMultiplier = bloodImageAspectRatio;
} else if (bloodImageAspectRatio > 1) {
heightRatioMultiplier = bloodImage.height / bloodImage.width;
}
bloodTokenWidth = bloodTokenWidth * widthRatioMultiplier * sizeAdjustment;
bloodTokenHeight = bloodTokenHeight * heightRatioMultiplier * sizeAdjustment;
}
var widthIncrement = bloodTokenWidth * 0.1,
widthIncrementTotal = widthIncrement,
heightIncrement = bloodTokenHeight * 0.1,
heightIncrementTotal = heightIncrement,
spatterToken = BloodSpatterAndStatusMarkers.fixedCreateObj('graphic', {
pageid: token.get('_pageid'),
imgsrc: bloodTokenSource,
tint_color: BloodSpatterAndStatusMarkers.bloodColor(gmNotes),
gmnotes: 'blood',
top: token.get('top') + (randomInteger(Math.floor(size / 2)) * BloodSpatterAndStatusMarkers.getOffset()),
left: token.get('left') + (randomInteger(Math.floor(size / 2)) * BloodSpatterAndStatusMarkers.getOffset()),
width: widthIncrement,
height: heightIncrement,
rotation: randomInteger(360) - 1,
layer: 'map'
});
toFront(spatterToken);
(function splatterEnlargeFunction (count) {
if (count < 10) {
setTimeout(function () {
widthIncrementTotal += widthIncrement;
heightIncrementTotal += heightIncrement;
spatterToken.set({
width: widthIncrementTotal,
height: heightIncrementTotal
});
splatterEnlargeFunction(count + 1);
}, 30);
}
})(0);
},
getTokenSize: function (token) {
return (token.get('height') + token.get('width')) / 2; //average the height and the width
},
timeout: 0,
increaseTimeout: function () {
BloodSpatterAndStatusMarkers.timeout += 2;
BloodSpatterAndStatusMarkers.watchTimeout();
},
interval: null,
watchTimeout: function () {
if (BloodSpatterAndStatusMarkers.interval === null) {
BloodSpatterAndStatusMarkers.interval = setInterval(function () {
if (BloodSpatterAndStatusMarkers.timeout > 0) {
BloodSpatterAndStatusMarkers.timeout--;
} else {
clearInterval(BloodSpatterAndStatusMarkers.interval);
BloodSpatterAndStatusMarkers.interval = null;
}
}, 2000);
}
},
fixedCreateObj: function () {
return function () {
var obj = createObj.apply(this, arguments);
if (obj && !obj.fbpath) {
obj.fbpath = obj.changed._fbpath.replace(/([^\/]*\/){4}/, '/');
}
return obj;
};
}(),
tokenHPChanged: function (token, maxHealth, currentHealth, damageTaken) {
if (maxHealth === '') {
return;
}
var percentOfHpLost = damageTaken / maxHealth,
damageMultiplier = 1 + Math.min(percentOfHpLost / 2, 0.5);
if (currentHealth >= maxHealth / 2) {
token.set({
status_redmarker: true
});
// Create spatter near token if "bloodied". Chance of spatter depends on severity of damage
if (damageTaken > 0 && currentHealth > 0 && currentHealth > randomInteger(maxHealth)) {
BloodSpatterAndStatusMarkers.createBlood(token, damageMultiplier, 'spatter');
}
} else {
token.set({
status_redmarker: false
});
}
if (currentHealth >= maxHealth) {
token.set({
status_dead: true
});
// Create pool near token if health drops below 1.
if(damageTaken > 0) {
BloodSpatterAndStatusMarkers.createBlood(token, damageMultiplier, 'pool');
}
} else {
token.set({
status_dead: false
});
}
}
};
on('ready', function () {
on('change:graphic:bar' + BloodSpatterAndStatusMarkers.hpBar + '_value', function (token, prev) {
var maxHealth = token.get('bar' + BloodSpatterAndStatusMarkers.hpBar + '_max'),
currentHealth = token.get('bar' + BloodSpatterAndStatusMarkers.hpBar + '_value'),
damageTaken = currentHealth - prev['bar' + BloodSpatterAndStatusMarkers.hpBar + '_value'];
BloodSpatterAndStatusMarkers.tokenHPChanged(token, maxHealth, currentHealth, damageTaken);
});
//Make blood trails, chance goes up depending on how injured a token is
on('change:graphic:lastmove', function (token) {
var maxHealth = token.get('bar' + BloodSpatterAndStatusMarkers.hpBar + '_max');
if (maxHealth === '' || BloodSpatterAndStatusMarkers.timeout !== 0) {
return;
}
var currentHealth = token.get('bar' + BloodSpatterAndStatusMarkers.hpBar + '_value'),
healthLost = maxHealth - currentHealth,
percentOfHpLost = healthLost / maxHealth,
damageMultiplier = .5 + Math.min(percentOfHpLost / 2, 0.5);
if (currentHealth >= maxHealth / 2 && currentHealth > randomInteger(maxHealth)) {
BloodSpatterAndStatusMarkers.createBlood(token, damageMultiplier, 'spatter');
BloodSpatterAndStatusMarkers.increaseTimeout();
}
});
on('chat:message', function (msg) {
if (msg.type === 'api' && msg.content.indexOf('!clearblood') !== -1) {
if (BloodSpatterAndStatusMarkers.onlyAllowGMtoRunCommands && !playerIsGM(msg.playerid)) {
sendChat(msg.who, '/w ' + msg.who + ' You are not authorized to use that command!');
return;
} else {
var objects = filterObjs(function (obj) {
if (obj.get('type') === 'graphic' && obj.get('gmnotes') === 'blood') {
return true;
} else {
return false;
}
});
_.each(objects, function (obj) {
obj.remove();
});
}
}
});
});