Difference between pages "Ballistic Skills" and "MediaWiki:Common.js"

From Infinity
(Difference between pages)
Jump to: navigation, search
 
 
Line 1: Line 1:
{{section-combat-module}}
+
/* Any JavaScript here will be loaded for all users on every page load. */
  
  
Ranged combat and firefights are the foundation of modern warfare and play an equally pivotal role in Infinity CodeOne.
+
/* Cookie consent */
  
 +
!function(){var i,r,o;i="__tcfapiLocator",r=[],(o=window.frames[i])||(function e(){var t=window.document,a=!!o;if(!a)if(t.body){var n=t.createElement("iframe");n.style.cssText="display:none",n.name=i,t.body.appendChild(n)}else setTimeout(e,5);return!a}(),window.__tcfapi=function(){for(var e,t=[],a=0;a<arguments.length;a++)t[a]=arguments[a];if(!t.length)return r;if("setGdprApplies"===t[0])3<t.length&&2===parseInt(t[1],10)&&"boolean"==typeof t[3]&&(e=t[3],"function"==typeof t[2]&&t[2]("set",!0));else if("ping"===t[0]){var n={gdprApplies:e,cmpLoaded:!1,cmpStatus:"stubCMP",apiVersion:2};"function"==typeof t[2]&&t[2](n,!0)}else r.push(t)},window.addEventListener("message",function(n){var i="string"==typeof n.data,e={};try{e=i?JSON.parse(n.data):n.data}catch(e){}var r=e.__tcfapiCall;r&&window.__tcfapi(r.command,r.version,function(e,t){var a={__tcfapiReturn:{returnValue:e,success:t,callId:r.callId}};i&&(a=JSON.stringify(a)),n.source.postMessage(a,"*")},r.parameter)},!1))}();
 +
!function(){var i,n,s;i="__uspapiLocator",n=[],(s=window.frames[i])||(function a(){var e=window.document,n=!!s;if(!s)if(e.body){var t=e.createElement("iframe");t.style.cssText="display:none",t.name=i,e.body.appendChild(t)}else setTimeout(a,5);return!n}(),window.__uspapi=function(){for(var a=[],e=0;e<arguments.length;e++)a[e]=arguments[e];if(!a.length)return n;"ping"===a[0]?"function"==typeof a[2]&&a[2]({cmpLoaded:!1,cmpStatus:"stubCMP"},!0):n.push(a)},window.addEventListener("message",function(t){var i="string"==typeof t.data,a={};try{a=i?JSON.parse(t.data):t.data}catch(a){}var s=a.__uspapiCall;s&&window.__uspapi(s.command,s.version,function(a,e){var n={__uspapiReturn:{returnValue:a,success:e,callId:s.callId}};i&&(n=JSON.stringify(n)),t.source.postMessage(n,"*")},s.parameter)},!1))}();
  
== BS ATTACK MODIFIERS (MOD) ==
+
<script async src='https://cmp.uniconsent.com/v2/a635eb8630/cmp.js'></script>
  
Before performing the [[BS Attack]] Roll (or Rolls), the player must check every [[MOD]] they must apply. There are [[MOD]]s that will affect the numerical value of the roll, the Attribute and others may affect the BS Attack Roll's [[Burst]] (B). Existing [[MOD]]s are:
 
  
*Cover
 
*Range
 
*Special Skills, Weapons, pieces of Equipment, or States.
 
  
  
=== Cover ===
+
/* The main toggle function moved here. */
  
The term Cover refers to all pieces of scenery that partially or completely obstruct [[LoF]], thus preventing the attacker from making a clean [[BS Attack]].
+
function toggleN4(showN4) {
 +
/*  alert("clicked! " +showN4); */
 +
    if (showN4=="true") {
 +
        $(".n4").show(300);
 +
        $(".n4list").show(300);
 +
        $(".n4inline").show(300);
 +
        $(".c1hide").hide(300);
 +
        setCookie("showN4", "true", 30);
 +
        var user=getCookie("showN4");
 +
/*      alert("Saved cookie: " + user); */
 +
        var ele = document.getElementsByClassName("c1strike");
 +
        for(var i=0;i<ele.length;i++){
 +
            ele[i].style.setProperty("text-decoration", "line-through");
 +
        }
 +
    } else {
 +
        $(".n4").hide(300);
 +
        $(".n4list").hide(300);
 +
        $(".n4inline").hide(300);
 +
        $(".c1hide").show(300);
 +
        setCookie("showN4", "false", 30);
 +
        var user=getCookie("showN4");
 +
/*      alert("Saved cookie: " + user); */
 +
        var ele = document.getElementsByClassName("c1strike");
 +
        for(var i=0;i<ele.length;i++){
 +
            ele[i].style.setProperty("text-decoration", "");
 +
        }
 +
    }
 +
}
  
{{effects}}
 
*If the target is in '''Total Cover''', the attacker may not declare a BS Attack with Weapons, Special Skills, or Equipment, that requires '''LoF'''.
 
*If the target is in '''Partial Cover''', the attacker will apply a -3 [[MOD]] to their BS Attack Roll and the target of the [[BS Attack]] reduces the [[Attack Damage]] by 3 for [[Saving Roll]] purposes, if the Roll was necessary.
 
  
 +
function forceN4() {
 +
/*  alert("clicked! " +showN4); */
 +
        setCookie("showN4", "true", 30);
 +
        $(".n4").show(0);
 +
        $(".n4list").show(0);
 +
        $(".n4inline").show(0);
 +
        $(".c1hide").hide(0);
 +
        $('#gametoggle').attr('checked', true);
 +
        var ele = document.getElementsByClassName("c1strike");
 +
        for(var i=0;i<ele.length;i++){
 +
            ele[i].style.setProperty("text-decoration", "line-through");
 +
        }
 +
 +
}
  
=== Types of Cover ===
 
  
==== Total Cover ====
+
function forceC1() {
Total Cover completely blocks the attacker's vision of his target, obstructing any [[LoF]] to their [[Silhouette]].  
+
/*  alert("clicked! " +showN4); */
 +
        setCookie("showN4", "false", 30);
 +
        $('#gametoggle').attr('checked', false);
 +
      $(".n4").hide(0);
 +
      $(".n4list").hide(0);
 +
        $(".n4inline").hide(0);
 +
        $(".c1hide").show(0);
 +
        var ele = document.getElementsByClassName("c1strike");
 +
        for(var i=0;i<ele.length;i++){
 +
            ele[i].style.setProperty("text-decoration", "");
 +
        }
 +
}
  
A target is in Total Cover when one or more scenery items completely blocks [[LoF]] to its [[Silhouette]].
 
  
==== Partial Cover ====
 
Partial Cover does '''not''' allow the attacker to see the whole [[Silhouette]] of their BS Attack's target.
 
  
A target is in Partial Cover when they are in contact with a piece of scenery that partially obscures their [[Silhouette]].
+
/* This code creates the N4 reveal slider, and what happens when you click on it. */
  
 +
$(document).ready(function(){
 +
    var doShow=getCookie("showN4");
 +
    if (doShow =="true") {
 +
        forceN4()
 +
    }
 +
    var showFromURL=getParameterByName('version');
 +
    if (showFromURL =="n4") {
 +
        forceN4()
 +
        setCookie("showN4", "true", 30);
 +
    }
 +
    if (showFromURL =="c1") {
 +
        forceC1()
 +
        setCookie("showN4", "false", 30);
 +
    }
  
==== Line of Fire and Cover ====
+
          $(".n4toggle").hide();
 +
            $("#gametoggle").click(function(){
 +
                if ($("#gametoggle").is(":checked")) {
 +
                    toggleN4("true")
 +
              } else {
 +
                    toggleN4("false")
 +
                }
 +
            });
 +
        });
  
NO COVER
 
{{image | name=eng-lof-and-cover-nocover-1024.jpg | style=512border }}
 
  
PARTIAL COVER
+
$(function () {
 +
$('#n4gametoggle').html("<span class='gamesliderlabel'>Show full N4 rules: </span><label class='switch' > <input type='checkbox' id='gametoggle' ><span class='slider round' ></span></label>");
 +
}());
  
Partial Cover due to being in contact with a scenery element that covers part of the target’s Silhouette.
 
{{image | name=eng-lof-and-cover-partialcover-1024.jpg | style=512border }}
 
  
TOTAL COVER
 
{{image | name=eng-lof-and-cover-totalcover-1024.jpg | style=512border }}
 
  
  
=== Range ===
+
/* URL parameter stuff. */
  
All BS Weapons, pieces of Equipment, and Special Skills, that can make [[BS Attack]]s apply a Range MOD that depends on the distance between the attacker and the target (see [[Range]]).
+
function getParameterByName(name, url) {
 +
    if (!url) url = window.location.href;
 +
    name = name.replace(/[\[\]]/g, '\\$&');
 +
    var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
 +
        results = regex.exec(url);
 +
    if (!results) return null;
 +
    if (!results[2]) return '';
 +
    return decodeURIComponent(results[2].replace(/\+/g, ' '));
 +
}
  
If the target is beyond the maximum Range of the BS Weapon, piece of Equipment or Special Skill, then the BS Attack automatically fails (the Order is spent, Disposable weapons lose a use, etc.).
 
  
For example, for the Combi Rifle we have the following values:
 
  
{{image | name=combi-rifle-1024.jpg | style=512border }}
 
  
{{c1}}
 
{{weapon}}
 
{{weaponrow|Combi Rifle|+3|+3|-3|-3|-6|-6|--|13|3|N|ARM|}}
 
|}
 
{{c1end}}
 
{{n4}}
 
{{weapon}}
 
{{weaponrow|Combi Rifle|+3|+3|-3|-3|-6|-6|--|13|3|N|ARM| [[Suppressive Fire Trait | Suppressive Fire]]}}
 
|}
 
{{n4end}}
 
  
  
*If the distance between the Trooper and the Target is from 0 to 16 inches, the Trooper has a +3 [[MOD]] to their BS Attack Roll due to Range.  
+
/* Cookie stuff. */
*If the distance is greater than 16 inches and equal to or less than 32 inches, the Trooper has a -3 [[MOD]] to their BS Attack Roll due to Range.
 
*If the distance is greater than 32 inches and equal to or less than 48 inches, the Trooper has a -6 [[MOD]] to their BS Attack Roll due to Range.
 
*The BS Attack automatically fails if the Range is more than 48 inches.
 
  
 +
function setCookie(cname, cvalue, exdays) {
 +
  var d = new Date();
 +
  d.setTime(d.getTime() + (exdays*24*60*60*1000));
 +
  var expires = "expires="+ d.toUTCString();
 +
  document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
 +
}
  
=== Special Skills, Weapons, Equipment, or States ===
+
function getCookie(cname) {
 
+
  var name = cname + "=";
Certain Special Skills, Weapons, Equipment or States can apply a [[MOD]] to [[BS Attack]] Rolls. These Special Skills, Weapons, pieces of Equipment, or States are explained in the respective sections of this rulebook.
+
  var decodedCookie = decodeURIComponent(document.cookie);
 
+
  var ca = decodedCookie.split(';');
== BS Attack Into a Close Combat ==
+
  for(var i = 0; i <ca.length; i++) {
If a [[BS Attack]] is declared against an enemy Trooper that is engaged in CC Combat a -6 [[MOD]] must be applied for each Allied Trooper engaged in the [[Close Combat|CC]] (in addition to any [[MODs]] for [[Range]], [[Cover]], [[Mimetism]]... for the target).
+
    var c = ca[i];
 
+
    while (c.charAt(0) == ' ') {
{{n4}}
+
      c = c.substring(1);
Every failed BS Attack Roll will hit the Allied Trooper, forcing them to perform a Saving Roll. If there are several Allied Troopers locked in that Close Combat, then the Trooper’s player chooses which one of them receives each hit.
+
    }
{{n4end}}
+
    if (c.indexOf(name) == 0) {
 
+
      return c.substring(name.length, c.length);
 
+
    }
{{section-combat-module}}
+
  }
 
+
  return "";
 
+
}
 
 
[[Category: Combat Module]]
 

Revision as of 12:49, 11 June 2021

/* Any JavaScript here will be loaded for all users on every page load. */


/* Cookie consent */

!function(){var i,r,o;i="__tcfapiLocator",r=[],(o=window.frames[i])||(function e(){var t=window.document,a=!!o;if(!a)if(t.body){var n=t.createElement("iframe");n.style.cssText="display:none",n.name=i,t.body.appendChild(n)}else setTimeout(e,5);return!a}(),window.__tcfapi=function(){for(var e,t=[],a=0;a<arguments.length;a++)t[a]=arguments[a];if(!t.length)return r;if("setGdprApplies"===t[0])3<t.length&&2===parseInt(t[1],10)&&"boolean"==typeof t[3]&&(e=t[3],"function"==typeof t[2]&&t[2]("set",!0));else if("ping"===t[0]){var n={gdprApplies:e,cmpLoaded:!1,cmpStatus:"stubCMP",apiVersion:2};"function"==typeof t[2]&&t[2](n,!0)}else r.push(t)},window.addEventListener("message",function(n){var i="string"==typeof n.data,e={};try{e=i?JSON.parse(n.data):n.data}catch(e){}var r=e.__tcfapiCall;r&&window.__tcfapi(r.command,r.version,function(e,t){var a={__tcfapiReturn:{returnValue:e,success:t,callId:r.callId}};i&&(a=JSON.stringify(a)),n.source.postMessage(a,"*")},r.parameter)},!1))}();
!function(){var i,n,s;i="__uspapiLocator",n=[],(s=window.frames[i])||(function a(){var e=window.document,n=!!s;if(!s)if(e.body){var t=e.createElement("iframe");t.style.cssText="display:none",t.name=i,e.body.appendChild(t)}else setTimeout(a,5);return!n}(),window.__uspapi=function(){for(var a=[],e=0;e<arguments.length;e++)a[e]=arguments[e];if(!a.length)return n;"ping"===a[0]?"function"==typeof a[2]&&a[2]({cmpLoaded:!1,cmpStatus:"stubCMP"},!0):n.push(a)},window.addEventListener("message",function(t){var i="string"==typeof t.data,a={};try{a=i?JSON.parse(t.data):t.data}catch(a){}var s=a.__uspapiCall;s&&window.__uspapi(s.command,s.version,function(a,e){var n={__uspapiReturn:{returnValue:a,success:e,callId:s.callId}};i&&(n=JSON.stringify(n)),t.source.postMessage(n,"*")},s.parameter)},!1))}();

<script async src='https://cmp.uniconsent.com/v2/a635eb8630/cmp.js'></script>




/* The main toggle function moved here. */

function toggleN4(showN4) {
/*   alert("clicked! " +showN4); */
    if (showN4=="true") {
        $(".n4").show(300);
        $(".n4list").show(300);
        $(".n4inline").show(300);
        $(".c1hide").hide(300);
        setCookie("showN4", "true", 30);
        var user=getCookie("showN4");
 /*       alert("Saved cookie: " + user); */
        var ele = document.getElementsByClassName("c1strike");
        for(var i=0;i<ele.length;i++){
            ele[i].style.setProperty("text-decoration", "line-through");
        }
    } else {
        $(".n4").hide(300);
        $(".n4list").hide(300);
        $(".n4inline").hide(300);
        $(".c1hide").show(300);
        setCookie("showN4", "false", 30);
        var user=getCookie("showN4");
 /*       alert("Saved cookie: " + user); */
        var ele = document.getElementsByClassName("c1strike");
        for(var i=0;i<ele.length;i++){
            ele[i].style.setProperty("text-decoration", "");
        }
    }
}


function forceN4() {
/*   alert("clicked! " +showN4); */
        setCookie("showN4", "true", 30);
        $(".n4").show(0);
        $(".n4list").show(0);
        $(".n4inline").show(0);
        $(".c1hide").hide(0);
        $('#gametoggle').attr('checked', true);
        var ele = document.getElementsByClassName("c1strike");
        for(var i=0;i<ele.length;i++){
            ele[i].style.setProperty("text-decoration", "line-through");
        }
 
}


function forceC1() {
/*   alert("clicked! " +showN4); */
        setCookie("showN4", "false", 30);
        $('#gametoggle').attr('checked', false);
       $(".n4").hide(0);
       $(".n4list").hide(0);
        $(".n4inline").hide(0);
        $(".c1hide").show(0);
        var ele = document.getElementsByClassName("c1strike");
        for(var i=0;i<ele.length;i++){
            ele[i].style.setProperty("text-decoration", "");
        }
}



/* This code creates the N4 reveal slider, and what happens when you click on it. */

$(document).ready(function(){
    var doShow=getCookie("showN4");
    if (doShow =="true") {
        forceN4()
    }
    var showFromURL=getParameterByName('version');
    if (showFromURL =="n4") {
        forceN4()
        setCookie("showN4", "true", 30);
    }
    if (showFromURL =="c1") {
        forceC1()
        setCookie("showN4", "false", 30);
    }

          $(".n4toggle").hide();
            $("#gametoggle").click(function(){
                if ($("#gametoggle").is(":checked")) {
                    toggleN4("true")
               } else {
                    toggleN4("false")
                }
            });
        });


$(function () {
	$('#n4gametoggle').html("<span class='gamesliderlabel'>Show full N4 rules: </span><label class='switch' > <input type='checkbox' id='gametoggle' ><span class='slider round' ></span></label>");
}());




/* URL parameter stuff. */

function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, '\\$&');
    var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, ' '));
}






/* Cookie stuff. */

function setCookie(cname, cvalue, exdays) {
  var d = new Date();
  d.setTime(d.getTime() + (exdays*24*60*60*1000));
  var expires = "expires="+ d.toUTCString();
  document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}

function getCookie(cname) {
  var name = cname + "=";
  var decodedCookie = decodeURIComponent(document.cookie);
  var ca = decodedCookie.split(';');
  for(var i = 0; i <ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0) == ' ') {
      c = c.substring(1);
    }
    if (c.indexOf(name) == 0) {
      return c.substring(name.length, c.length);
    }
  }
  return "";
}