魔兽地图编辑器吧 关注:65,201贴子:3,838,562
  • 14回复贴,共1

塔防游戏如何制作物品锁

只看楼主收藏回复

塔防游戏里,当玩家使用物品锁的功能时,一定区域内的物品其他玩家不能捡起,当玩家打开物品锁的功能时,全部玩家都可以捡起该区域的物品,这物品锁具体是怎么写触发的


IP属地:广东来自iPhone客户端1楼2021-12-20 08:47回复
    掉落物品时就记录归属玩家,拾取时检查所属玩家及物品锁开关


    IP属地:浙江2楼2021-12-20 09:27
    收起回复
      广告
      立即查看
      用一个开关技能模拟物品锁
      当物品被捡起
      判断玩家
      判断物品在指定区域
      判断物品锁技能开关
      命令丢弃物品或者无动作
      我拍脑袋想出来的不一定对。


      IP属地:甘肃来自Android客户端3楼2021-12-20 11:24
      收起回复
        给物品加自定义值,不匹配就丢弃


        IP属地:江苏来自Android客户端5楼2021-12-20 22:56
        收起回复
          library ItemProtect requires Reset
          function DroupItemConditions takes nothing returns boolean
          return ((GetSpellAbilityId() == 'A0EN'))
          endfunction
          function ItemProtectConditions takes nothing returns boolean
          return (((GetUnitTypeId(GetManipulatingUnit()) == 'h003') or (IsUnitType(GetManipulatingUnit(), UNIT_TYPE_HERO) == true)))
          endfunction
          function ItemProtectActions takes nothing returns nothing
          if ((GetItemUserData(GetManipulatedItem()) == 0)) then
          call SetItemUserData( GetManipulatedItem(), ( GetPlayerId(GetOwningPlayer(GetManipulatingUnit())) + 1 ) )
          return
          else
          if ((GetItemUserData(GetManipulatedItem()) != ( GetPlayerId(GetOwningPlayer(GetManipulatingUnit())) + 1 ))) then
          call DroupItem( GetManipulatedItem(), GetManipulatingUnit() )
          call DisplayTextToPlayer( GetOwningPlayer(GetManipulatingUnit()), 0, 0, "|cffff0000这个物品不是你的,不能拾取!|r" )
          return
          endif
          endif
          endfunction
          function DroupItemActions takes nothing returns nothing
          local item it =GetSpellTargetItem()
          if (((GetItemUserData(it) == 1) or (GetItemUserData(it) == 2) or (GetItemUserData(it) == 3) or (GetItemUserData(it) == 4) or (GetItemUserData(it) == 5))) then
          if ((GetItemUserData(it) == ( GetPlayerId(GetTriggerPlayer()) + 1 ))) then
          call SetItemUserData( it, 0 )
          call DisplayTextToPlayer( GetOwningPlayer(GetTriggerUnit()), 0, 0, "|cff00ff00物品已经解封。|r" )
          return
          else
          call DisplayTextToPlayer( GetOwningPlayer(GetTriggerUnit()), 0, 0, ( "|cffff0000不能解封" + ( GetPlayerName(Player(GetItemUserData(it)-1)) + "的物品。|r" ) ) )
          return
          endif
          else
          call DisplayTextToPlayer( GetOwningPlayer(GetTriggerUnit()), 0, 0, "|cffff0000不能解封不在保护状态中的物品。|r" )
          endif
          set it =null
          endfunction
          //===========================================================================
          function InitTrig_ItemProtect takes nothing returns nothing
          set UnitPickItem = CreateTrigger()
          set UnitSetItem = CreateTrigger()
          call TriggerRegisterAnyUnitEvent(UnitSetItem, EVENT_PLAYER_UNIT_SPELL_EFFECT )
          call TriggerAddCondition(UnitSetItem, Condition(function DroupItemConditions))
          call TriggerAddAction(UnitSetItem, function DroupItemActions)
          call TriggerRegisterAnyUnitEvent( UnitPickItem, EVENT_PLAYER_UNIT_PICKUP_ITEM )
          call TriggerAddCondition(UnitPickItem, Condition(function ItemProtectConditions))
          call TriggerAddAction(UnitPickItem, function ItemProtectActions)
          endfunction
          endlibrary
          LZ自己看着改吧 我写的 一个保护物品的


          IP属地:浙江7楼2021-12-25 17:20
          回复
            多谢大佬,虽然我看不懂,还是菜鸟中


            IP属地:广东来自iPhone客户端8楼2022-01-01 09:51
            回复