R A H
Senior User
- Joined
- May 24, 2014
- Messages
- 1,342
- Reaction score
- 47
Event jest ustawiony na godzine
XX:XX, gdy wybije ta godzina, wyskakuje wiadomo?? na czerwono : Special Exp starts in 10 minutes. If you want join, type: !special join
Wiadomo?? pojawia si? co 1 minute a? do startu wydarzenia.
Gracz ktory chce do??czy?, musi by? w pz i by? w gildi.
Po wpisaniu komendy !special join ka?da osoba trafia do regroup roomu reszty cz?onk?w swojej gildi gdzie jest no logout i pz.
Otrzymuje r?wnie? wiadomo?? :
You have joined to the Special. You were teleported to the regroup room. If you want leave this event, type : !special leave.
Zapisy trwaj? 10 minut.
Gdy minie czas zapisow, wysyla gildie z regroup rooma na X ekipy (zale?nie od tego ile gildi si? zapisze), do losowych budynk?w, maja tez non pvp dla swojej gildi.
Przydziela graczom ich kolor i nie maja mo?liwo?ci zmiany outfita/koloru podczas wydarzenia.
Wy?wietla si? wiadomo?? : Special Exp has been started.
Walka dotad az jedna druzyna nie pozostanie na arenie.
Gdy jaki? gracz zginie nie traci skilli/do?wiadczenia i wraca do temple.
Gdy ostatnia gildia b?dzie na "arenie". Cala gildia z areny trafia do g??wnego temple otsa, gildia z wygranej dro?yny otrzymuje dost?p do special exp (!specialexp).
Osoby kt?re padn?, lub wygraj? event respia sie w temple z 1hp.
Code:
<?xml version='1.0' encoding='ISO-8859-1'?>
<mod name='Special Exp' version='1.0' enabled='yes'>
<config name='SpecialExpIslandEvent_conf'><=!=[=C=D=A=T=A=[
healthAfterDeath = 10000
globalStorage = 3000
guildTypeStorage = 3001
specialExpPosition = {x = 1560, y = 599, z = 7}
addRewards = false
rewardItems = {2160, 25, 2152, 25, 2148, 25}
rewardRandomize = true
minAccesToStartEvent = 6
timeDelayToPrepareToStart = 1 -- in minutes
minimumRequiredGuilds = 2
checkProtection = false
-- messages
messageToStart = 'Special Exp starts in %d minute%s. If you want join, type: !special join'
messageHasntGuild = 'You do not belong to any guild.'
messagePlayerNotInProtectionZone = 'You are not in a protection zone!'
messageInRegroupRoom = 'You have joined to the Special. You were teleported to the regroup room. If you want leave this event, type: !special leave.'
messageNotEnoughtGuilds = 'We not have enough guilds to start Special Exp. We have %d guild%s, we need at least ' .. minimumRequiredGuilds .. ' or more to start event. Event are stopped.'
messageStart = 'Special Exp has started.'
messageNoMoreFreeSlots = 'You can\'n join to an event, all slots are busy.'
messageToJoin = '%s has joined to Special Exp. He is %d player who joined to an event. We have %d guild%s in event.'
messageTryToJoin = 'You are already in Special Exp.'
messageEnd = '%s guild win Special Exp, now all members can enter on special exp, just use command: !specialexp.'
messagePlayerAreInFight = 'You are in fight mode. Wait until your fight mode will end.'
colorRed = 94
colorGreen = 81
colorBlue = 87
colorYellow = 79
guildsConfig = {
[1] = {
regroupRoomPosition = {x = 1464, y = 600, z = 7}, -- pozycja roomu startowego
fightRandomPositions = {{x = 1321, y = 651, z = 7}, {x = 1322, y = 651, z = 7}}, -- w jednej z tych pozycji pojawia sie cala gildia
outfit = {lookType = 137, lookHead = colorRed, lookBody = colorRed, lookLegs = colorRed, lookFeet = colorRed, lookAddons = 3}
},
[2] = {
regroupRoomPosition = {x = 1464, y = 619, z = 7}, -- pozycja roomu startowego
fightRandomPositions = {{x = 1396, y = 710, z = 7}, {x = 1397, y = 710, z = 7}}, -- w jednej z tych pozycji pojawia sie cala gildia
outfit = {lookType = 140, lookHead = colorBlue, lookBody = colorBlue, lookLegs = colorBlue, lookFeet = colorBlue, lookAddons = 3}
},
[3] = {
regroupRoomPosition = {x = 1496, y = 619, z = 7}, -- pozycja roomu startowego
fightRandomPositions = {{x = 1403, y = 669, z = 5}, {x = 1404, y = 669, z = 5}}, -- w jednej z tych pozycji pojawia sie cala gildia
outfit = {lookType = 139, lookHead = colorYellow, lookBody = colorYellow, lookLegs = colorYellow, lookFeet = colorYellow, lookAddons = 3}
},
[4] = {
regroupRoomPosition = {x = 1496, y = 600, z = 7}, -- pozycja roomu startowego
fightRandomPositions = {{x = 1305, y = 691, z = 5}, {x = 1306, y = 691, z = 5}}, -- w jednej z tych pozycji pojawia sie cala gildia
outfit = {lookType = 139, lookHead = colorGreen, lookBody = colorGreen, lookLegs = colorGreen, lookFeet = colorGreen, lookAddons = 3}
}
}
maximumRequiredGuilds = #guildsConfig
-- functions, don't change this
SPECIAL_EXP_NO_ACTIVE = 0
SPECIAL_EXP_PREPARE = 1
SPECIAL_EXP_ACTIVE = 2
GUILD_SLOT_NONE = -1
outfitCondition, subId = {}, 100
for i = 1, maximumRequiredGuilds do
outfitCondition[i] = createConditionObject(CONDITION_OUTFIT)
setConditionParam(outfitCondition[i], CONDITION_PARAM_TICKS, -1)
setConditionParam(outfitCondition[i], CONDITION_PARAM_SUBID, subId)
addOutfitCondition(outfitCondition[i], guildsConfig[i].outfit)
end
function doTeleportThingEffect(cid, newPos, afterEffect)
doSendMagicEffect(getThingPos(cid), afterEffect)
return doTeleportThing(cid, newPos, true) and doSendMagicEffect(newPos, afterEffect)
end
function getPlayersGuildId(status, k)
if getStorage(globalStorage) ~= status then
return {}, {}
end
local players, guilds = {}, {}
for _, cid in pairs(getPlayersOnline()) do
local guildId = getPlayerGuildId(cid)
if (k and guildId == k) or
(not k and getCreatureStorage(cid, globalStorage) == status) then
table.insert(players, cid)
if not isInArray(guilds, guildId) then
table.insert(guilds, guildId)
end
end
end
return players, guilds
end
function hasntGuildName(guildList, id)
for _, v in pairs(guildList) do
if v == id then
return false
end
end
return true
end
function getPlayerGuildSlot(id)
local playerCount, guildsCount = getPlayersGuildId(SPECIAL_EXP_PREPARE)
local slotByGuildName = {}
for _, pid in pairs(playerCount) do
local guildId, guildStatus = getPlayerGuildId(pid), getCreatureStorage(pid, guildTypeStorage)
if guildStatus ~= GUILD_SLOT_NONE then
if id and id == guildId then
return guildStatus
end
if hasntGuildName(slotByGuildName, guildId) then
slotByGuildName[guildStatus] = guildId
end
end
end
for i = 1, maximumRequiredGuilds do
if not slotByGuildName[i] then
return i
end
end
return GUILD_SLOT_NONE
end
function checkRegroupRoom(cid)
local playerCount, guildsCount = getPlayersGuildId(SPECIAL_EXP_PREPARE)
doBroadcastMessage(messageToJoin:format(getCreatur eName(cid), #playerCount, #guildsCount, (#guildsCount > 1 and 's' or '')))
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, messageInRegroupRoom)
end
function getFreeGuildSlot(id)
local playerCount, guildsCount = getPlayersGuildId(SPECIAL_EXP_PREPARE)
if #guildsCount >= maximumRequiredGuilds and not isInArray(guildsCount, id) then
return false
end
return true
end
function addPlayerToSpecialExp(cid)
if not isPlayer(cid) or getStorage(globalStorage) ~= SPECIAL_EXP_PREPARE then
return
end
if getCreatureStorage(cid, globalStorage) ~= SPECIAL_EXP_NO_ACTIVE then
return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, messageTryToJoin)
end
local guildId = getPlayerGuildId(cid)
if guildId == 0 then
return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, messageHasntGuild)
end
if checkProtection and not getTilePzInfo(getThingPos(cid)) then
return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, messagePlayerNotInProtectionZone)
end
if not getFreeGuildSlot(guildId) then
return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, messageNoMoreFreeSlots)
end
doCreatureSetStorage(cid, globalStorage, SPECIAL_EXP_PREPARE)
local guildSlot = getPlayerGuildSlot(guildId)
if guildSlot == GUILD_SLOT_NONE then
return doCreatureSetStorage(cid, globalStorage, SPECIAL_EXP_NO_ACTIVE)
end
doCreatureSetStorage(cid, guildTypeStorage, guildSlot)
doTeleportThingEffect(cid, guildsConfig[guildSlot].regroupRoomPosition, CONST_ME_TELEPORT)
checkRegroupRoom(cid)
end
function choose(tableThing)
return tableThing[math.random(#tableThing)]
end
function removePlayerFromSpecialExp(cid, k, removeHealth)
if not isPlayer(cid) or getCreatureStorage(cid, globalStorage) ~= (k and SPECIAL_EXP_ACTIVE or SPECIAL_EXP_PREPARE) then
return false
end
if getCreatureCondition(cid, CONDITION_OUTFIT, subId) then
doRemoveCondition(cid, CONDITION_OUTFIT, subId)
end
if removeHealth then
doCreatureAddHealth(cid, -(getCreatureHealth(cid) - healthAfterDeath))
end
doCreatureSetSkullType(cid, SKULL_NONE)
if getCreatureCondition(cid, CONDITION_INFIGHT) then
doRemoveCondition(cid, CONDITION_INFIGHT)
end
doCreatureSetStorage(cid, globalStorage, SPECIAL_EXP_NO_ACTIVE)
doCreatureSetStorage(cid, guildTypeStorage, GUILD_SLOT_NONE)
doTeleportThingEffect(cid, getPlayerMasterPos(cid), CONST_ME_TELEPORT)
end
function sendPlayerToArena(cid, i, firstSend, pos)
if firstSend and outfitCondition[i] then
doAddCondition(cid, outfitCondition[i])
end
if not pos then
pos = choose(guildsConfig[i].fightRandomPositions)
end
doTeleportThingEffect(cid, pos, CONST_ME_TELEPORT)
local _max = getCreatureMaxHealth(cid) - getCreatureHealth(cid)
doTargetCombatHealth(0, cid, COMBAT_HEALING, _max, _max, CONST_ME_NONE)
return pos
end
function beginSpecialExpEvent()
local playerCount, guildsCount = getPlayersGuildId(SPECIAL_EXP_PREPARE)
for i = 1, #guildsCount do
local players, guilds = getPlayersGuildId(SPECIAL_EXP_PREPARE, guildsCount[i])
local toPosition = nil
for _, cid in pairs(players) do
toPosition = sendPlayerToArena(cid, getCreatureStorage(cid, guildTypeStorage), true, toPosition)
doCreatureSetStorage(cid, globalStorage, SPECIAL_EXP_ACTIVE)
registerCreatureEvent(cid, 'specialExpLogout')
registerCreatureEvent(cid, 'specialExpOutfit')
registerCreatureEvent(cid, 'specialExpStatsChange')
end
end
end
function startSpecialExp(_type, _time)
local status = getStorage(globalStorage)
if _type == SPECIAL_EXP_NO_ACTIVE then
if status ~= SPECIAL_EXP_NO_ACTIVE then
local players, guilds = getPlayersGuildId(status)
for _, pid in pairs(players) do
if not removePlayerFromSpecialExp(pid, true) then
removePlayerFromSpecialExp(pid)
end
end
end
elseif _type == SPECIAL_EXP_PREPARE then
if status == SPECIAL_EXP_ACTIVE then
return
end
_time = _time or timeDelayToPrepareToStart
if _time < timeDelayToPrepareToStart and status ~= SPECIAL_EXP_PREPARE then
return
end
if _time > 0 then
doBroadcastMessage(messageToStart:format(_time, (_time > 1 and 's' or '')))
addEvent(startSpecialExp, 60 * 1000, SPECIAL_EXP_PREPARE, _time - 1)
else
return startSpecialExp(SPECIAL_EXP_ACTIVE)
end
elseif _type == SPECIAL_EXP_ACTIVE then
local playerCount, guildsCount = getPlayersGuildId(SPECIAL_EXP_PREPARE)
if #guildsCount < minimumRequiredGuilds then
startSpecialExp(SPECIAL_EXP_NO_ACTIVE)
return doBroadcastMessage(messageNotEnoughtGuilds:format( #guildsCount, (#guildsCount > 1 and 's' or '')))
end
doBroadcastMessage(messageStart)
beginSpecialExpEvent()
end
doSetStorage(globalStorage, _type)
end
function checkAliveGuilds(name)
local playerCount, guildsCount = getPlayersGuildId(SPECIAL_EXP_ACTIVE)
if #guildsCount <= 1 then
sendRewards(guildsCount[1], name)
for _, cid in pairs(playerCount) do
removePlayerFromSpecialExp(cid, true, true)
end
end
end
function sendRewards(id, name)
if addRewards then
for _, cid in pairs(getPlayersOnline()) do
if getPlayerGuildId(cid) == id then
if rewardRandomize then
local randomItem = math.random(#rewardItems / 2)
doPlayerAddItem(cid, rewardItems[randomItem * 2 - 1], rewardItems[randomItem * 2], true)
else
for i = 1, #rewardItems / 2 do
doPlayerAddItem(cid, rewardItems[i * 2 - 1], rewardItems[i * 2], true)
end
end
end
end
end
doSetStorage(guildTypeStorage, id)
doBroadcastMessage(messageEnd:format(name))
startSpecialExp(SPECIAL_EXP_NO_ACTIVE)
end
]=]=></config>
<event type='login' name='specialExpLogin' event='script'><=!=[=C=D=A=T=A=[
domodlib('SpecialExpIslandEvent_conf')
function onLogin(cid)
doCreatureSetStorage(cid, globalStorage, SPECIAL_EXP_NO_ACTIVE)
doCreatureSetStorage(cid, guildTypeStorage, GUILD_SLOT_NONE)
return true
end
]=]=></event>
<event type='logout' name='specialExpLogout' event='script'><=!=[=C=D=A=T=A=[
domodlib('SpecialExpIslandEvent_conf')
function onLogout(cid)
if getCreatureStorage(cid, globalStorage) ~= SPECIAL_EXP_NO_ACTIVE then
return false
end
return true
end
]=]=></event>
<event type='statschange' name='specialExpStatsChange' event='script'><=!=[=C=D=A=T=A=[
domodlib('SpecialExpIslandEvent_conf')
function onStatsChange(cid, attacker, type, combat, value)
if combat == COMBAT_HEALING or getCreatureStorage(cid, globalStorage) ~= SPECIAL_EXP_ACTIVE then
return true
end
if isCreature(attacker) and getPlayerGuildId(cid) == getPlayerGuildId(attacker) then
return false
end
if value >= getCreatureHealth(cid) then
if not isCreature(attacker) then
return false
end
local _max = getCreatureMaxHealth(cid) - getCreatureHealth(cid)
doTargetCombatHealth(0, cid, COMBAT_HEALING, _max, _max, CONST_ME_NONE)
removePlayerFromSpecialExp(cid, true, true)
checkAliveGuilds(getPlayerGuildName(attacker))
return false
end
return true
end
]=]=></event>
<event type='outfit' name='specialExpOutfit' event='script'><=!=[=C=D=A=T=A=[
domodlib('SpecialExpIslandEvent_conf')
function onOutfit(cid, old, current)
if getCreatureStorage(cid, globalStorage) == SPECIAL_EXP_ACTIVE then
return false
end
return true
end
]=]=></event>
<talkaction words='!special;!specialexp' event='script'><=!=[=C=D=A=T=A=[
domodlib('SpecialExpIslandEvent_conf')
function onSay(cid, words, param, channel)
words = words:lower()
if words == '!specialexp' then
if checkProtection and not getTilePzInfo(getThingPos(cid)) then
return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, messagePlayerNotInProtectionZone)
end
if getCreatureCondition(cid, CONDITION_INFIGHT) then
return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, messagePlayerAreInFight)
end
local status = getStorage(guildTypeStorage)
if status == getPlayerGuildId(cid) then
doTeleportThingEffect(cid, specialExpPosition, CONST_ME_TELEPORT)
end
return true
end
param = param:lower()
if (param == 'start' or param == 'stop') and getPlayerAccess(cid) >= minAccesToStartEvent then
if param == 'start' then
doSetStorage(globalStorage, SPECIAL_EXP_NO_ACTIVE)
end
startSpecialExp(param == 'start' and SPECIAL_EXP_PREPARE or SPECIAL_EXP_NO_ACTIVE)
elseif param == 'join' then
addPlayerToSpecialExp(cid)
elseif param == 'leave' then
removePlayerFromSpecialExp(cid)
end
return true
end
]=]=></talkaction>
<globalevent name='SpecialExpIslandTime' time='17:30' event='script'><=!=[=C=D=A=T=A=[
domodlib('SpecialExpIslandEvent_conf')
function onTimer()
startSpecialExp(SPECIAL_EXP_NO_ACTIVE)
startSpecialExp(SPECIAL_EXP_PREPARE)
return true
end
]=]=></globalevent>
</mod>