Fix armes naturelles/corps à corps
This commit is contained in:
parent
5ba86f12df
commit
3543ce60cb
@ -101,14 +101,14 @@ export class RdDCombatManager extends Combat {
|
|||||||
const carac = combatant.actor.system.carac[competence.system.defaut_carac].value;
|
const carac = combatant.actor.system.carac[competence.system.defaut_carac].value;
|
||||||
const niveau = competence.system.niveau;
|
const niveau = competence.system.niveau;
|
||||||
const bonusEcaille = (armeCombat?.system.magique) ? armeCombat.system.ecaille_efficacite : 0;
|
const bonusEcaille = (armeCombat?.system.magique) ? armeCombat.system.ecaille_efficacite : 0;
|
||||||
rollFormula = RdDCombatManager.formuleInitiative(2, carac, niveau, bonusEcaille);
|
rollFormula = RdDCombatManager.formuleInitiative(2, carac, niveau, bonusEcaille);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//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,24 +226,23 @@ 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',
|
system: {
|
||||||
system: {
|
competence: p.name,
|
||||||
competence: p.name,
|
possessionid: p.system.possessionid,
|
||||||
possessionid: p.system.possessionid,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}));
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
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()) {
|
||||||
@ -355,7 +356,7 @@ export class RdDCombatManager extends Combat {
|
|||||||
compData = RdDItemCompetence.findCompetence(combatant.actor.items, action.system.competence);
|
compData = RdDItemCompetence.findCompetence(combatant.actor.items, action.system.competence);
|
||||||
compNiveau = compData.system.niveau;
|
compNiveau = compData.system.niveau;
|
||||||
initInfo = action.name + " / " + action.system.competence;
|
initInfo = action.name + " / " + action.system.competence;
|
||||||
|
|
||||||
if (combatant.actor.type == 'creature' || combatant.actor.type == 'entite') {
|
if (combatant.actor.type == 'creature' || combatant.actor.type == 'entite') {
|
||||||
caracForInit = compData.system.carac_value;
|
caracForInit = compData.system.carac_value;
|
||||||
} else {
|
} else {
|
||||||
@ -383,7 +384,7 @@ export class RdDCombatManager extends Combat {
|
|||||||
switch (arme.system.cac) {
|
switch (arme.system.cac) {
|
||||||
case "empoignade":
|
case "empoignade":
|
||||||
return 3;
|
return 3;
|
||||||
case "pugilat":
|
case "pugilat":
|
||||||
case "naturelle":
|
case "naturelle":
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
@ -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,
|
||||||
@ -745,32 +747,32 @@ export class RdDCombat {
|
|||||||
isVisible(token, defenderToken) {
|
isVisible(token, defenderToken) {
|
||||||
return canvas.effects.visibility.testVisibility(defenderToken.center, { object: token })
|
return canvas.effects.visibility.testVisibility(defenderToken.center, { object: token })
|
||||||
}
|
}
|
||||||
|
|
||||||
distance(token, defenderToken) {
|
distance(token, defenderToken) {
|
||||||
return Number(canvas.grid.measureDistances([{ ray: new Ray(token.center, defenderToken.center) }], { gridSpaces: false })).toFixed(1);
|
return Number(canvas.grid.measureDistances([{ ray: new Ray(token.center, defenderToken.center) }], { gridSpaces: false })).toFixed(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
_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 };
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -857,7 +859,7 @@ export class RdDCombat {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _onAttaqueParticuliere(rollData) {
|
async _onAttaqueParticuliere(rollData) {
|
||||||
|
|
||||||
const isMeleeDiffNegative = (rollData.competence.type == 'competencecreature' || rollData.selectedCarac.label == "Mêlée") && rollData.diffLibre < 0;
|
const isMeleeDiffNegative = (rollData.competence.type == 'competencecreature' || rollData.selectedCarac.label == "Mêlée") && rollData.diffLibre < 0;
|
||||||
// force toujours, sauf empoignade
|
// force toujours, sauf empoignade
|
||||||
// finesse seulement en mélée, pour l'empoignade, ou si la difficulté libre est de -1 minimum
|
// finesse seulement en mélée, pour l'empoignade, ou si la difficulté libre est de -1 minimum
|
||||||
@ -875,7 +877,7 @@ export class RdDCombat {
|
|||||||
else if (!isForce && !isFinesse && isRapide) {
|
else if (!isForce && !isFinesse && isRapide) {
|
||||||
return await this.choixParticuliere(rollData, "rapidite");
|
return await this.choixParticuliere(rollData, "rapidite");
|
||||||
}
|
}
|
||||||
|
|
||||||
const choixParticuliere = await ChatMessage.create({
|
const choixParticuliere = await ChatMessage.create({
|
||||||
alias: this.attacker.name,
|
alias: this.attacker.name,
|
||||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(this.attacker.name),
|
whisper: ChatUtility.getWhisperRecipientsAndGMs(this.attacker.name),
|
||||||
@ -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