fighting-konoha/browo.js

36 lines
2.5 KiB
JavaScript

/* Shared BRO WO moves (stocky safari ranger, fists and oil-palm trees): player and AI use the same rules. */
(() => {
'use strict';
const balance = { cooldowns:{skill1:4,skill2:7,ultimate:18}, castTime:.5, forestDamage:12, basicRefund:.05 };
const names = ['TINJU SAFARI','POHON SAWIT','JOGET GEMOY','HUTAN SAWIT'];
// Safari chain: a quick jab, a wide hook, then a heavy shoulder smash with big knockback. Reach sits inside the measured
// fist tip (82/82/97 px in BROWO_METRICS.emitters).
const combo = [
{damage:6,knockback:80,reach:105,duration:.34,hitAt:.5},
{damage:8,knockback:110,reach:105,duration:.38,hitAt:.5},
{damage:12,knockback:220,reach:120,duration:.5,hitAt:.58}
];
// Pohon Sawit: BRO WO slams a palm on the floor and an oil-palm erupts `ahead` px in front; everything inside `radius`
// px of that spot on the floor is hit. He does not need to touch the rival; a jump above 150 px clears it.
const tree = { ahead:190, radius:90 };
// Joget Gemoy: a cheerful shoulder-swaying dance; leaves burst around him and everything within `radius` is hit.
const dance = { radius:125 };
// Hutan Sawit: four palms erupt one after another in front of him (spacing `trees`, every `gap` s from `at`); a rival
// standing inside `radius` of any one takes 12 (48 total if all four land). He is free after the 0.5 s cast.
const forest = { cutinDuration:.78, trees:[150,280,410,540], at:.8, gap:.34, radius:85, duration:2.6 };
function move(name,index=1) {
if(name==='attack')return {name:`attack${index}`,type:'attack',index,...combo[index-1]};
if(name==='skill1')return {name,type:name,damage:18,duration:.62,knockback:210,tree:true,reach:tree.ahead+tree.radius,hitAt:.55};
if(name==='skill2')return {name,type:name,damage:14,duration:.62,knockback:260,dance:true,reach:dance.radius,hitAt:.5};
return {name:'ultimate',type:'ultimate',duration:balance.castTime,damage:0,hitAt:1};
}
function start(a,name,index=1) {
if(a.action||a.state==='hurt'||a.state==='down'||a.state==='recover')return false;
if(name!=='attack'&&a.cooldowns[name]>0)return false;
if(name!=='attack')a.cooldowns[name]=balance.cooldowns[name];
a.action={...move(name,index),t:0,fired:false,queued:0};a.state=a.action.name;a.stateTime=0;return true;
}
function refund(a) {for(const name of Object.keys(balance.cooldowns))a.cooldowns[name]=Math.max(0,a.cooldowns[name]-balance.cooldowns[name]*balance.basicRefund);}
window.Browo={balance,names,combo,tree,dance,forest,move,start,refund};
})();