Fix armes naturelles/corps à corps
This commit is contained in:
parent
5ba86f12df
commit
3543ce60cb
@ -107,8 +107,8 @@ export class RdDCombatManager extends Combat {
|
|||||||
}
|
}
|
||||||
//console.log("Combatat", c);
|
//console.log("Combatat", c);
|
||||||
const roll = combatant.getInitiativeRoll(rollFormula);
|
const roll = combatant.getInitiativeRoll(rollFormula);
|
||||||
if ( !roll.total) {
|
if (!roll.total) {
|
||||||
roll.evaluate( {async: false});
|
roll.evaluate({ async: false });
|
||||||
}
|
}
|
||||||
if (roll.total <= 0) roll.total = 0.00;
|
if (roll.total <= 0) roll.total = 0.00;
|
||||||
console.log("Compute init for", rollFormula, roll.total, combatant);
|
console.log("Compute init for", rollFormula, roll.total, combatant);
|
||||||
@ -156,12 +156,14 @@ export class RdDCombatManager extends Combat {
|
|||||||
let actions = [];
|
let actions = [];
|
||||||
for (const arme of armes) {
|
for (const arme of armes) {
|
||||||
if (arme.system.equipe) {
|
if (arme.system.equipe) {
|
||||||
const dommages = arme.system.dommages;
|
const dommages = arme.system.dommages.toString();
|
||||||
const tableauDommages = dommages.includes("/") ? dommages.split("/") : [dommages, dommages] ;
|
const tableauDommages = dommages.includes("/") ? dommages.split("/") : [dommages, dommages];
|
||||||
if (arme.system.unemain && arme.system.deuxmains && !dommages.includes("/")) {
|
if (arme.system.unemain && arme.system.deuxmains && !dommages.includes("/")) {
|
||||||
ui.notifications.info("Les dommages de l'arme à 1/2 mains " + arme.name + " ne sont pas corrects (ie sous la forme X/Y)");
|
ui.notifications.info("Les dommages de l'arme à 1/2 mains " + arme.name + " ne sont pas corrects (ie sous la forme X/Y)");
|
||||||
}
|
}
|
||||||
if (arme.system.unemain && arme.system.competence) {
|
console.log(">>>>", arme)
|
||||||
|
if ((arme.system.unemain && arme.system.competence) ||
|
||||||
|
(arme.system.competence.toLowerCase().includes("corps à corps"))) {
|
||||||
actions.push(RdDCombatManager.$prepareAttaqueArme({
|
actions.push(RdDCombatManager.$prepareAttaqueArme({
|
||||||
arme: arme,
|
arme: arme,
|
||||||
infoMain: "(1 main)",
|
infoMain: "(1 main)",
|
||||||
@ -224,8 +226,7 @@ export class RdDCombatManager extends Combat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static listActionsPossessions(actor) {
|
static listActionsPossessions(actor) {
|
||||||
return RdDCombatManager._indexActions(actor.getPossessions().map(p =>
|
return RdDCombatManager._indexActions(actor.getPossessions().map(p => {
|
||||||
{
|
|
||||||
return {
|
return {
|
||||||
name: p.name,
|
name: p.name,
|
||||||
action: 'conjurer',
|
action: 'conjurer',
|
||||||
@ -241,7 +242,7 @@ export class RdDCombatManager extends Combat {
|
|||||||
static listActionsCombat(combatant) {
|
static listActionsCombat(combatant) {
|
||||||
const actor = combatant.actor;
|
const actor = combatant.actor;
|
||||||
let actions = RdDCombatManager.listActionsPossessions(actor);
|
let actions = RdDCombatManager.listActionsPossessions(actor);
|
||||||
if (actions.length>0) {
|
if (actions.length > 0) {
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
if (actor.isCreature()) {
|
if (actor.isCreature()) {
|
||||||
@ -394,7 +395,7 @@ export class RdDCombatManager extends Combat {
|
|||||||
static displayInitiativeMenu(html, combatantId) {
|
static displayInitiativeMenu(html, combatantId) {
|
||||||
console.log("Combatant ; ", combatantId);
|
console.log("Combatant ; ", combatantId);
|
||||||
const combatant = game.combat.combatants.get(combatantId);
|
const combatant = game.combat.combatants.get(combatantId);
|
||||||
if (! (combatant?.actor) ) {
|
if (!(combatant?.actor)) {
|
||||||
ui.notifications.warn(`Le combatant ${combatant.name ?? combatantId} n'est pas associé à un acteur, impossible de déterminer ses actions de combat!`)
|
ui.notifications.warn(`Le combatant ${combatant.name ?? combatantId} n'est pas associé à un acteur, impossible de déterminer ses actions de combat!`)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -479,7 +480,7 @@ export class RdDCombat {
|
|||||||
else {
|
else {
|
||||||
const defender = target?.actor;
|
const defender = target?.actor;
|
||||||
const defenderTokenId = target?.id;
|
const defenderTokenId = target?.id;
|
||||||
if ( defender.type == 'entite' && defender.system.definition.typeentite == ENTITE_NONINCARNE) {
|
if (defender.type == 'entite' && defender.system.definition.typeentite == ENTITE_NONINCARNE) {
|
||||||
ui.notifications.warn("Vous ne pouvez pas cibler une entité non incarnée !!!!");
|
ui.notifications.warn("Vous ne pouvez pas cibler une entité non incarnée !!!!");
|
||||||
} else {
|
} else {
|
||||||
return this.create(attacker, defender, defenderTokenId, target)
|
return this.create(attacker, defender, defenderTokenId, target)
|
||||||
@ -589,7 +590,7 @@ export class RdDCombat {
|
|||||||
async onEvent(button, event) {
|
async onEvent(button, event) {
|
||||||
const chatMessage = ChatUtility.getChatMessage(event);
|
const chatMessage = ChatUtility.getChatMessage(event);
|
||||||
const defenderRoll = ChatUtility.getMessageData(chatMessage, 'defender-roll');
|
const defenderRoll = ChatUtility.getMessageData(chatMessage, 'defender-roll');
|
||||||
const attackerRoll = defenderRoll?.attackerRoll ?? ChatUtility.getMessageData(chatMessage, 'attacker-roll') ;
|
const attackerRoll = defenderRoll?.attackerRoll ?? ChatUtility.getMessageData(chatMessage, 'attacker-roll');
|
||||||
console.log('RdDCombat', attackerRoll, defenderRoll);
|
console.log('RdDCombat', attackerRoll, defenderRoll);
|
||||||
const defenderTokenId = event.currentTarget.attributes['data-defenderTokenId']?.value;
|
const defenderTokenId = event.currentTarget.attributes['data-defenderTokenId']?.value;
|
||||||
|
|
||||||
@ -709,12 +710,13 @@ export class RdDCombat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async proposerAjustementTirLancer( rollData ) {
|
async proposerAjustementTirLancer(rollData) {
|
||||||
if (['tir', 'lancer'].includes(rollData.competence.system.categorie)) {
|
if (['tir', 'lancer'].includes(rollData.competence.system.categorie)) {
|
||||||
if (this.defender.isEntite([ENTITE_BLURETTE])){
|
if (this.defender.isEntite([ENTITE_BLURETTE])) {
|
||||||
ChatMessage.create( {
|
ChatMessage.create({
|
||||||
content: `<strong>La cible est une blurette, l'arme à distance sera perdue dans le blurêve`,
|
content: `<strong>La cible est une blurette, l'arme à distance sera perdue dans le blurêve`,
|
||||||
whisper: ChatMessage.getWhisperRecipients("GM")})
|
whisper: ChatMessage.getWhisperRecipients("GM")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const defenderToken = canvas.tokens.get(this.defenderTokenId);
|
const defenderToken = canvas.tokens.get(this.defenderTokenId);
|
||||||
@ -723,7 +725,7 @@ export class RdDCombat {
|
|||||||
const portee = this._ajustementPortee(dist, rollData.arme)
|
const portee = this._ajustementPortee(dist, rollData.arme)
|
||||||
const taille = this._ajustementTaille(this.defender)
|
const taille = this._ajustementTaille(this.defender)
|
||||||
const activite = this._ajustementMouvement(this.defender)
|
const activite = this._ajustementMouvement(this.defender)
|
||||||
const total = [portee, taille, activite].map(it=>it.diff).filter(d => !Number.isNaN(d)).reduce(Misc.sum(), 0)
|
const total = [portee, taille, activite].map(it => it.diff).filter(d => !Number.isNaN(d)).reduce(Misc.sum(), 0)
|
||||||
ChatMessage.create({
|
ChatMessage.create({
|
||||||
content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-info-distance.html', {
|
content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-info-distance.html', {
|
||||||
rollData: rollData,
|
rollData: rollData,
|
||||||
@ -751,26 +753,26 @@ export class RdDCombat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_ajustementPortee(dist, arme) {
|
_ajustementPortee(dist, arme) {
|
||||||
if (dist <= arme.system.portee_courte) return {msg:"courte", diff:0};
|
if (dist <= arme.system.portee_courte) return { msg: "courte", diff: 0 };
|
||||||
if (dist <= arme.system.portee_moyenne) return {msg: "moyenne" , diff: -3};
|
if (dist <= arme.system.portee_moyenne) return { msg: "moyenne", diff: -3 };
|
||||||
if (dist <= arme.system.portee_extreme) return {msg: "extrême", diff:-5};
|
if (dist <= arme.system.portee_extreme) return { msg: "extrême", diff: -5 };
|
||||||
return {msg: "inatteignable", diff: -10};
|
return { msg: "inatteignable", diff: -10 };
|
||||||
}
|
}
|
||||||
|
|
||||||
_ajustementTaille(actor) {
|
_ajustementTaille(actor) {
|
||||||
if (actor.isVehicule()) return {msg: "véhicule", diff: 0}
|
if (actor.isVehicule()) return { msg: "véhicule", diff: 0 }
|
||||||
const taille = actor.getCaracByName('TAILLE')?.value ?? 1;
|
const taille = actor.getCaracByName('TAILLE')?.value ?? 1;
|
||||||
if (taille <= 1) return {msg: "souris", diff: -8};
|
if (taille <= 1) return { msg: "souris", diff: -8 };
|
||||||
if (taille <= 3) return {msg: "chat", diff: -4};
|
if (taille <= 3) return { msg: "chat", diff: -4 };
|
||||||
if (taille <= 5) return {msg: "chien", diff: -2};
|
if (taille <= 5) return { msg: "chien", diff: -2 };
|
||||||
if (taille <= 15) return {msg: "humanoïde", diff: 0};
|
if (taille <= 15) return { msg: "humanoïde", diff: 0 };
|
||||||
if (taille <= 20) return {msg: "ogre", diff: 2};
|
if (taille <= 20) return { msg: "ogre", diff: 2 };
|
||||||
return {msg: "gigantesque", diff: 4};
|
return { msg: "gigantesque", diff: 4 };
|
||||||
}
|
}
|
||||||
_ajustementMouvement(defender) {
|
_ajustementMouvement(defender) {
|
||||||
if (defender.getSurprise(true)) return {msg: "immobile (surprise)", diff: 0};
|
if (defender.getSurprise(true)) return { msg: "immobile (surprise)", diff: 0 };
|
||||||
if (game.combat?.combatants.find(it => it.actorId == defender.id)) return {msg: "en mouvement (combat)", diff: -4};
|
if (game.combat?.combatants.find(it => it.actorId == defender.id)) return { msg: "en mouvement (combat)", diff: -4 };
|
||||||
return {msg: "à déterminer (0 immobile, -3 actif, -4 en mouvement, -5 en zig-zag)", diff: -3};
|
return { msg: "à déterminer (0 immobile, -3 actif, -4 en mouvement, -5 en zig-zag)", diff: -3 };
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -914,7 +916,7 @@ export class RdDCombat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
isPossession( attackerRoll) {
|
isPossession(attackerRoll) {
|
||||||
return attackerRoll.selectedCarac.label.toLowerCase() == 'possession';
|
return attackerRoll.selectedCarac.label.toLowerCase() == 'possession';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1057,9 +1059,8 @@ export class RdDCombat {
|
|||||||
const arme = this.defender.getArmeParade(armeParadeId);
|
const arme = this.defender.getArmeParade(armeParadeId);
|
||||||
console.log("RdDCombat.parade >>>", attackerRoll, armeParadeId, arme);
|
console.log("RdDCombat.parade >>>", attackerRoll, armeParadeId, arme);
|
||||||
const competence = arme?.system?.competence;
|
const competence = arme?.system?.competence;
|
||||||
if (competence == undefined)
|
if (competence == undefined) {
|
||||||
{
|
console.error("Pas de compétence de parade associée à ", arme?.name, armeParadeId);
|
||||||
console.error("Pas de compétence de parade associée à ", arme?.name, armeParadeId) ;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"id": "foundryvtt-reve-de-dragon",
|
"id": "foundryvtt-reve-de-dragon",
|
||||||
"title": "Rêve de Dragon",
|
"title": "Rêve de Dragon",
|
||||||
"version": "10.2.5",
|
"version": "10.2.6",
|
||||||
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.2.5.zip",
|
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.2.6.zip",
|
||||||
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json",
|
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json",
|
||||||
"compatibility": {
|
"compatibility": {
|
||||||
"minimum": "10",
|
"minimum": "10",
|
||||||
|
Loading…
Reference in New Issue
Block a user