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 niveau = competence.system.niveau;
|
||||
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);
|
||||
const roll = combatant.getInitiativeRoll(rollFormula);
|
||||
if ( !roll.total) {
|
||||
roll.evaluate( {async: false});
|
||||
if (!roll.total) {
|
||||
roll.evaluate({ async: false });
|
||||
}
|
||||
if (roll.total <= 0) roll.total = 0.00;
|
||||
console.log("Compute init for", rollFormula, roll.total, combatant);
|
||||
@ -156,12 +156,14 @@ export class RdDCombatManager extends Combat {
|
||||
let actions = [];
|
||||
for (const arme of armes) {
|
||||
if (arme.system.equipe) {
|
||||
const dommages = arme.system.dommages;
|
||||
const tableauDommages = dommages.includes("/") ? dommages.split("/") : [dommages, dommages] ;
|
||||
const dommages = arme.system.dommages.toString();
|
||||
const tableauDommages = dommages.includes("/") ? dommages.split("/") : [dommages, dommages];
|
||||
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)");
|
||||
}
|
||||
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({
|
||||
arme: arme,
|
||||
infoMain: "(1 main)",
|
||||
@ -224,24 +226,23 @@ export class RdDCombatManager extends Combat {
|
||||
}
|
||||
|
||||
static listActionsPossessions(actor) {
|
||||
return RdDCombatManager._indexActions(actor.getPossessions().map(p =>
|
||||
{
|
||||
return {
|
||||
name: p.name,
|
||||
action: 'conjurer',
|
||||
system: {
|
||||
competence: p.name,
|
||||
possessionid: p.system.possessionid,
|
||||
}
|
||||
return RdDCombatManager._indexActions(actor.getPossessions().map(p => {
|
||||
return {
|
||||
name: p.name,
|
||||
action: 'conjurer',
|
||||
system: {
|
||||
competence: p.name,
|
||||
possessionid: p.system.possessionid,
|
||||
}
|
||||
}));
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static listActionsCombat(combatant) {
|
||||
const actor = combatant.actor;
|
||||
let actions = RdDCombatManager.listActionsPossessions(actor);
|
||||
if (actions.length>0) {
|
||||
if (actions.length > 0) {
|
||||
return actions;
|
||||
}
|
||||
if (actor.isCreature()) {
|
||||
@ -355,7 +356,7 @@ export class RdDCombatManager extends Combat {
|
||||
compData = RdDItemCompetence.findCompetence(combatant.actor.items, action.system.competence);
|
||||
compNiveau = compData.system.niveau;
|
||||
initInfo = action.name + " / " + action.system.competence;
|
||||
|
||||
|
||||
if (combatant.actor.type == 'creature' || combatant.actor.type == 'entite') {
|
||||
caracForInit = compData.system.carac_value;
|
||||
} else {
|
||||
@ -383,7 +384,7 @@ export class RdDCombatManager extends Combat {
|
||||
switch (arme.system.cac) {
|
||||
case "empoignade":
|
||||
return 3;
|
||||
case "pugilat":
|
||||
case "pugilat":
|
||||
case "naturelle":
|
||||
return 4;
|
||||
}
|
||||
@ -394,7 +395,7 @@ export class RdDCombatManager extends Combat {
|
||||
static displayInitiativeMenu(html, combatantId) {
|
||||
console.log("Combatant ; ", 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!`)
|
||||
return;
|
||||
}
|
||||
@ -479,7 +480,7 @@ export class RdDCombat {
|
||||
else {
|
||||
const defender = target?.actor;
|
||||
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 !!!!");
|
||||
} else {
|
||||
return this.create(attacker, defender, defenderTokenId, target)
|
||||
@ -589,7 +590,7 @@ export class RdDCombat {
|
||||
async onEvent(button, event) {
|
||||
const chatMessage = ChatUtility.getChatMessage(event);
|
||||
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);
|
||||
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 (this.defender.isEntite([ENTITE_BLURETTE])){
|
||||
ChatMessage.create( {
|
||||
if (this.defender.isEntite([ENTITE_BLURETTE])) {
|
||||
ChatMessage.create({
|
||||
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 {
|
||||
const defenderToken = canvas.tokens.get(this.defenderTokenId);
|
||||
@ -723,7 +725,7 @@ export class RdDCombat {
|
||||
const portee = this._ajustementPortee(dist, rollData.arme)
|
||||
const taille = this._ajustementTaille(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({
|
||||
content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-info-distance.html', {
|
||||
rollData: rollData,
|
||||
@ -745,32 +747,32 @@ export class RdDCombat {
|
||||
isVisible(token, defenderToken) {
|
||||
return canvas.effects.visibility.testVisibility(defenderToken.center, { object: token })
|
||||
}
|
||||
|
||||
|
||||
distance(token, defenderToken) {
|
||||
return Number(canvas.grid.measureDistances([{ ray: new Ray(token.center, defenderToken.center) }], { gridSpaces: false })).toFixed(1);
|
||||
}
|
||||
|
||||
_ajustementPortee(dist, arme) {
|
||||
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_extreme) return {msg: "extrême", diff:-5};
|
||||
return {msg: "inatteignable", diff: -10};
|
||||
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_extreme) return { msg: "extrême", diff: -5 };
|
||||
return { msg: "inatteignable", diff: -10 };
|
||||
}
|
||||
|
||||
_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;
|
||||
if (taille <= 1) return {msg: "souris", diff: -8};
|
||||
if (taille <= 3) return {msg: "chat", diff: -4};
|
||||
if (taille <= 5) return {msg: "chien", diff: -2};
|
||||
if (taille <= 15) return {msg: "humanoïde", diff: 0};
|
||||
if (taille <= 20) return {msg: "ogre", diff: 2};
|
||||
return {msg: "gigantesque", diff: 4};
|
||||
if (taille <= 1) return { msg: "souris", diff: -8 };
|
||||
if (taille <= 3) return { msg: "chat", diff: -4 };
|
||||
if (taille <= 5) return { msg: "chien", diff: -2 };
|
||||
if (taille <= 15) return { msg: "humanoïde", diff: 0 };
|
||||
if (taille <= 20) return { msg: "ogre", diff: 2 };
|
||||
return { msg: "gigantesque", diff: 4 };
|
||||
}
|
||||
_ajustementMouvement(defender) {
|
||||
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};
|
||||
return {msg: "à déterminer (0 immobile, -3 actif, -4 en mouvement, -5 en zig-zag)", diff: -3};
|
||||
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 };
|
||||
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) {
|
||||
|
||||
|
||||
const isMeleeDiffNegative = (rollData.competence.type == 'competencecreature' || rollData.selectedCarac.label == "Mêlée") && rollData.diffLibre < 0;
|
||||
// force toujours, sauf empoignade
|
||||
// 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) {
|
||||
return await this.choixParticuliere(rollData, "rapidite");
|
||||
}
|
||||
|
||||
|
||||
const choixParticuliere = await ChatMessage.create({
|
||||
alias: 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';
|
||||
}
|
||||
|
||||
@ -1057,9 +1059,8 @@ export class RdDCombat {
|
||||
const arme = this.defender.getArmeParade(armeParadeId);
|
||||
console.log("RdDCombat.parade >>>", attackerRoll, armeParadeId, arme);
|
||||
const competence = arme?.system?.competence;
|
||||
if (competence == undefined)
|
||||
{
|
||||
console.error("Pas de compétence de parade associée à ", arme?.name, armeParadeId) ;
|
||||
if (competence == undefined) {
|
||||
console.error("Pas de compétence de parade associée à ", arme?.name, armeParadeId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,8 +1,8 @@
|
||||
{
|
||||
"id": "foundryvtt-reve-de-dragon",
|
||||
"title": "Rêve de Dragon",
|
||||
"version": "10.2.5",
|
||||
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.2.5.zip",
|
||||
"version": "10.2.6",
|
||||
"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",
|
||||
"compatibility": {
|
||||
"minimum": "10",
|
||||
|
Loading…
Reference in New Issue
Block a user