Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Lazy_Peon = {
- ENTRY_LAZY_PEON = 10556,
- ENTRY_LUMBERPILE = 175784,
- SAY_PEON_AWAKE = {
- "Just was resting eyes! Back to work now!",
- "OK boss, I get back to tree-hitting.",
- "Ow! OK, I'll get back to work, %s!",
- },
- SAY_PEON_ASLEEP = "Sleepy... so sleepy...",
- SPELL_PEON_SLEEP = 17743,
- SPELL_PEON_AWAKEN = 19938,
- };
- function Lazy_Peon.OnSpawn(event, creature)
- Lazy_Peon.Reset(creature)
- creature:SetData(StopSleepingTimer, math.random(30000, 120000))
- end
- function Lazy_Peon.Reset(creature)
- local reset, stop = creature:GetData(ResetSleepingTimer), creature:GetData(StopSleepingTimer)
- if (sleep) then
- creature:RemoveEventById(sleep)
- creature:SetData(ResetSleepingTimer, nil)
- end
- if (stop) then
- creature:RemoveEventById(stop)
- end
- creature:SetData(StopSleepingTimer, creature:RegisterEvent(Lazy_Peon.OnStopSleepingTimer, math.random(90000, 120000), 1))
- end
- function Lazy_Peon.OnResetSleepingTimer(eventId, delay, repeats, creature)
- creature:SetData(ResetSleepingTimer, nil)
- -- DoScriptText(SAY_PEON_AWAKE_2, m_creature);
- creature:Emote(EMOTE_STATE_NONE);
- -- EnterEvadeMode();
- end
- function Lazy_Peon.OnStopSleepingTimer(eventId, delay, repeats, creature)
- creature:SetData(StopSleepingTimer, nil)
- Lazy_Peon.StartLumbering(creature, creature)
- end
- function Lazy_Peon.StartLumbering(creature, unit)
- local stop = creature:GetData(StopSleepingTimer)
- if (stop) then
- creature:RemoveEventById(stop)
- creature:SetData(StopSleepingTimer, nil)
- end
- local lumber = creature:GetNearestGameObject(15, Lazy_Peon.ENTRY_LUMBERPILE)
- if(lumber) then
- creature:RemoveAura(Lazy_Peon.SPELL_PEON_SLEEP)
- creature:SetWalk(false)
- local x, y, z = lumber:GetLocation()
- if(unit:GetTypeId() == 4) then -- Player type ID
- local StringSelect = string.format(Lazy_Peon.SAY_PEON_AWAKE[math.random(#Lazy_Peon.SAY_PEON_AWAKE)], unit:GetName())
- creature:SendChatMessageToPlayer(1, 0, StringSelect, unit)
- unit:KilledMonsterCredit(Lazy_Peon.ENTRY_LAZY_PEON)
- creature:MoveTo(1, x, y, z)
- else
- creature:MoveTo(2, x, y, z)
- end
- end
- end
- function Lazy_Peon.OnReachWP(event, creature, movetype, id)
- local stop = creature:GetData(ResetSleepingTimer)
- if (stop) then
- creature:RemoveEventById(stop)
- end
- local ResetTime = id == 1 and 80000 or math.random(30000, 60000)
- creature:SetData(ResetSleepingTimer, creature:RegisterEvent(Lazy_Peon.OnResetSleepingTimer, ResetTime, 1))
- creature:Emote(234) -- EMOTE_STATE_WORK_CHOPWOOD
- end
- function Lazy_Peon.AwakenSpellCast(event, player, spell)
- if(spell:GetEntry() == Lazy_Peon.SPELL_PEON_AWAKEN) then
- local target = spell:GetTarget()
- if(not target:HasAura(Lazy_Peon.SPELL_PEON_SLEEP)) or (not target:GetEntry() == Lazy_Peon.ENTRY_LAZY_PEON) then
- return;
- end
- StartLumbering(target, player)
- end
- end
- RegisterCreatureEvent(Lazy_Peon.ENTRY_LAZY_PEON, 5, Lazy_Peon.OnSpawn)
- RegisterCreatureEvent(Lazy_Peon.ENTRY_LAZY_PEON, 5, Lazy_Peon.OnReachWP)
- RegisterPlayerEvent(5, Lazy_Peon.AwakenSpellCast)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement