x003018_g_scriptId = 003018

x003018_g_ActivityId = 2

--大本营和两个守护
x003018_g_BaseFlagId = {226027, 226025, 226026}

--小怪(rolebaseId)
x003018_g_MonsterId = {}
x003018_g_MonsterId[1] = 226001
x003018_g_MonsterId[2] = 226002
x003018_g_MonsterId[3] = 226003
x003018_g_MonsterId[4] = 226004
x003018_g_MonsterId[5] = 226005
x003018_g_MonsterId[6] = 226006
x003018_g_MonsterId[7] = 226007
x003018_g_MonsterId[8] = 226008

--精英(rolebaseId)
x003018_g_JingYingId = {} 
x003018_g_JingYingId[1] = 226009
x003018_g_JingYingId[2] = 226010
x003018_g_JingYingId[3] = 226011
x003018_g_JingYingId[4] = 226012
x003018_g_JingYingId[5] = 226013
x003018_g_JingYingId[6] = 226014
x003018_g_JingYingId[7] = 226015
x003018_g_JingYingId[8] = 226016

 --BossRoleBaseId
x003018_g_BossId = {}
x003018_g_BossId[1] = 226017
x003018_g_BossId[2] = 226018
x003018_g_BossId[3] = 226019
x003018_g_BossId[4] = 226020
x003018_g_BossId[5] = 226021
x003018_g_BossId[6] = 226022
x003018_g_BossId[7] = 226023
x003018_g_BossId[8] = 226024

--空降精英RoleBaseId
x003018_g_SpecialMonsterId = {}
x003018_g_SpecialMonsterId[1] = 226009
x003018_g_SpecialMonsterId[2] = 226010

x003018_g_GroupPoint = 4600   

x003018_g_TimeOutPoint = 60     --时间到没打完的分数

x003018_g_PointRate = {}            --分数加成
x003018_g_PointRate[1] = {90, 50}   --(分数，加成百分比（50表示50%）)
x003018_g_PointRate[2] = {80, 20}
x003018_g_PointRate[3] = {60, 0}

x003018_g_RewardId = -1       --等级最低的奖励Id
x003018_g_MailId = 5                --背包满了邮件Id
x003018_g_Money = 1000 -- 帮贡

x003018_g_GuildMoneyItemId = 102101204 --给所有人发送势力商店货币

x003018_g_TransformBuffId = 4600

x003018_g_TimeOutWinTip = 10424
x003018_g_ChannalGuild = 3


function x003018_OnActivityStart(scene, curTime, idx)
    if GetGuildActivity(scene,x003018_g_ActivityId) then
        local point = x003018_g_TimeOutPoint
        x003018_ActivityEnd(scene, 0, point)
    end
end

function x003018_ActivityEnd(scene, win, point)
    local guid = GetGuildSceneGuildGuid(scene)
    SendChannalMessage(scene, x003018_g_ChannalGuild, x003018_g_TimeOutWinTip, guid)

    local rate = x003018_GetPointRate(point)
    SetGuildDefenceBattleEnd(scene, win, point, rate, x003018_g_Money, x003018_g_RewardId, x003018_g_MailId,x003018_g_GuildMoneyItemId)
    x003018_ClearAllMonster(scene)
end

function x003018_GetPointRate(point)
    for i = 1 ,#x003018_g_PointRate do
        if point >= x003018_g_PointRate[i][1] then
            return x003018_g_PointRate[i][2]
        end
    end

    return 0
end

function x003018_ClearAllMonster(scene)
    for i=1,#x003018_g_BaseFlagId do 
        DeleMonsterByRoleId(scene, x003018_g_BaseFlagId[i])
    end

    for i = 1, #x003018_g_MonsterId do
        DeleMonsterByRoleId(scene, x003018_g_MonsterId[i])
    end

    for i = 1, #x003018_g_JingYingId do
        DeleMonsterByRoleId(scene, x003018_g_JingYingId[i])
    end

    for i = 1, #x003018_g_SpecialMonsterId do
        DeleMonsterByRoleId(scene, x003018_g_SpecialMonsterId[i])
    end

    for i = 1, #x003018_g_BossId do
        DeleMonsterByRoleId(scene, x003018_g_BossId[i])
    end

    RemoveSceneBuffById(scene, x003018_g_GroupPoint)
end