-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClippyAssistBCC.lua
678 lines (592 loc) · 21.8 KB
/
ClippyAssistBCC.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
local data = ClippyAssist.data
local CA_Realm = GetRealmName(); --Get Realm for Profile.
local CA_Char = UnitName("player"); --Get char name for profile.
local CAProfile = CA_Realm.." - "..CA_Char;
local animation_queue = {}
local animation_needs_init = true
local is_frame_ready = false
local time_hide_text = GetTime()
---------------------------
-- Convenience Functions --
---------------------------
local function QueueAnimation(animation, callback)
table.insert(animation_queue, {
mode = "normal",
["animation"] = animation,
["callback"] = callback,
})
animation_needs_init = true
end
local function QueueAnimationLoop(animation, callback)
table.insert(animation_queue, {
mode = "loop",
["animation"] = animation,
["callback"] = callback,
})
animation_needs_init = true
end
-- Queue an animation with no callback.
local function SingleAnimation(animation)
QueueAnimation(animation, function() end)
table.insert(animation_queue, {
mode = "loop",
["animation"] = "RestPose",
["callback"] = function() end,
})
end
-- Queue an animation with no callback, *only* if no animations are
-- currently playing already.
local function IdleAnimation(animation)
if #(animation_queue) == 1 and
animation_queue[1].animation == "RestPose"
then
SingleAnimation(animation)
end
end
-------------------------
-- Animation Functions --
-------------------------
-- Initialize the data structures AnimateTexCoords() requires to
-- properly calculate tex coords. Minimal work is performed here.
local function InitTexCoords(
texture, animation,
frameWidth, frameHeight,
callback)
animation_needs_init = false
-- Actual texture path is set on first tex coord update
-- (AnimateTexCoords()), not here (since proper tex coords
-- haven't been calculated yet).
texture.isSet = false
texture.frame = 1
texture.elapsed = 0
texture.cols = math.floor(animation.tex_width / frameWidth)
texture.rows = math.floor(animation.tex_height / frameHeight)
-- Setting tex coords bases dimensions off of the parent's
-- UV-coords, where max (width, height) is (1, 1).
texture.w_col = frameWidth / animation.tex_width
texture.h_row = frameHeight / animation.tex_height
-- Using a callback to handle the "animation finished" event
-- is the most flexible way to do this.
texture.callback = callback
end
-- Moves local texture coordinates of a frame across a spritesheet
-- texture (stop-motion animation).
-- Intended to be called inside a tight OnUpdate() loop.
-- (Based off the code for Blizzard's LFG "eye" searching icon.)
local function AnimateTexCoords(texture, animation, elapsed)
local elapsed_total = elapsed + texture.elapsed
-- If next frame isn't due yet, account for the current update's
-- elapsed time, then return without performing any work.
if texture.isSet and
elapsed_total <= animation.timing[texture.frame]
then
texture.elapsed = elapsed_total
return
end
-- Increment current frame until we reach the one to display.
-- Less efficient than Blizzard's method (which assumes a constant
-- frame time), but allows for variable frame timing.
while texture.frame <= animation.frames and
elapsed_total > animation.timing[texture.frame]
do
elapsed_total = elapsed_total - animation.timing[texture.frame]
texture.frame = texture.frame + 1
end
texture.elapsed = elapsed_total
-- If we've gone past the end of the current animation, we can
-- trigger our callback and then return (w/out doing work to figure
-- out our new tex coords).
if texture.frame > animation.frames then
texture.callback()
return
end
-- Calculate new local texture coordinates.
-- `bottom` is calculated before `top` to make ceil() rounding not
-- require an extra check.
local left = ((texture.frame - 1) % texture.cols) * texture.w_col
local right = left + texture.w_col
local bottom = math.ceil(texture.frame / texture.cols) * texture.h_row
local top = bottom - texture.h_row
texture:SetTexCoord(left, right, top, bottom)
-- This is only called once per animation, on the first frame.
-- Subsequent OnUpdate() calls during the first frame will return
-- early and skip executing this line.
-- This call is delayed until after SetTexCoord() to prevent the
-- frame from flashing entire unset textures.
if not texture.isSet then
texture:SetTexture(animation.path)
texture.isSet = true
end
end
----------------------
-- Main Frame Setup --
----------------------
-- Create and position addon frame.
local frame = CreateFrame("Frame", "ClippyFrame", UIParent)
frame:SetSize(124, 93)
frame:SetPoint("CENTER")
frame:SetFrameStrata("HIGH")
-- Create frame texture and set anchors.
local texture = frame:CreateTexture(nil, "OVERLAY")
frame.texture = texture
texture:SetAllPoints("ClippyFrame")
frame:Show()
-- Set mouse interaction properties of addon frame.
frame:EnableMouse(true)
frame:SetMovable(true)
frame:SetClampedToScreen(true)
frame:RegisterForDrag("LeftButton")
frame:SetScript("OnMouseUp", function(self, button)
IdleAnimation("Wave1")
end)
frame:SetScript("OnDragStart", function(self, button)
self:StartMoving()
IdleAnimation("Wave2")
end)
frame:SetScript("OnDragStop", function(self)
self:StopMovingOrSizing()
ClippyAssist.PositionBalloon()
end)
-- Set up syntactic sugar for handling all events.
ClippyFrame.events = {}
function ClippyFrame_OnEvent(self, event, ...)
ClippyFrame.events[event](self, ...)
end
frame:SetScript("OnEvent", ClippyFrame_OnEvent)
-- Set up animation update logic.
frame:SetScript("OnUpdate", function(self, elapsed)
if #(animation_queue) == 0 then
return
end
if animation_needs_init then
InitTexCoords(
frame.texture,
data[animation_queue[1].animation],
124, 93,
function()
animation_queue[1].callback()
animation_needs_init = true
if #(animation_queue) > 1 or
animation_queue[1].mode == "normal"
then
table.remove(animation_queue, 1)
end
if #(animation_queue) == 0 then
frame.texture:SetTexture(nil)
end
end)
end
AnimateTexCoords(
frame.texture,
data[animation_queue[1].animation],
elapsed)
end)
------------------
-- Text Balloon --
------------------
-- Set up text balloon frame.
local path_balloon_texture = "Interface/AddOns/ClippyAssistBCC/rc/balloon.tga"
local balloon_corner_size = 15
local balloon = CreateFrame("Frame", "ClippyBalloon", frame)
balloon:Hide()
balloon:SetSize(180, 260)
balloon:SetPoint("CENTER")
balloon:SetFrameStrata("HIGH")
-- Corner pieces.
local balloon_slice_TL = balloon:CreateTexture()
balloon_slice_TL:SetPoint("TOPLEFT")
balloon_slice_TL:SetSize(balloon_corner_size, balloon_corner_size)
balloon_slice_TL:SetTexCoord(0.0, 0.3, 0.0, 0.3)
balloon_slice_TL:SetTexture(path_balloon_texture)
local balloon_slice_TR = balloon:CreateTexture()
balloon_slice_TR:SetPoint("TOPRIGHT")
balloon_slice_TR:SetSize(balloon_corner_size, balloon_corner_size)
balloon_slice_TR:SetTexCoord(0.7, 1.0, 0.0, 0.3)
balloon_slice_TR:SetTexture(path_balloon_texture)
local balloon_slice_BL = balloon:CreateTexture()
balloon_slice_BL:SetPoint("BOTTOMLEFT")
balloon_slice_BL:SetSize(balloon_corner_size, balloon_corner_size)
balloon_slice_BL:SetTexCoord(0.0, 0.3, 0.7, 1.0)
balloon_slice_BL:SetTexture(path_balloon_texture)
local balloon_slice_BR = balloon:CreateTexture()
balloon_slice_BR:SetPoint("BOTTOMRIGHT")
balloon_slice_BR:SetSize(balloon_corner_size, balloon_corner_size)
balloon_slice_BR:SetTexCoord(0.7, 1.0, 0.7, 1.0)
balloon_slice_BR:SetTexture(path_balloon_texture)
-- Edge pieces.
local balloon_slice_T = balloon:CreateTexture()
balloon_slice_T:SetPoint("TOPLEFT", balloon_slice_TL, "TOPRIGHT")
balloon_slice_T:SetPoint("BOTTOMRIGHT", balloon_slice_TR, "BOTTOMLEFT")
balloon_slice_T:SetTexCoord(0.3, 0.4, 0.0, 0.3)
balloon_slice_T:SetTexture(path_balloon_texture)
local balloon_slice_L = balloon:CreateTexture()
balloon_slice_L:SetPoint("TOPLEFT", balloon_slice_TL, "BOTTOMLEFT")
balloon_slice_L:SetPoint("BOTTOMRIGHT", balloon_slice_BL, "TOPRIGHT")
balloon_slice_L:SetTexCoord(0.0, 0.3, 0.3, 0.4)
balloon_slice_L:SetTexture(path_balloon_texture)
local balloon_slice_R = balloon:CreateTexture()
balloon_slice_R:SetPoint("TOPLEFT", balloon_slice_TR, "BOTTOMLEFT")
balloon_slice_R:SetPoint("BOTTOMRIGHT", balloon_slice_BR, "TOPRIGHT")
balloon_slice_R:SetTexCoord(0.7, 1.0, 0.3, 0.4)
balloon_slice_R:SetTexture(path_balloon_texture)
local balloon_slice_B = balloon:CreateTexture()
balloon_slice_B:SetPoint("TOPLEFT", balloon_slice_BL, "TOPRIGHT")
balloon_slice_B:SetPoint("BOTTOMRIGHT", balloon_slice_BR, "BOTTOMLEFT")
balloon_slice_B:SetTexCoord(0.3, 0.4, 0.7, 1.0)
balloon_slice_B:SetTexture(path_balloon_texture)
-- Center piece.
local balloon_slice_C = balloon:CreateTexture()
balloon_slice_C:SetPoint("TOPLEFT", balloon_slice_TL, "BOTTOMRIGHT")
balloon_slice_C:SetPoint("BOTTOMRIGHT", balloon_slice_BR, "TOPLEFT")
balloon_slice_C:SetTexCoord(0.3, 0.3, 0.4, 0.4)
balloon_slice_C:SetTexture(path_balloon_texture)
-- Text texture.
balloon.text = balloon:CreateFontString(nil, "OVERLAY")
balloon.text:SetFont("Interface/AddOns/ClippyAssistBCC/rc/ClippySans.ttf", 14)
balloon.text:SetTextColor(0, 0, 0)
balloon.text:SetJustifyH("LEFT")
balloon.text:SetJustifyV("TOP")
balloon.text:SetPoint("TOPLEFT", balloon_slice_C, "TOPLEFT")
balloon.text:SetWidth(balloon_slice_C:GetWidth())
balloon.text:SetText("")
-- Balloon tip frame.
local path_balloon_tip_texture = "Interface/AddOns/ClippyAssistBCC/rc/tip.tga"
local balloon_tip_size = 20
local balloon_tip = CreateFrame("Frame", "BalloonTip", balloon)
balloon_tip:SetSize(balloon_tip_size, balloon_tip_size)
balloon_tip:SetFrameStrata("HIGH")
local balloon_texture = balloon_tip:CreateTexture()
balloon_texture:SetAllPoints()
balloon_texture:SetTexture(path_balloon_tip_texture)
-- Positioning convenience function.
ClippyAssist.PositionBalloon = function()
local x_mid = GetScreenWidth() / 2
local y_mid = GetScreenHeight() / 2
local x_frame, y_frame = frame:GetCenter()
x_frame = x_frame - x_mid
y_frame = y_frame - y_mid
balloon:ClearAllPoints()
if x_frame >= 0 and y_frame >= 0 then
balloon:SetPoint("TOPRIGHT", frame, "BOTTOMLEFT", 100, -10)
balloon_tip:ClearAllPoints()
balloon_tip:SetPoint("BOTTOMLEFT", balloon, "TOP", -15, -2)
balloon_texture:SetTexCoord(0.5, 1.0, 0.0, 0.5)
elseif x_frame >= 0 and y_frame < 0 then
balloon:SetPoint("BOTTOMRIGHT", frame, "TOPLEFT", 80, 5)
balloon_tip:ClearAllPoints()
balloon_tip:SetPoint("TOPLEFT", balloon, "BOTTOM", 25, 2)
balloon_texture:SetTexCoord(0.5, 1.0, 0.5, 1.0)
elseif x_frame < 0 and y_frame < 0 then
balloon:SetPoint("BOTTOMLEFT", frame, "TOPRIGHT", -60, 5)
balloon_tip:ClearAllPoints()
balloon_tip:SetPoint("TOPRIGHT", balloon, "BOTTOM", -20, 2)
balloon_texture:SetTexCoord(0.0, 0.5, 0.5, 1.0)
else --x_frame < 0 and y_frame >= 0
balloon:SetPoint("TOPLEFT", frame, "BOTTOMRIGHT", -80, -10)
balloon_tip:ClearAllPoints()
balloon_tip:SetPoint("BOTTOMRIGHT", balloon, "TOP", -10, -2)
balloon_texture:SetTexCoord(0.0, 0.5, 0.0, 0.5)
end
end
-- Enable custom WeakAura support.
is_frame_ready = true
-------------------------------
-- Custom WeakAura Interface --
-------------------------------
-- Check that Clippy is initialized before attempting to use addon.
function ClippyAssist.isReady()
return is_frame_ready
end
-- Display a speech bubble for the specified duration.
function ClippyAssist.SetText(msg, duration)
balloon.text:SetText(msg)
-- Resize balloon to fit text.
balloon:SetHeight(
balloon.text:GetHeight() +
balloon.text:GetLineHeight() +
2 * balloon_corner_size
)
-- Position balloon depending on Clippy's location.
ClippyAssist.PositionBalloon()
-- Display balloon.
balloon:Show()
IdleAnimation("Explain")
-- Set up hiding for balloon.
time_hide_text = GetTime() + duration
C_Timer.After(duration, function()
balloon:Hide()
balloon.text:SetText("")
end)
end
-- Display a speech bubble for the specified duration with an animation.
function ClippyAssist.SetTextAnimation(msg, animation, duration)
balloon.text:SetText(msg)
-- Resize balloon to fit text.
balloon:SetHeight(
balloon.text:GetHeight() +
balloon.text:GetLineHeight() +
2 * balloon_corner_size
)
-- Position balloon depending on Clippy's location.
ClippyAssist.PositionBalloon()
-- Display balloon.
balloon:Show()
if (animation) then
SingleAnimation(animation)
else
IdleAnimation("Explain")
end
-- Set up hiding for balloon.
time_hide_text = GetTime() + duration
C_Timer.After(duration, function()
balloon:Hide()
balloon.text:SetText("")
end)
end
------------
-- Events --
------------
-- Idle: 10% GetArtsy, 10% Print, 20% GetAttention, 60% Look{direction}
local function AnimateIdle()
local delay = math.random(20, 30)
C_Timer.After(delay, function()
local chance = math.random()
if chance < 0.10 then
IdleAnimation("GetArtsy")
elseif chance < 0.20 then
IdleAnimation("Print")
elseif chance < 0.40 then
IdleAnimation("GetAttention")
else
chance = math.random(1, 8)
if chance == 1 then IdleAnimation("LookUp")
elseif chance == 2 then IdleAnimation("LookUpRight")
elseif chance == 3 then IdleAnimation("LookRight")
elseif chance == 4 then IdleAnimation("LookDownRight")
elseif chance == 5 then IdleAnimation("LookDown")
elseif chance == 6 then IdleAnimation("LookDownLeft")
elseif chance == 7 then IdleAnimation("LookLeft")
elseif chance == 8 then IdleAnimation("LookUpLeft")
end
end
AnimateIdle()
end)
end
-- Alert
frame:RegisterEvent("CHAT_MSG_RAID_WARNING")
frame:RegisterEvent("READY_CHECK")
--frame:RegisterEvent("ROLE_POLL_BEGIN")
function frame.events:CHAT_MSG_RAID_WARNING(...) SingleAnimation("Alert") end
function frame.events:READY_CHECK(...) SingleAnimation("Alert") end
function frame.events:ROLE_POLL_BEGIN(...) SingleAnimation("Alert") end
-- paragon chest complete
-- received zone quest (legion/bfa assaults)
-- CheckingSomething
-- encounter journal open
-- reading TRP/MRP
-- Congratulate
frame:RegisterEvent("BOSS_KILL")
--frame:RegisterEvent("ENCOUNTER_START")
frame:RegisterEvent("QUEST_TURNED_IN")
--frame:RegisterEvent("ISLAND_COMPLETED")
--frame:RegisterEvent("WARFRONT_COMPLETED")
--frame:RegisterEvent("ACHIEVEMENT_EARNED")
frame:RegisterEvent("PLAYER_LEVEL_UP")
frame:RegisterEvent("PLAYER_UNGHOST")
frame:RegisterEvent("PLAYER_ALIVE")
frame:RegisterEvent("DUEL_FINISHED")
--frame:RegisterEvent("NEW_MOUNT_ADDED")
--frame:RegisterEvent("NEW_PET_ADDED")
--frame:RegisterEvent("NEW_TOY_ADDED")
--frame:RegisterEvent("BARBER_SHOP_APPEARANCE_APPLIED")
function frame.events:BOSS_KILL(...) SingleAnimation("Congratulate") end
--function frame.events:ENCOUNTER_START() SingleAnimation("Congratulate") ClippyAssist.SetText("Your encounter started!", 5) end
function frame.events:QUEST_TURNED_IN(...) SingleAnimation("Congratulate") end
function frame.events:ISLAND_COMPLETED(...) SingleAnimation("Congratulate") end
function frame.events:WARFRONT_COMPLETED(...) SingleAnimation("Congratulate") end
function frame.events:ACHIEVEMENT_EARNED(...) SingleAnimation("Congratulate") end
function frame.events:PLAYER_LEVEL_UP(...) SingleAnimation("Congratulate") end
function frame.events:PLAYER_UNGHOST() SingleAnimation("Congratulate") end
function frame.events:PLAYER_ALIVE()
if (not UnitIsDeadOrGhost("player")) then SingleAnimation("Congratulate") end
end
function frame.events:DUEL_FINISHED() SingleAnimation("Congratulate") end
function frame.events:NEW_MOUNT_ADDED(...) SingleAnimation("Congratulate") end
function frame.events:NEW_PET_ADDED(...) SingleAnimation("Congratulate") end
function frame.events:NEW_TOY_ADDED(...) SingleAnimation("Congratulate") end
function frame.events:BARBER_SHOP_APPEARANCE_APPLIED() SingleAnimation("Congratulate") end
-- rare elite killed
-- received AH mail
-- reached reputation level
-- crafting complete
-- new appearance set
-- all battlepets healed
-- EmptyTrash
frame:RegisterEvent("PLAYER_DEAD")
frame:RegisterEvent("ENCOUNTER_END")
frame:RegisterEvent("DELETE_ITEM_CONFIRM")
function frame.events:PLAYER_DEAD() SingleAnimation("EmptyTrash") end
function frame.events:ENCOUNTER_END(encounterID, encounterName, difficultyID, groupSize, success)
if success == 0 then SingleAnimation("EmptyTrash") end
end
function frame.events:DELETE_ITEM_CONFIRM(...) SingleAnimation("EmptyTrash") end
-- key failed
-- duel lost
-- Explain
-- weakaura speech bubble (while idle)
-- GetAttention
frame:RegisterEvent("ADDON_LOADED")
function frame.events:ADDON_LOADED(...)
--Check for settings array. Used for Profiles.
if( not ClippyAssistData ) then
ClippyAssistData = {};
end
--Check for Profile Settings
if( not ClippyAssistData[CAProfile]) then
ClippyAssistData[CAProfile] = {};
end
--Check for Profile Settings
if( not ClippyAssistData[CAProfile].scale) then
ClippyAssistData[CAProfile].scale = 1;
end
if ClippyAssistData[CAProfile].scale then
scale = tonumber(ClippyAssistData[CAProfile].scale)
if (scale == nil) then
scale = 1
end
end
frame:SetSize(124*scale, 93*scale)
end
-- GetAttention
frame:RegisterEvent("PLAYER_FLAGS_CHANGED")
function frame.events:PLAYER_FLAGS_CHANGED(unitTarget)
if unitTarget == "player" and UnitIsAFK("player") then SingleAnimation("GetAttention") end
end
-- afk logout starts
-- GoodBye
-- casting hearth
-- casting teleport
-- Greeting
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
function frame.events:PLAYER_ENTERING_WORLD(isInitialLogin, isReloadingUi)
if isInitialLogin or isReloadingUi then
C_Timer.After(5.0, function()
if (math.random() < 0.40) then
SingleAnimation("Greeting1")
else
SingleAnimation("Greeting2")
end
AnimateIdle()
end)
end
end
-- Hide
-- cast invisibility
-- cast stealth
-- Print
-- export weakaura
-- Processing
-- viewing LFG applicants
-- Searching
-- viewing LFG groups
-- SendMail
frame:RegisterEvent("MAIL_SEND_SUCCESS")
function frame.events:MAIL_SEND_SUCCESS() SingleAnimation("SendMail") end
-- trade complete
-- Show
-- exit invisibility
-- exit stealth
-- cancel logout
-- Aggro drop (e.g. fade, feign death)
-- 1. Hide
-- 2. Show
-- Pull timer
frame:RegisterEvent("START_TIMER")
function frame.events:START_TIMER(timerType, timeRemaining, totalTime)
if timerType == 3 then
SingleAnimation("Alert")
SingleAnimation("GetAttention")
local x_mid = GetScreenWidth() / 2
local y_mid = GetScreenHeight() / 2
local x_frame, y_frame = frame:GetCenter()
x_frame = x_frame - x_mid
y_frame = y_frame - y_mid
local theta = atan2(y_frame, x_frame)
if theta > -45 and theta <= 45 then SingleAnimation("GestureRight2")
elseif theta > 45 and theta <= 135 then SingleAnimation("GestureDown2")
elseif theta > 135 or theta <= -135 then SingleAnimation("GestureLeft2")
elseif theta > -135 and theta <= -45 then SingleAnimation("GestureUp2")
end
if theta > -22.5 and theta <= 22.5 then SingleAnimation("LookRight")
elseif theta > 22.5 and theta <= 67.5 then SingleAnimation("LookDownRight")
elseif theta > 67.5 and theta <= 112.5 then SingleAnimation("LookDown")
elseif theta > 112.5 and theta <= 157.5 then SingleAnimation("LookDownLeft")
elseif theta > 157.5 and theta <= -157.5 then SingleAnimation("LookLeft")
elseif theta > -157.5 and theta <= -112.5 then SingleAnimation("LookUpLeft")
elseif theta > -112.5 and theta <= -67.5 then SingleAnimation("LookUp")
elseif theta > -67.5 and theta <= -22.5 then SingleAnimation("LookUpRight")
end
end
end
-- Log out (timer)
-- 1. Wave1
-- 2. Save
-- 3. Print
-- 4. GoodBye
--------------------
-- Slash Commands --
--------------------
SLASH_CLIPPY1 = "/clippy"
function SlashCmdList.CLIPPY(msg, editBox)
if msg == "" then
msg = "-help"
end
msg, arg1 = strsplit(" ", msg)
if msg == "-help" or msg == "-h" or msg == "-?" then
print("You are currently using Clippy Assist v" ..
GetAddOnMetadata("ClippyAssistBCC", "Version") .. ".")
print("It looks like you're trying to use Clippy Assist. " ..
"Would you like some help with that?")
print(" -help: Shows this text.")
print(" -scale <scale>: Scales Clippy with given percentage.")
print(" -hide: Temporarily hide Clippy. :c")
print(" -show: Show Clippy again. :D")
print(" -reset: Resets Clippy's position.")
print(" -list: Lists all available animations.")
print(" everything else: Attempts to play that animation.")
elseif msg == "-hide" then
frame:Hide() -- Note: also prevents frame:OnUpdate() from firing!
elseif msg == "-scale" then
ClippyAssistData[CAProfile].scale = tonumber(arg1)
if (ClippyAssistData[CAProfile].scale == null) then
ClippyAssistData[CAProfile].scale = 1
end
frame:SetSize(124*ClippyAssistData[CAProfile].scale, 93*ClippyAssistData[CAProfile].scale)
elseif msg == "-show" then
frame:Show()
elseif msg == "-reset" or msg == "-r" then
frame:ClearAllPoints()
frame:SetPoint("CENTER")
ClippyAssistData[CAProfile].scale = 1
frame:SetSize(124*ClippyAssistData[CAProfile].scale, 93*ClippyAssistData[CAProfile].scale)
elseif msg == "-list" or msg == "-l" then
print("Clippy's available animations:")
local display = {}
for i,_ in pairs(data) do
table.insert(display, i)
end
table.sort(display)
for _,name in ipairs(display) do
print(" " .. name)
end
else
-- `data.msg == nil` doesn't work for some reason...
if data[msg] == nil then
print("Couldn't find that animation.")
print("Use \"/clippy -list\" to list available animations.")
print("Use \"/clippy -help\" to view all commands.")
else
SingleAnimation(msg)
end
end
end