To continue on the subject, I've now created a section for close combat weapons. I can't figure how to populate the Damage Factor (DF) box. I've tried this code : <h2>Arme de tir</h2>
<fieldset class="repeating_weapons">
<select name="attr_weaponname">
<option value="aucune"selected>(Choisir)</option>
<option value="bolter">Bolter</option>
<option value="bolter_lourd">Bolter Lourd </option>
<option value="canon_grav">Canon Grav</option>
<option value="canon_laser">Canon Laser</option>
<option value="canon_plasma">Canon Plasma</option>
<option value="carabine_laser">Carabine Laser</option>
<option value="fusil_pompe">Fusil à pompe</option>
<option value="fusil_pompe_automatique">Fusil à pompe automatique</option>
<option value="fusil_grav">Fusil Grav</option>
<option value="fusil_melta">Fusil Melta</option>
<option value="fusil_plasma">Fusil Plasma</option>
<option value="grenade_fragmentation">Grenade à fragmentation</option>
<option value="grenade_flash">Grenade Flash</option>
<option value="grenade_melta">Grenade Melta</option>
<option value="Lance_flammes">Lance-flammes</option>
<option value="lance_flammes_lourd">Lance-flammes lourd</option>
<option value="lance_missile">Lance-missile</option>
<option value="multi_melta">Multi-Melta</option>
<option value="pistolet_bolter">Pistolet Bolter</option>
<option value="pistolet_grav">Pistolet Grav</option>
<option value="pistolet_laser">Pistolet Laser</option>
<option value="pistolet_melta">Pistolet Melta</option>
<option value="pistolet_plasma">Pistolet Plasma</option>
<option value="pistolet_stubber">Pistolet Stubber</option>
<option value="sniper_laser">Sniper Laser</option>
<option value="stubber">Stubber</option>
<option value="stubber_lourd">Stubber Lourd</option>
</select>
<button type="roll" name="roll_wound_level" value="&{template:default} {{name=@{character_name} tire avec @{weaponname} sur @{target|character_name} }} {{Niveau de la blessure =[[ @{INJ} + ?{Marge de succès?|0} - @{target|combined_personal_defense} ]] }}"></button><span class="dee">
<h5>INJ:</h5> <input name="attr_INJ" value="-" readonly />
<h5>Recharge:</h5> <input name="attr_Recharge" value="-" readonly />
<h5> Chargeur :</h5> <input name="attr_Chargeur" value="-" readonly /> <input type="hidden" name="attr_chargeurfull" value="" >
<button type="roll" name="roll_recharge" value="!ammo @{character_id} @{chargeurfull} [[-1*?{Recharge?|1d3|1d4|1d6|1d8|1d10}<1]]"></button>
</fieldset>
<h2>Arme de corps à corps</h2>
<fieldset class="repeating_weapons_cac">
<select name="attr_weaponname_cac">
<option value="arme_energetique_deux_mains" >Arme énergétique à deux mains</option>
<option value="arme_improvisee" selected>Arme improvisée</option>
<option value="eviscerateur" >Éviscérateur</option>
<option value="gantelet_energetique" >Gantelet énergétique</option>
<option value="hache" >Hache</option>
<option value="hache_deux_main" >Hache à deux mains</option>
<option value="hache_energetique" >Hache énergétique</option>
<option value="hache_tronconneuse" >Hache tronnçonneuse</option>
<option value="lame" >Lame</option>
<option value="lame_deux_mains" >Lame à deux mains</option>
<option value="lame_energetique" >Lame énergétique</option>
<option value="lame_tronconneuse" >Lame tronçonneuse</option>
<option value="lance" >Lance</option>
<option value="lance_energetique" >Lance énergtique</option>
<option value="mace" >Mace</option>
<option value="mace_energetique" >Mace Énergétique</option>
<option value="marteau_tonnerre" >Marteau tonnerre à deux mains</option>
</select>
<button type="roll" name="roll_wound_level_cac" value="&{template:default} {{name=@{character_name} attaque avec @{weaponname_cac} sur @{target|character_name} }} {{Niveau de la blessure =[[ @{target|body} + @{target|mass_scale} + @{DF} + ?{Marge de succès?|0} - @{target|combined_personal_defense} ]] }}"></button><span class="dee">
<h5>INJ:</h5> <input name="attr_DF" value="-" readonly />
</fieldset>
</div>
<script type="text/worker">
const weapons = {
aucune: {repeating_weapons_INJ: "", repeating_weapons_Recharge: "", repeating_weapons_Chargeur: ""},
bolter: {repeating_weapons_INJ: 3, repeating_weapons_Recharge: "1D6", repeating_weapons_Chargeur: 4},
bolter_lourd : {repeating_weapons_INJ: 4, repeating_weapons_Recharge: "1D6", repeating_weapons_Chargeur: 3},
canon_grav: {repeating_weapons_INJ: 2, repeating_weapons_Recharge: "1D3", repeating_weapons_Chargeur: 2},
canon_laser: {repeating_weapons_INJ: 9, repeating_weapons_Recharge: "1D3", repeating_weapons_Chargeur: 2},
canon_plasma: {repeating_weapons_INJ: 6, repeating_weapons_Recharge: "1D3", repeating_weapons_Chargeur: 3},
carabine_laser: {repeating_weapons_INJ: 1, repeating_weapons_Recharge: "1D10", repeating_weapons_Chargeur: 5},
fusil_pompe: {repeating_weapons_INJ: 1, repeating_weapons_Recharge: "1D6", repeating_weapons_Chargeur: 5},
fusil_pompe_automatique: {repeating_weapons_INJ: 2, repeating_weapons_Recharge: "1D3", repeating_weapons_Chargeur: 4},
fusil_grav: {repeating_weapons_INJ: 1, repeating_weapons_Recharge: "1D4", repeating_weapons_Chargeur: 3},
fusil_melta: {repeating_weapons_INJ: 6, repeating_weapons_Recharge: "1D4", repeating_weapons_Chargeur: 3},
fusil_plasma: {repeating_weapons_INJ: 5, repeating_weapons_Recharge: "1D6", repeating_weapons_Chargeur: 4},
grenade_fragmentation: {repeating_weapons_INJ: 2, repeating_weapons_Recharge: "N/A", repeating_weapons_Chargeur: 1},
grenade_flash: {repeating_weapons_INJ: 0, repeating_weapons_Recharge: "N/A", repeating_weapons_Chargeur: 3},
grenade_melta: {repeating_weapons_INJ: 5, repeating_weapons_Recharge: "N/A", repeating_weapons_Chargeur: 1},
Lance_flammes: {repeating_weapons_INJ: 1, repeating_weapons_Recharge: "1D3", repeating_weapons_Chargeur: 3},
lance_flammes_lourd: {repeating_weapons_INJ: 2, repeating_weapons_Recharge: "1D4", repeating_weapons_Chargeur: 2},
lance_missile: {repeating_weapons_INJ: 8, repeating_weapons_Recharge: "N/A", repeating_weapons_Chargeur: 5},
multi_melta: {repeating_weapons_INJ: 10, repeating_weapons_Recharge: "1D4", repeating_weapons_Chargeur: 3},
pistolet_bolter: {repeating_weapons_INJ: 2, repeating_weapons_Recharge: "1D8", repeating_weapons_Chargeur: 5},
pistolet_grav: {repeating_weapons_INJ: 0, repeating_weapons_Recharge: "1D6", repeating_weapons_Chargeur: 4},
pistolet_laser: {repeating_weapons_INJ: 1, repeating_weapons_Recharge: "1D10", repeating_weapons_Chargeur: 5},
pistolet_melta: {repeating_weapons_INJ: 4, repeating_weapons_Recharge: "1D3", repeating_weapons_Chargeur: 4},
pistolet_plasma: {repeating_weapons_INJ: 4, repeating_weapons_Recharge: "1D6", repeating_weapons_Chargeur: 4},
pistolet_stubber: {repeating_weapons_INJ: 0, repeating_weapons_Recharge: "1D10", repeating_weapons_Chargeur: 5},
sniper_laser: {repeating_weapons_INJ: 3, repeating_weapons_Recharge: "1D4", repeating_weapons_Chargeur: 3},
stubber: {repeating_weapons_INJ: 1, repeating_weapons_Recharge: "1D8", repeating_weapons_Chargeur: 4},
stubber_lourd: {repeating_weapons_INJ: 2, repeating_weapons_Recharge: "1D8", repeating_weapons_Chargeur: 3},
};
const weapons_cac = {
arme_energetique_deux_mains: {repeating_weapons_cac_DF: 7},
arme_improvisee: {repeating_weapons_cac_DF: -1},
eviscerateur: {repeating_weapons_cac_DF: 8},
gantelet_energetique: {repeating_weapons_cac_DF: 9},
hache: {repeating_weapons_cac_DF: 1},
hache_deux_main: {repeating_weapons_cac_DF: 3},
hache_energetique: {repeating_weapons_cac_DF: 5},
hache_tronconneuse: {repeating_weapons_cac_DF: 4},
lame: {repeating_weapons_cac_DF: 1},
lame_deux_mains: {repeating_weapons_cac_DF: 3},
lame_energetique: {repeating_weapons_cac_DF: 5},
lame_tronconneuse: {repeating_weapons_cac_DF: 4},
lance: {repeating_weapons_cac_DF: 1},
lance_energetique: {repeating_weapons_cac_DF: 5},
mace: {repeating_weapons_cac_DF: 1},
mace_energetique: {repeating_weapons_cac_DF: 5},
marteau_tonnerre: {repeating_weapons_cac_DF: 9},
};
on("change:repeating_weapons:weaponname sheet:opened", function () {
getAttrs(["repeating_weapons_weaponname"], function (values) {
const output = weapons[values.repeating_weapons_weaponname] || weapons['Aucune'];
setAttrs(output);
});
});
on("change:repeating_weapons_cac:weaponname sheet:opened", function () {
getAttrs(["repeating_weapons_cac_weaponname"], function (values) {
const output = weapons_cac[values.repeating_weapons_cac_weaponname] || weapons_cac['arme_improvisee'];
setAttrs(output);
});
});
on("change:repeating_weapons:Chargeur", function(eventInfo) {
setAttrs({
repeating_weapons_chargeurfull: eventInfo.sourceAttribute
});
});
</script>
Now both the shooting & close combat weapon doesn't work. Can someone please help me with this? Hopefully, I wasn't to far away from a solution.