Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
  • Loading branch information
ibm2431 committed Mar 11, 2020
2 parents 4f62a7e + 8c15a48 commit 68485af
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions scripts/globals/bcnm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ function findBattlefields(player, npc, itemId)
return 0
end
for k, v in pairs(zbfs) do
if v[3] == itemId and checkReqs(player, npc, v[2], true) then
if v[3] == itemId and checkReqs(player, npc, v[2], true) and not player:battlefieldAtCapacity(v[2]) then
mask = bit.bor(mask,math.pow(2,v[1]))
end
end
Expand Down Expand Up @@ -826,8 +826,7 @@ function TradeBCNM(player, npc, trade, onUpdate)

-- open menu of valid battlefields
local validBattlefields = findBattlefields(player, npc, itemId)
local battlefieldId = getBattlefieldIdByBit(player, validBattlefields)
if validBattlefields ~= 0 and not player:battlefieldAtCapacity(battlefieldId) then
if validBattlefields ~= 0 then
if not onUpdate then
player:startEvent(32000, 0, 0, 0, validBattlefields, 0, 0, 0, 0)
end
Expand All @@ -842,7 +841,6 @@ end
-----------------------------------------------

function EventTriggerBCNM(player, npc)

-- player is in battlefield and clicks to leave
if player:getBattlefield() then
player:startEvent(32003)
Expand All @@ -851,9 +849,9 @@ function EventTriggerBCNM(player, npc)
-- player wants to register a new battlefield
elseif not player:hasStatusEffect(tpz.effect.BATTLEFIELD) then
local mask = findBattlefields(player, npc, 0)

-- mask = 268435455 -- uncomment to open menu with all possible battlefields
local battlefieldId = getBattlefieldIdByBit(player, mask)
if mask ~= 0 and not player:battlefieldAtCapacity(battlefieldId) then
if mask ~= 0 then
player:startEvent(32000, 0, 0, 0, mask, 0, 0, 0, 0)
return true
end
Expand Down

0 comments on commit 68485af

Please sign in to comment.