Witam posiadam skrypt castle by kawon wszystko ładnie działa do momentu gdy pojawi się boss ;P
ponieważ jak boss sie pojawia i go zabijamy to nikt nie dostaje zamku...
za pomoc w tym skrypcie dam rep++
oto link do tematu z tym systemem http://otland.net/f82/talkactions-globalevents-lib-monsters-castle-war-system-maps-111115/
a oto mój lib czyli plik gdzie sie wszystko ustawia:
ponieważ jak boss sie pojawia i go zabijamy to nikt nie dostaje zamku...
za pomoc w tym skrypcie dam rep++
oto link do tematu z tym systemem http://otland.net/f82/talkactions-globalevents-lib-monsters-castle-war-system-maps-111115/
a oto mój lib czyli plik gdzie sie wszystko ustawia:
PHP:
local castleConfig = {
days = {1,2,3,4,5},
time_1 = 1*60*1000, -- time from start event to fight
time_2 = 40*60*1000, -- time from fight to end event
guildOwnStorage = 17000,
attackersStorage = 17002,
enabledStorage = 17006,
endedStorage = 17007,
leaderLevel = 2500,
membersNeeded = 1,
monster = "Roxon King",
monsterSpawn = {x = 884, y = 624, z = 4},
startAttackers = {
[1] = {x = 857, y = 637, z = 7},
[2] = {x = 905, y = 612, z = 7},
[3] = {x = 906, y = 651, z = 7}
},
gates = {
-- 1 Pozycja Guildi
[1] = {pos = {x = 870, y = 635, z = 7}, itemid = 9533},
[2] = {pos = {x = 870, y = 636, z = 7}, itemid = 9533},
[3] = {pos = {x = 866, y = 628, z = 7}, itemid = 9533},
[4] = {pos = {x = 866, y = 629, z = 7}, itemid = 9533},
[5] = {pos = {x = 866, y = 630, z = 7}, itemid = 9533},
-- 2 Pozycja Guildi
[6] = {pos = {x = 899, y = 516, z = 7}, itemid = 9486},
[7] = {pos = {x = 900, y = 516, z = 7}, itemid = 9486},
[8] = {pos = {x = 901, y = 516, z = 7}, itemid = 9486},
[9] = {pos = {x = 902, y = 516, z = 7}, itemid = 9486},
[10] = {pos = {x = 904, y = 519, z = 7}, itemid = 9486},
[11] = {pos = {x = 905, y = 519, z = 7}, itemid = 9486},
[12] = {pos = {x = 906, y = 519, z = 7}, itemid = 9486},
-- 3 Pozycja Guildi
[13] = {pos = {x = 899, y = 646, z = 7}, itemid = 9485},
[14] = {pos = {x = 900, y = 646, z = 7}, itemid = 9485},
[15] = {pos = {x = 901, y = 646, z = 7}, itemid = 9485},
[16] = {pos = {x = 912, y = 649, z = 7}, itemid = 9533},
[17] = {pos = {x = 912, y = 650, z = 7}, itemid = 9533},
[18] = {pos = {x = 912, y = 651, z = 7}, itemid = 9533},
[19] = {pos = {x = 912, y = 652, z = 7}, itemid = 9533},
},
}
CASTLE_DAYS = {2,5}
function getCastleConfig(value)
if (value ~= nil) then
return castleConfig[value] or false
else
return false
end
end
function removeNotKilledKing(cid)
if isMonster(cid) and getCreatureName(cid) == castleConfig.monster then
doRemoveCreature(cid)
end
return true
end
-- it sux but don`t have idea how to make it better, attackers Index
function Castle_getGuildPos(guildId)
local attackers = Castle_getAttackers()
for i,value in ipairs(attackers) do
if (tonumber(guildId) == tonumber(value)) then
ret = i
end
end
return ret
end
function Castle_enableSaving()
doBroadcastMessage("[ Castle Event Enabled! ]\n\nIf you're a guild leader and you have at least ".. castleConfig.membersNeeded .." members you can sign in your guild by saying !castle in default channel.", MESSAGE_INFO_DESCR)
setGlobalStorageValue(castleConfig.enabledStorage, 1)
--setGlobalStorageValue(castleConfig.endedStorage, 0)
Castle_cleanUp()
addEvent(Castle_startEvent, castleConfig.time_1)
return true
end
function Castle_getAttackers()
local ret = {}
local query = string.explode(getGlobalStorageValue(castleConfig.attackersStorage), ",")
for _,value in ipairs(query) do
if isNumber(value) then
table.insert(ret, value)
end
end
return ret
end
function Castle_startEvent()
setGlobalStorageValue(castleConfig.enabledStorage, 0)
setGlobalStorageValue(castleConfig.endedStorage, 0)
if(#Castle_getAttackers() == 0) then
doBroadcastMessage("[ Castle Event Failed! ]\n\nWe have not attackers!", MESSAGE_INFO_DESCR)
return true
end
doBroadcastMessage("[ Castle Event Fight! ]\n\nEvent has been started. Kill Furox King !!!", MESSAGE_INFO_DESCR)
local monster = doSummonCreature(castleConfig.monster, castleConfig.monsterSpawn)
for _, gate in pairs(castleConfig.gates) do
doRemoveItem(getTileItemById(gate.pos, gate.itemid).uid)
end
addEvent(Castle_endEvent, castleConfig.time_2, false)
addEvent(removeNotKilledKing, castleConfig.time_2, monster)
return true
end
function Castle_endEvent(killed, damages)
local playersOnline = getPlayersOnline()
local dmgCount = 0
local message = ""
local winner = 0
if (getGlobalStorageValue(castleConfig.endedStorage) ~= 1) then
if (killed) then
for _,value in ipairs(Castle_getAttackers()) do
message = message.."\n"..getGuildName(value)..":"..damages[Castle_getGuildPos(value)].." dmg"
if damages[Castle_getGuildPos(value)] > dmgCount then
winner = value
dmgCount = damages[Castle_getGuildPos(value)]
end
end
doBroadcastMessage("[ Castle Event End! ]\n\n> Statistics " .. message .."\nWINNER:"..getGuildName(winner), MESSAGE_INFO_DESCR)
local attackers = Castle_getAttackers()
table.insert(attackers, getGlobalStorageValue(castleConfig.guildOwnStorage))
for _, pid in ipairs(playersOnline) do
if ((isInArray(attackers, getPlayerGuildId(pid)) or getGlobalStorageValue(castleConfig.guildOwnStorage) == getPlayerGuildId(pid)) and not(tonumber(getPlayerGuildId(pid)) == tonumber(winner))) then
doRemoveCondition(pid, CONDITION_INFIGHT)
doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)))
end
end
setGlobalStorageValue(castleConfig.guildOwnStorage, winner)
else
doBroadcastMessage("[ Castle Event End! ]\n\n> Castle has been saved by owner.", MESSAGE_INFO_DESCR)
end
setGlobalStorageValue(castleConfig.endedStorage, 1)
end
Castle_cleanUp()
return true
end
function Castle_cleanUp()
setGlobalStorageValue(castleConfig.attackersStorage, ",")
return true
end
function Castle_getGuildMembers(guildId)
local playersOnline = getPlayersOnline()
local members = {}
for _, pid in ipairs(playersOnline) do
if (getPlayerGuildId(pid) == guildId) then
table.insert(members, pid)
end
end
return members
end
function Castle_trySave(cid)
if not(getPlayerGuildLevel(cid) == GUILDLEVEL_LEADER) then
doPlayerSendCancel(cid, "Sorry, but you have to be a leader of guild.")
return true
end
if (getGlobalStorageValue(castleConfig.enabledStorage) ~= 1) then
doPlayerSendCancel(cid, "Sorry, but it's not time yet.")
return true
end
if (getPlayerLevel(cid) < castleConfig.leaderLevel) then
doPlayerSendCancel(cid, "Sorry, but your level is too low.")
return true
end
local players = Castle_getGuildMembers(getPlayerGuildId(cid))
if (#players == 1) then
doPlayerSendCancel(cid, "Sorry, but you haven't any online members in guild.")
return true
end
if (#players < castleConfig.membersNeeded) then
doPlayerSendCancel(cid, "Sorry, but you need at least ".. castleConfig.membersNeeded .." guild members online.")
return true
end
if (tonumber(getGlobalStorageValue(castleConfig.guildOwnStorage)) == tonumber(getPlayerGuildId(cid))) then
doPlayerSendCancel(cid, "Your guild should protect Castle, not attack.")
return true
end
if (#Castle_getAttackers() == 3) then
doPlayerSendCancel(cid, "Sorry, we have already 3 attacking guilds.")
return true
end
if (isInArray(Castle_getAttackers(), getPlayerGuildId(cid))) then
doPlayerSendCancel(cid, "Be patient, war will start in a few minutes.")
return true
end
setGlobalStorageValue(castleConfig.attackersStorage, getGlobalStorageValue(castleConfig.attackersStorage)..getPlayerGuildId(cid)..",")
doBroadcastMessage("[ Castle Event Info ]\n\nGuild ".. getPlayerGuildName(cid) .." will fight for Castle.\nAttackers: ".. #Castle_getAttackers() .." / 3", MESSAGE_INFO_DESCR)
for i, pid in ipairs(getPlayersOnline()) do
if (isInArray(getPlayerGuildId(cid), getPlayerGuildId(pid))) then
doTeleportThing(pid, castleConfig.startAttackers[#Castle_getAttackers()])
end
end
return true
end