--[[ Created by Warren Dawes : contact@warren2go.com ~ 1.0 - 09-05-2015 - Support for RouN ]] BindMapData = { ["RouN"] = { Tick = 60, -- 60 second per tick MinStep = 1, MaxStep = 5, StepData = { [1] = { Duration = 900000, }, -- step at 15 minutes [2] = { Duration = 1800000, }, -- step at 30 minutes [3] = { Duration = 2700000, }, -- step at 45 minutes [4] = { Duration = 3600000, }, -- step at 60 minutes [5] = { Duration = 0, }, -- max step }, VendorData = { InBoothAdd = 60000, -- 60 seconds added per tick to onexit abstate InBoothMaxAdd = 7200000, -- 120 minutes max InBoothAbstate = { [1] = { ExpIndex = "StaVend_1", DropIndex = "StaVend_2", Strength = 1, Duration = 0, }, [2] = { ExpIndex = "StaVend_1", DropIndex = "StaVend_2", Strength = 1, Duration = 0, }, [3] = { ExpIndex = "StaVend_1", DropIndex = "StaVend_2", Strength = 1, Duration = 0, }, [4] = { ExpIndex = "StaVend_1", DropIndex = "StaVend_2", Strength = 1, Duration = 0, }, [5] = { ExpIndex = "StaVend_1", DropIndex = "StaVend_2", Strength = 1, Duration = 0, }, }, }, }, } require( "common" ) MemBlock = {} function HouseZonePost( Handle, MapIndex ) cExecCheck("HouseZonePost") local Var = MemBlock[Handle] if Var == nil then local MapData = BindMapData[MapIndex] if MapData == nil then return ReturnAI.CPP end MemBlock[Handle] = {} Var = MemBlock[Handle] Var.Handle = Handle Var.MapIndex = MapIndex Var.MapData = MapData Var.VendorData = MapData.VendorData Var.PlayerList = {} Var.NearList = {} Var.NextTick = cCurSec() end return MainLoop( Var ) end function MainLoop( Var ) cExecCheck("MainLoop") local CurrentSecond = cCurSec() if Var.NextTick > CurrentSecond then return ReturnAI.CPP end cExecCheck("MainLoop:82") local PlayerList = { cGetPlayerList( Var.MapIndex ) } for k, v in pairs(PlayerList) do local PlayerHandle = PlayerList[k] local PlayerCharNo = cGetCharNo( PlayerHandle ) local PlayerMode = cGetObjectMode( PlayerHandle ) cExecCheck("MainLoop:92") if PlayerMode ~= nil then if cIsObjectDead( PlayerHandle ) == nil then local PlayerData = Var.PlayerList[PlayerCharNo] cExecCheck("MainLoop:98") if PlayerMode == "booth" then local DistBetween = cDistanceSquar( Var.Handle, PlayerHandle ) cExecCheck("MainLoop:104") if DistBetween <= 500000 then if PlayerData == nil then cExecCheck("MainLoop:109") Var.PlayerList[PlayerCharNo] = {} PlayerData = Var.PlayerList[PlayerCharNo] PlayerData.Handle = PlayerHandle PlayerData.Duration = 0 PlayerData.Step = Var.MapData.MinStep end cExecCheck("MainLoop:120") PlayerData.Checked = CurrentSecond PlayerData.InVendor = true PlayerData.Expire = false PlayerData.Handle = PlayerHandle cExecCheck("MainLoop:124") if PlayerData.Duration < Var.VendorData.InBoothMaxAdd then PlayerData.Duration = PlayerData.Duration + Var.VendorData.InBoothAdd cAssertLog( "AddDuration = " .. PlayerData.Duration ) end cExecCheck("MainLoop:130") if PlayerData.Step < Var.MapData.MaxStep then local StepDuration = Var.MapData.StepData[PlayerData.Step] cExecCheck("MainLoop:135") if PlayerData.Duration >= StepDuration.Duration then PlayerData.Step = PlayerData.Step + 1 cAssertLog( "AddStep = " .. PlayerData.Step ) end end cExecCheck("MainLoop:142") MainSetAbstate( Var, PlayerData ) end end end end end -- This cant iterate like this, key is charno for k, v in pairs(Var.PlayerList) do cExecCheck("MainLoop:152") if v.Checked ~= CurrentSecond then cExecCheck("MainLoop:154") v.InVendor = false v.Expire = true if v.Expire then v.Duration = v.Duration - Var.VendorData.InBoothAdd cAssertLog( "RemoveDuration = " .. v.Duration ) if v.Duration <= 0 then v.Duration = 0 v.Step = Var.MapData.MinStep else if v.Step == Var.MapData.MinStep then v.Duration = 0 v.Step = Var.MapData.MinStep elseif v.Step > Var.MapData.MinStep then local StepDuration = Var.MapData.StepData[v.Step - 1] cExecCheck("MainLoop:175") if v.Duration <= StepDuration.Duration then v.Step = v.Step - 1 cAssertLog( "RemoveStep = " .. v.Step ) end end end end end end cExecCheck("MainLoop:160") Var.NextTick = CurrentSecond + Var.MapData.Tick return ReturnAI.CPP end function MainSetAbstate( Var, PlayerData ) cExecCheck("MainSetAbstate") if PlayerData.Duration > 0 then cSetAbstate( PlayerData.Handle, Var.VendorData.InBoothAbstate[PlayerData.Step].ExpIndex, Var.VendorData.InBoothAbstate[PlayerData.Step].Strength, Var.VendorData.InBoothAbstate[PlayerData.Step].Duration + PlayerData.Duration ) cSetAbstate( PlayerData.Handle, Var.VendorData.InBoothAbstate[PlayerData.Step].DropIndex, Var.VendorData.InBoothAbstate[PlayerData.Step].Strength, Var.VendorData.InBoothAbstate[PlayerData.Step].Duration + PlayerData.Duration ) end end