Merge pull request #752 from PZ157/PR-Branch

武将技能ai优化
This commit is contained in:
Spmario233 2024-01-01 23:45:30 +08:00 committed by GitHub
commit 4039dd5bf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 18 deletions

View File

@ -67,7 +67,7 @@ game.import('card',function(lib,game,ui,get,ai,_status){
current.chooseToDiscard('he','弃置一张牌,并视为对'+get.translation(target)+'使用一张【杀】,或点击「取消」弃置其一张牌').set('ai',function(card){
if(!_status.event.goon) return 0;
return 5-get.value(card);
}).set('goon',(get.effect(target,{name:'guohe'},current)<get.effect(target,{name:'sha'},current)));
}).set('goon',(get.effect(target,{name:'guohe'},current)<get.effect(current,{name:'guohe'},current)+get.effect(target,{name:'sha'},current)));
}
else{
current.chooseBool('是否视为对'+get.translation(target)+'使用一张【杀】?','若点击「取消」则改为获得其一张牌').set('ai',function(){

View File

@ -155,8 +155,10 @@ game.import('card',function(lib,game,ui,get,ai,_status){
next.set('useShan',(()=>{
if(target.hasSkillTag('noShan',null,event)) return false;
if(target.hasSkillTag('useShan',null,event)) return true;
if(event.baseDamage+event.extraDamage<=0 || get.attitude(target,player._trueMe||player)>0) bool=false;
if(event.shanRequired>1&&target.countCards('h','shan')<event.shanRequired-(event.shanIgnored||0)) return false;
if(event.baseDamage+event.extraDamage<=0 || get.attitude(target,player._trueMe||player)>0) return false;
if(event.shanRequired>1&&target.mayHaveShan(target,'use',null,'count')<event.shanRequired-(event.shanIgnored||0)) return false;
if(event.baseDamage+event.extraDamage>=target.hp+
((player.hasSkillTag('jueqing',false,target)||target.hasSkill('gangzhi'))?target.hujia:0)) return true;
if(get.damageEffect(target,player,target,get.nature(event.card))>=0) return false;
return true;
})());

View File

@ -184,12 +184,29 @@ game.import('card',function(lib,game,ui,get,ai,_status){
return 0;
},
result:{
target:function(player,target,cardx){
if(player.hasSkillTag('viewHandcard',null,target,true)) return target.countCards('h',function(card){
return get.suit(card)!=get.suit(cardx)
})>0?-1.5:0;
return -1.4;
},
target:(player,target,card)=>{
//if(typeof card!=='object') return -2;
let suit=get.suit(card),
view=player.hasSkillTag('viewHandcard',null,target,true),
fz=0,
fm=0;
target.getCards('h',i=>{
if(i.isKnownBy(player)){
if(suit!==get.suit(i)){
if(view||get.is.shownCard(i)) return -2;
fz++;
fm++;
}
else if(!view&&!get.is.shownCard(i)) fm++;
}
else{
fz+=0.75;
fm++;
}
});
if(!fm) return 0;
return -2*fz/fm;
}
},
tag:{
damage:1,

View File

@ -3380,7 +3380,10 @@ game.import('character',function(lib,game,ui,get,ai,_status){
viewAs:{name:'juedou'},
position:'h',
filterTarget:lib.filter.targetEnabled,
check:(card)=>get.name(card)=='sha'?0:5.5-get.value(card),
ai1:(card)=>{
if(get.name(card)==='sha') return 0;
return 5.5-get.value(card);
},
log:false,
precontent:function(){
delete event.result.skill;

View File

@ -2083,9 +2083,9 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(target.hasMark('dcchangqu_warshipx')){
var prompt2='是否交给'+get.translation(player)+get.cnNumber(num)+'张手牌?'+(nextPlayer?'若如此做,将“战舰”移动给'+get.translation(nextPlayer)+'':'')+'否则你下次受到的属性伤害值+'+num;
target.chooseCard(get.translation(player)+'对你发动了【长驱】',prompt2).set('ai',card=>{
if(_status.event.att>0) return 6-get.value(card);
if(_status.event.take) return -get.value(card);
return 5-get.value(card);
if(_status.event.att>0) return 15-get.value(card);
if(_status.event.take) return 0;
return 8.2-0.8*Math.min(5,_status.event.target.hp+_status.event.target.hujia)-get.value(card);
}).set('att',get.attitude(target,player)).set('take',function(){
var base=num;
var getEffect=function(target,player,num){
@ -2101,7 +2101,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
var num=base+ind+1;
var effx=getEffect(current,player,num);
return effx<eff;
});
}).set('target',target);
});
}
else event.goto(4);
@ -4725,7 +4725,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(num>1&&player.hp+player.hujia>2) return 0;
if(target==player){
if(num) return -get.value(button.link,target);
if(ui.cardPile.childNodes.length>80) return 6-get.value(card,player);
if(ui.cardPile.childNodes.length>80) return 6-get.value(button.link,player);
return 0;
}
var val=get.buttonValue(button);
@ -9182,7 +9182,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
'step 0'
player.chooseTarget(get.prompt2('juetao'),lib.filter.notMe).set('ai',function(target){
let att=-get.attitude(_status.event.player,target);
if(att<=0) return -att;
if(att<=0) return att;
if(target.hasSkillTag('nodamage')) return 0.01*att;
if(target.getEquip('tengjia')||target.getEquip('renwang')) return 0.2*att;
if(target.getEquip('bugua')) return 0.3*att;

View File

@ -2872,9 +2872,18 @@ game.import('character',function(lib,game,ui,get,ai,_status){
},
tairan2:{
mod:{
aiValue:function(player,card,num){
if(card.hasGaintag&&card.hasGaintag('tairan')) return num/10;
aiOrder:function(player,card,num){
if(card.hasGaintag&&card.hasGaintag('tairan')) return 10*num;
},
aiValue:function(player,card,num){
if(card.hasGaintag&&card.hasGaintag('tairan')){
if(card.name!=='wuxie'&&(get.type(card)==='basic'||get.type(card,'trick')==='trick')) return num/64;
return num/8;
}
},
aiUseful:function(player,card,num){
return lib.skill.tairan2.mod.aiValue.apply(this,arguments);
}
},
audio:'tairan',
trigger:{player:'phaseUseBegin'},