太阳神三国杀lua吧 关注:2,644贴子:73,500
  • 2回复贴,共1

求助,关于旧版ai的格式

只看楼主收藏回复

抄写技能手册的lua技能,采用lua里的ai技能换名,有些发动有些不发动,格式该怎样换呢?


IP属地:安徽1楼2020-03-06 00:08回复
    比如这是英魂的lua
    newyinghunCard = sgs.CreateSkillCard{
    name = "newyinghunCard",
    target_fixed = false,
    will_throw = true,
    on_effect = function(self, effect)
    local source = effect.from
    local dest = effect.to
    local x = source:getLostHp() + 1
    local room = source:getRoom()
    local good = false
    if x == 1 then
    dest:drawCards(1)
    room:askForDiscard(dest, self:objectName(), 1, 1, false, true);
    good = true
    else
    local choice = room:askForChoice(source, self:objectName(), "d1tx+dxt1")
    if choice == "d1tx" then
    dest:drawCards(1)
    x = math.min(x, dest:getCardCount(true))
    room:askForDiscard(dest, self:objectName(), x, x, false, true)
    good = false
    else
    dest:drawCards(x)
    room:askForDiscard(dest, self:objectName(), 1, 1, false, true)
    good = true
    end
    end
    if good then
    room:setEmotion(dest, "good")
    else
    room:setEmotion(dest, "bad")
    end
    end
    }
    newyinghunVS = sgs.CreateViewAsSkill{
    name = "newyinghun",
    n = 0,
    view_as = function(self, cards)
    return newyinghunCard:clone()
    end,
    enabled_at_play = function(self, player)
    return false
    end,
    enabled_at_response = function(self, player, pattern)
    return pattern == "@@newyinghun"
    end
    }
    newyinghun = sgs.CreateTriggerSkill{
    name = "newyinghun",
    frequency = sgs.Skill_NotFrequent,
    events = {sgs.EventPhaseStart},
    view_as_skill = newyinghunVS,
    on_trigger = function(self, event, player, data)
    local room = player:getRoom()
    room:askForUseCard(player, "@@newyinghun", "@yinghun")
    return false
    end,
    can_trigger = function(self, target)
    if target then
    if target:isAlive() and target:hasSkill(self:objectName()) then
    if target:getPhase() == sgs.Player_Start then
    return true
    end
    end
    end
    return false
    end
    }


    IP属地:安徽3楼2020-03-06 00:09
    回复
      2026-01-09 16:15:04
      广告
      不感兴趣
      开通SVIP免广告
      这是林包的ai
      sgs.ai_skill_choice.yinghun = function(self, choices)
      return self.yinghunchoice
      end
      sgs.ai_skill_playerchosen.yinghun = function(self, targets)
      if self.player:hasFlag("AI_doNotInvoke_yinghun") then
      self.player:setFlags("-AI_doNotInvoke_yinghun")
      return nil
      end
      local x = self.player:getLostHp()
      local n = x - 1
      self:updatePlayers()
      if x == 1 and #self.friends == 1 then
      for _, enemy in ipairs(self.enemies) do
      if hasManjuanEffect(enemy) then
      return enemy
      end
      end
      return nil
      end
      self.yinghun = nil
      local player = self:AssistTarget()
      if x == 1 then
      self:sort(self.friends_noself, "handcard")
      self.friends_noself = sgs.reverse(self.friends_noself)
      for _, friend in ipairs(self.friends_noself) do
      if self:hasSkills(sgs.lose_equip_skill, friend) and friend:getCards("e"):length() > 0
      and not hasManjuanEffect(friend) then
      self.yinghun = friend
      break
      end
      end
      if not self.yinghun then
      for _, friend in ipairs(self.friends_noself) do
      if friend:hasSkills("tuntian+zaoxian") and not hasManjuanEffect(friend) then
      self.yinghun = friend
      break
      end
      end
      end
      if not self.yinghun then
      for _, friend in ipairs(self.friends_noself) do
      if self:needToThrowArmor(friend) and not hasManjuanEffect(friend) then
      self.yinghun = friend
      break
      end
      end
      end
      if not self.yinghun then
      for _, enemy in ipairs(self.enemies) do
      if hasManjuanEffect(enemy) then
      return enemy
      end
      end
      end
      if not self.yinghun and player and not hasManjuanEffect(player) and player:getCardCount(true) > 0 and not self:needKongcheng(player, true) then
      self.yinghun = player
      end
      if not self.yinghun then
      for _, friend in ipairs(self.friends_noself) do
      if friend:getCards("he"):length() > 0 and not hasManjuanEffect(friend) then
      self.yinghun = friend
      break
      end
      end
      end
      if not self.yinghun then
      for _, friend in ipairs(self.friends_noself) do
      if not hasManjuanEffect(friend) then
      self.yinghun = friend
      break
      end
      end
      end
      elseif #self.friends > 1 then
      self:sort(self.friends_noself, "chaofeng")
      for _, friend in ipairs(self.friends_noself) do
      if self:hasSkills(sgs.lose_equip_skill, friend) and friend:getCards("e"):length() > 0
      and not hasManjuanEffect(friend) then
      self.yinghun = friend
      break
      end
      end
      if not self.yinghun then
      for _, friend in ipairs(self.friends_noself) do
      if friend:hasSkills("tuntian+zaoxian") and not hasManjuanEffect(friend) then
      self.yinghun = friend
      break
      end
      end
      end
      if not self.yinghun then
      for _, friend in ipairs(self.friends_noself) do
      if self:needToThrowArmor(friend) and not hasManjuanEffect(friend) then
      self.yinghun = friend
      break
      end
      end
      end
      if not self.yinghun and #self.enemies > 0 then
      local wf
      if self.player:isLord() then
      if self:isWeak() and (self.player:getHp() < 2 and self:getCardsNum("Peach") < 1) then
      wf = true
      end
      end
      if not wf then
      for _, friend in ipairs(self.friends_noself) do
      if self:isWeak(friend) then
      wf = true
      break
      end
      end
      end
      if not wf then
      self:sort(self.enemies, "chaofeng")
      for _, enemy in ipairs(self.enemies) do
      if enemy:getCards("he"):length() == n
      and not self:doNotDiscard(enemy, "nil", true, n) then
      self.yinghunchoice = "d1tx"
      return enemy
      end
      end
      for _, enemy in ipairs(self.enemies) do
      if enemy:getCards("he"):length() >= n
      and not self:doNotDiscard(enemy, "nil", true, n)
      and self:hasSkills(sgs.cardneed_skill, enemy) then
      self.yinghunchoice = "d1tx"
      return enemy
      end
      end
      end
      end
      if not self.yinghun and player and not hasManjuanEffect(player) and not self:needKongcheng(player, true) then
      self.yinghun = player
      end
      if not self.yinghun then
      self.yinghun = self:findPlayerToDraw(false, n)
      end
      if not self.yinghun then
      for _, friend in ipairs(self.friends_noself) do
      if not hasManjuanEffect(friend) then
      self.yinghun = friend
      break
      end
      end
      end
      if self.yinghun then self.yinghunchoice = "dxt1" end
      end
      if not self.yinghun and x > 1 and #self.enemies > 0 then
      self:sort(self.enemies, "handcard")
      for _, enemy in ipairs(self.enemies) do
      if enemy:getCards("he"):length() >= n
      and not self:doNotDiscard(enemy, "nil", true, n) then
      self.yinghunchoice = "d1tx"
      return enemy
      end
      end
      self.enemies = sgs.reverse(self.enemies)
      for _, enemy in ipairs(self.enemies) do
      if not enemy:isNude()
      and not (self:hasSkills(sgs.lose_equip_skill, enemy) and enemy:getCards("e"):length() > 0)
      and not self:needToThrowArmor(enemy)
      and not enemy:hasSkills("tuntian+zaoxian") then
      self.yinghunchoice = "d1tx"
      return enemy
      end
      end
      for _, enemy in ipairs(self.enemies) do
      if not enemy:isNude()
      and not (self:hasSkills(sgs.lose_equip_skill, enemy) and enemy:getCards("e"):length() > 0)
      and not self:needToThrowArmor(enemy)
      and not (enemy:hasSkills("tuntian+zaoxian") and x < 3 and enemy:getCards("he"):length() < 2) then
      self.yinghunchoice = "d1tx"
      return enemy
      end
      end
      end
      return self.yinghun
      end
      sgs.ai_skill_choice.yinghun = function(self, choices)
      return self.yinghunchoice
      end
      sgs.ai_playerchosen_intention.yinghun = function(self, from, to)
      if from:getLostHp() > 1 then return end
      local intention = -80
      if hasManjuanEffect(to) then intention = -intention end
      sgs.updateIntention(from, to, intention)
      end
      sgs.ai_choicemade_filter.skillChoice.yinghun = function(self, player, promptlist)
      local to
      for _, p in sgs.qlist(self.room:getOtherPlayers(player)) do
      if p:hasFlag("YinghunTarget") then
      to = p
      break
      end
      end
      local choice = promptlist[#promptlist]
      local intention = (choice == "dxt1") and -80 or 80
      if to then sgs.updateIntention(player, to, intention) end
      end
      local function getLowerBoundOfHandcard(self)
      local least = math.huge
      local players = self.room:getOtherPlayers(self.player)
      for _, player in sgs.qlist(players) do
      least = math.min(player:getHandcardNum(), least)
      end
      return least
      end
      local function getBeggar(self)
      local least = getLowerBoundOfHandcard(self)
      self:sort(self.friends_noself)
      for _, friend in ipairs(self.friends_noself) do
      if friend:getHandcardNum() == least and not hasManjuanEffect(friend) then
      return friend
      end
      end
      for _, player in sgs.qlist(self.room:getOtherPlayers(self.player)) do
      if player:getHandcardNum() == least then
      return player
      end
      end
      end
      换名没用


      IP属地:安徽4楼2020-03-06 00:10
      回复