Merge pull request #495 from PZ157/PR-Branch

优化部分技能ai
This commit is contained in:
Spmario233 2023-10-09 22:14:42 +08:00 committed by GitHub
commit 21425e6948
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 107 additions and 45 deletions

View File

@ -3304,14 +3304,14 @@ game.import('character',function(lib,game,ui,get,ai,_status){
dddduanbing:{ dddduanbing:{
enable:'phaseUse', enable:'phaseUse',
filter:function(event,player){ filter:function(event,player){
return player.canAddJudge('bingliang')&&player.hasCard((card)=>lib.skill['dddduanbing'].filterCard(card,player),'h'); return player.canAddJudge('bingliang')&&player.hasCard((card)=>lib.skill['dddduanbing'].filterCard(card,player),'he');
}, },
filterCard:function(card,player){ filterCard:function(card,player){
if(get.color(card)!='black'||get.type2(card)=='trick') return false; if(get.color(card)!='black'||get.type2(card)=='trick') return false;
return player.canAddJudge(get.autoViewAs({name:'bingliang'},[card])); return player.canAddJudge(get.autoViewAs({name:'bingliang'},[card]));
}, },
check:function(card){ check:function(card){
return 6-get.value(card); return 8.2-get.value(card);
}, },
discard:false, discard:false,
lose:false, lose:false,

View File

@ -6398,6 +6398,14 @@ game.import('character',function(lib,game,ui,get,ai,_status){
trigger.directHit.push(trigger.target); trigger.directHit.push(trigger.target);
} }
}, },
ai:{
effect:{
player:function(card,player,target){
if(player!==target&&get.itemtype(target)==='player'&&(card.name==='sha'||get.type(card,false)==='trick')&&
target.countCards('he')&&!target.hasSkillTag('noh')) return [1,0,1,-1];
}
}
}
}, },
}, },
}, },

View File

@ -944,6 +944,14 @@ game.import('character',function(lib,game,ui,get,ai,_status){
}, },
content:function(){ content:function(){
trigger.cancel(); trigger.cancel();
},
ai:{
effect:{
target:function(card,player,target){
if(card.name==='sha'&&!game.hasNature(card)&&target.hasEmptySlot(2)) return 'zeroplayertarget';
if(get.subtype(card)=='equip2'&&target.isEmpty(2)) return [0.6,-0.8];
}
}
} }
}, },
//战役篇蒋钦 //战役篇蒋钦

View File

@ -3804,6 +3804,11 @@ game.import('character',function(lib,game,ui,get,ai,_status){
audio:2, audio:2,
preHidden:true, preHidden:true,
audioname:['sp_lvmeng','re_sunben','re_sunce'], audioname:['sp_lvmeng','re_sunben','re_sunce'],
mod:{
aiOrder:function(player,card,num){
if(get.color(card)==='red'&&get.name(card)==='sha') return get.order({name: 'sha'})+0.15;
}
},
trigger:{ trigger:{
player:'useCardToPlayered', player:'useCardToPlayered',
target:'useCardToTargeted', target:'useCardToTargeted',
@ -3812,6 +3817,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(!(event.card.name=='juedou'||(event.card.name=='sha'&&get.color(event.card)=='red'))) return false; if(!(event.card.name=='juedou'||(event.card.name=='sha'&&get.color(event.card)=='red'))) return false;
return player==event.target||event.getParent().triggeredTargets3.length==1; return player==event.target||event.getParent().triggeredTargets3.length==1;
}, },
locked:false,
frequent:true, frequent:true,
content:function(){ content:function(){
player.draw(); player.draw();
@ -4872,9 +4878,10 @@ game.import('character',function(lib,game,ui,get,ai,_status){
}, },
preHidden:true, preHidden:true,
check:function(event,player){ check:function(event,player){
if(player.countCards('h')<=1) return true; return (player.countCards('h')+2+event.num)<=5||game.hasPlayer(function(target){
return game.hasPlayer(function(current){ return player!==target&&!game.hasPlayer(function(current){
return current!=player&&current.isMinHandcard()&&get.attitude(player,current)>0; return current!==player&&current!==target&&current.countCards('h')<target.countCards('h');
})&&get.attitude(player,target)>0;
}); });
}, },
content:function(){ content:function(){
@ -6276,30 +6283,33 @@ game.import('character',function(lib,game,ui,get,ai,_status){
useShan:true, useShan:true,
effect:{ effect:{
target:function(card,player,target,current){ target:function(card,player,target,current){
if(get.tag(card,'respondShan')){ if(get.tag(card,'respondShan')&&!player.hasSkillTag('directHit_ai',true,{
var hastarget=game.hasPlayer(function(current){ target: target,
return get.attitude(target,current)<0; card: card
}); },true)){
var be=target.countCards('e',{color:'black'}); let club=0,spade=0;
if(target.countCards('h','shan')&&be){ if(game.hasPlayer(function(current){
if(!target.hasSkill('guidao')) return 0; return get.attitude(target,current)<0&&get.damageEffect(current,target,target,'thunder')>0;
return [0,hastarget?target.countCards('he')/2:0]; })){
club=2;
spade=4;
} }
if(target.countCards('h','shan')&&target.countCards('h')>2){ if(!target.isHealthy()) club+=2;
if(!target.hasSkill('guidao')) return 0; if(!club&&!spade) return 1;
return [0,hastarget?target.countCards('h')/4:0]; if(!target.mayHaveShan(player)) return 1-0.1*Math.min(5,target.countCards('hs'));
} if(!target.hasSkillTag('rejudge')) return [1,(club+spade)/4];
if(target.countCards('h')>3||(be&&target.countCards('h')>=2)){ let pos=player.hasSkillTag('viewHandcard',null,target,true)?'hes':'e',better=club>spade?'club':'spade',max=0;
return [0,0]; target.hasCard(function(cardx){
} if(get.suit(cardx)===better){
if(target.countCards('h')==0){ max=2;
return [1.5,0]; return true;
} }
if(target.countCards('h')==1&&!be){ if(spade&&get.color(cardx)==='black') max=1;
return [1.2,0]; },pos);
} if(max===2) return [1,Math.max(club,spade)];
if(!target.hasSkill('guidao')) return [1,0.05]; if(max===1) return [1,Math.min(club,spade)];
return [1,Math.min(0.5,(target.countCards('h')+be)/4)]; if(pos==='e') return [1,Math.min(Math.max(1,target.countCards('hs'))*(club+spade)/4,Math.max(club,spade))];
return [1,(club+spade)/4];
} }
} }
} }
@ -7259,17 +7269,20 @@ game.import('character',function(lib,game,ui,get,ai,_status){
useShan:true, useShan:true,
effect:{ effect:{
target:function(card,player,target,current){ target:function(card,player,target,current){
if(get.tag(card,'respondShan')){ if(get.tag(card,'respondShan')&&!player.hasSkillTag('directHit_ai',true,{
var hastarget=game.hasPlayer(function(current){ target: target,
return get.attitude(target,current)<0; card: card
}); },true)&&game.hasPlayer(function(current){
if(target.countCards('h','shan')&&target.countCards('e',{suit:'spade'})){ return get.attitude(target,current)<0&&get.damageEffect(current,target,target,'thunder')>0;
return [0,hastarget?target.countCards('he')/2:0]; })){
} if(!target.mayHaveShan(player)) return 1-0.1*Math.min(5,target.countCards('hs'));
if(target.countCards('h','shan')){ if(!target.hasSkillTag('rejudge')) return [1,1];
return [1,hastarget?target.countCards('he')/2:0]; let pos=player.hasSkillTag('viewHandcard',null,target,true)?'hes':'e';
} if(target.hasCard(function(cardx){
return [1,target.countCards('h')/4]; return get.suit(cardx)==='spade';
},pos)) return [1,4];
if(pos==='e') return [1,Math.min(4,1+0.75*Math.max(1,target.countCards('hs')))];
return [1,1];
} }
} }
} }

View File

@ -10553,6 +10553,22 @@ game.import('character',function(lib,game,ui,get,ai,_status){
content:function(){ content:function(){
player.draw(2+get.sgn(trigger.player.hp-player.hp)); player.draw(2+get.sgn(trigger.player.hp-player.hp));
}, },
ai:{
effect:{
target:function(card,player,target){
if(get.itemtype(player)!=='player'||player===target) return 1;
let num=1,ds=2+get.sgn(player.hp-target.hp);
if(player===_status.currentPhase&&_status.currentPhase.group==='qun'&&target.hasZhuSkill('yuwei',player)) num=2;
if(target.getHistory('gain',function(evt){
return evt.getParent(2).name==='shiyuan'&&evt.cards.length===ds;
}).length>=num) return 1;
let name=get.name(card);
if(get.tag(card,'lose')||name==='huogong'||name==='juedou'||name==='tiesuo') return [1,ds];
if(!target.hasFriend()) return 1;
return [1,0.8*ds];
}
}
}
}, },
dushi:{ dushi:{
audio:2, audio:2,

View File

@ -10583,6 +10583,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
}, },
content:function(){ content:function(){
"step 0" "step 0"
if(get.mode()!=='identity'||player.identity!=='nei') player.addExpose(0.2);
player.draw(2); player.draw(2);
"step 1" "step 1"
player.chooseCard(2,'he',true,'交给'+get.translation(trigger.player)+'两张牌').set('ai',function(card){ player.chooseCard(2,'he',true,'交给'+get.translation(trigger.player)+'两张牌').set('ai',function(card){
@ -10597,8 +10598,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
trigger.player.storage.xiantu4.push(player); trigger.player.storage.xiantu4.push(player);
}, },
ai:{ ai:{
threaten:1.1, threaten:1.1
expose:0.3
} }
}, },
xiantu1:{audio:true}, xiantu1:{audio:true},

View File

@ -2592,10 +2592,21 @@ game.import('character',function(lib,game,ui,get,ai,_status){
return player!=event.player&&event.num<event.player.hp; return player!=event.player&&event.num<event.player.hp;
}, },
check:function(event,player){ check:function(event,player){
if(get.attitude(player,event.player)>-2) return false; if(event.player.hasSkillTag('nodamage')) return false;
if(player.hp>2) return true; let tj = player.countCards('hs', function (card) {
if(player.hp==2&&event.player.hp<3) return false; return get.name(card) === 'tao' || get.name(card) === 'jiu';
return player.hp>1; }),
att = get.attitude(_status.event.player, event.player),
eff = get.damageEffect(event.player, player, _status.event.player, event.nature),
fd = event.player.hasSkillTag('filterDamage', null, {
player: player,
card: event.card
}),
hp = player.hp + tj;
if(player.storage.tairan2) hp -= player.storage.tairan2;
if(eff <= 0 || fd || att >= -2 || Math.abs(hp) <= 1) return false;
if(hp > 2 || event.player.isLinked() && event.nature && eff > 0) return true;
return !event.player.countCards('hs') || event.player.hp > 2 * event.num && !event.player.hasSkillTag('maixie');
}, },
logTarget:'player', logTarget:'player',
content:function(){ content:function(){
@ -2604,6 +2615,12 @@ game.import('character',function(lib,game,ui,get,ai,_status){
trigger.yimie_num=trigger.player.hp-trigger.num; trigger.yimie_num=trigger.player.hp-trigger.num;
trigger.num=trigger.player.hp; trigger.num=trigger.player.hp;
}, },
ai:{
damageBonus:true,
skillTagFilter:function(player,tag,arg){
return arg && arg.target && arg.target.hp > 1 && player.hp > 1 && get.attitude(player, arg.target) < -2;
}
}
}, },
yimie2:{ yimie2:{
trigger:{player:'damageEnd'}, trigger:{player:'damageEnd'},