|
| 1 | +-- PLAYER_EVENT_ON_LOGIN = 3, // (event, player) |
| 2 | +-- ELUNA_EVENT_ON_LUA_STATE_OPEN = 33, // (event) - triggers after all scripts are loaded |
| 3 | + |
| 4 | +local PLAYER_EVENT_ON_LOGIN = 3 |
| 5 | +local ELUNA_EVENT_ON_LUA_STATE_OPEN = 33 |
| 6 | + |
| 7 | +local position = 0 |
| 8 | +local camCharName = "Chromie" -- Only character to be teleported around |
| 9 | +local delay = 300000 -- in ms. 300000 = 5min |
| 10 | +local chatDelay = 15000 -- in ms. 15000 = 15sec |
| 11 | +local minMoney = 20000 -- money in copper 20000 = 2 gold |
| 12 | +local maxMoney = 50000 -- money in copper 50000 = 5 gold |
| 13 | + |
| 14 | +local HasFound = {} |
| 15 | + |
| 16 | +-- positions: 1) Shattrath, 2) Dark Portal |
| 17 | +local mapId = { 530, 0} |
| 18 | +local x = { -1882, -11826} |
| 19 | +local y = { 5296, -3196} |
| 20 | +local z = { 3, -25.6} |
| 21 | +local o = { 0.33, 3.25} |
| 22 | + |
| 23 | +local RandomChats1 = { |
| 24 | +"Oh hello, ", |
| 25 | +"Greetings, " |
| 26 | +} |
| 27 | + |
| 28 | +local Random Chats2 = { |
| 29 | +"! Thank you for keeping me company.", |
| 30 | +"! I appreciate you being around." |
| 31 | +} |
| 32 | + |
| 33 | +--calculates the amounts of time an event should be registered |
| 34 | +local function GetAmount() |
| 35 | + local val = (delay / chatDelay) - 1 |
| 36 | + if val < 1 then |
| 37 | + PrintError("Time between Chats is too small in cCamera teleport Lua.") |
| 38 | + end |
| 39 | +end |
| 40 | + |
| 41 | +local function ScheduleTPLogin( _, player ) |
| 42 | + if player:GetName() == camCharName then |
| 43 | + ScheduleTeleport( player ) |
| 44 | + end |
| 45 | +end |
| 46 | + |
| 47 | +local function ScheduleTPReload ( _ ) |
| 48 | + local player = GetPlayerByName( name ) |
| 49 | + ScheduleTeleport( player ) |
| 50 | + -- wipe players having found Chromie already. |
| 51 | + HasFound = {} |
| 52 | +end |
| 53 | + |
| 54 | +local function GiveReward() |
| 55 | + playersInRange = WorldObject:GetPlayersInRange( 10, 2, 1 ) -- 10m range, friendly, alive |
| 56 | + if playersInRange then |
| 57 | + local player = playersInRange[ math.random( #myTable ) ] |
| 58 | + end |
| 59 | + if player then |
| 60 | + if HasFound[ player:GetGUIDLow() ] = 1 then |
| 61 | + chromie:SendUnitSay( "Please step aside, " .. player:GetName() .. ". Let me have a chat with the other time-travellers as well. Thank you!", 0 ) |
| 62 | + end |
| 63 | + local chromime = GetPlayerByName( camCharName ) |
| 64 | + if chromie then |
| 65 | + local id = math.random(#RandomChats) |
| 66 | + chromie:SendUnitSay( RandomChats1[ id ] .. player:GetName(), RandomChats2[ id ], 0 ) |
| 67 | + -- Give Reward |
| 68 | + player:ModifyMoney( math.random( minMoney, maxMoney ) ) |
| 69 | + HasFound[ player:GetGUIDLow() ] = 1 |
| 70 | + else |
| 71 | + PrintError("Could not give reward for the cam rotation.") |
| 72 | + end |
| 73 | + end |
| 74 | +end |
| 75 | + |
| 76 | +local function ScheduleTeleport( player ) |
| 77 | + if player then |
| 78 | + position = position + 1 |
| 79 | + if not mapId[position] then |
| 80 | + position = 1 |
| 81 | + end |
| 82 | + Teleport( mapId[position], x[position], y[position], z[position], o[position]) |
| 83 | + player:RegisterEvent( ScheduleTeleport, delay, 1 ) |
| 84 | + player:RegisterEvent( GiveReward, chatDelay , GetAmount() ) |
| 85 | + else |
| 86 | + PrintError("Could not schedule teleport for the cam rotation.") |
| 87 | + end |
| 88 | +end |
| 89 | + |
| 90 | +RegisterPlayerEvent( PLAYER_EVENT_ON_LOGIN, ScheduleTPLogin ) |
| 91 | +RegisterPlayerEvent( ELUNA_EVENT_ON_LUA_STATE_OPEN, ScheduleTPReload ) |
0 commit comments