vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | function tradeDispenserSlaveOnUpdate() |
2 | local down, up, lag = GetNetStats(); |
||
3 | local LagTimer = floor(lag/1000); |
||
4 | if (LagTimer < 0.2) then LagTimer=0.2 end; |
||
5 | |||
6 | if (not tD_Temp.isEnabled) then return end |
||
7 | |||
8 | if (tD_Temp.broadcastSlice > 0) then |
||
9 | if (arg1~=nil) then |
||
10 | tD_Temp.broadcastSlice = tD_Temp.broadcastSlice - arg1 |
||
11 | end |
||
12 | if (tD_Temp.broadcastSlice < 0) then |
||
13 | if (UnitAffectingCombat("player")==1) then |
||
14 | -- player is in combat! tD should not spam its auto-broadcast while fighting some mobs! (especially bossmobs) - wait 15sec, and try again! |
||
15 | tD_Temp.broadcastSlice = 15; |
||
16 | else |
||
17 | if (tD_CharDatas.AutoBroadcast) then tradeDispenserBroadcastItems() end |
||
18 | tD_Temp.broadcastSlice = tD_CharDatas.broadcastSlice |
||
19 | end |
||
20 | end |
||
21 | end |
||
22 | |||
23 | if (arg1~=nil) then |
||
24 | tD_Temp.timeSlice = tD_Temp.timeSlice - arg1 |
||
25 | |||
26 | if (tD_CharDatas.TimelimitCheck and tD_Temp.Countdown) then |
||
27 | if (tD_Temp.Countdown>0) then |
||
28 | tD_Temp.Countdown=tD_Temp.Countdown - arg1; |
||
29 | if (math.floor(tD_Temp.Countdown)==11) then |
||
30 | tradeDispenserMessage("WHISPER", tD_GlobalDatas.whisper[11]); |
||
31 | tD_Temp.Countdown=tD_Temp.Countdown-1; |
||
32 | end |
||
33 | if (math.floor(tD_Temp.Countdown)==0) then |
||
34 | tD_Temp.Target.Name=nil; |
||
35 | tD_Temp.tradeState="timeup"; |
||
36 | tradeDispenserVerbose(1,"Timeup, close the trade"); |
||
37 | CloseTrade(); |
||
38 | tD_Temp.Countdown=tD_Temp.Countdown-1; |
||
39 | end |
||
40 | --tradeDispenserVerbose(0,"countdown: "..tD_Temp.Countdown); |
||
41 | end |
||
42 | end |
||
43 | end; |
||
44 | if (tD_Temp.timeSlice > 0) then return end |
||
45 | |||
46 | if (tD_Temp.tradeState == "populate") then |
||
47 | tD_Temp.timeSlice = LagTimer |
||
48 | tradeDispenserVerbose(1,"tradeDispenserSlaveOnUpdate: populate") |
||
49 | |||
50 | if (tD_Temp.Slot[tD_Temp.tradeData.slotID]) then |
||
51 | if (tD_Temp.tradeData.containerLocation == nil) then |
||
52 | tradeDispenserVerbose(3,"Compile Item "..tD_Temp.tradeData.slotID) |
||
53 | local cID, sID = tradeDispenserCompile(tD_Temp.tradeData.slotID) |
||
54 | |||
55 | if (cID == "deadlink") then |
||
56 | tradeDispenserVerbose(1,"deadlink") |
||
57 | tD_Temp.tradeData.containerLocation=nil; |
||
58 | tD_Temp.timeSlice = LagTimer*4 |
||
59 | tD_Temp.tradeState = "accept" |
||
60 | tD_Temp.tradeData = false |
||
61 | return |
||
62 | elseif (cID==nil) then |
||
63 | tradeDispenserMessage("WHISPER",tD_GlobalDatas.whisper[4]) |
||
64 | tradeDispenserMessage("SAY",tD_GlobalDatas.whisper[2]) |
||
65 | tD_Temp.timeSlice = LagTimer*4 |
||
66 | tD_Temp.tradeState = "accept" |
||
67 | tD_Temp.tradeData = true |
||
68 | return |
||
69 | else |
||
70 | tradeDispenserVerbose(2,"tradeDispenserOnUpdate: found container location") |
||
71 | tD_Temp.tradeData.containerLocation = {} |
||
72 | tD_Temp.tradeData.containerLocation.cID = cID |
||
73 | tD_Temp.tradeData.containerLocation.sID = sID |
||
74 | end |
||
75 | end |
||
76 | |||
77 | if (tD_Temp.tradeData.containerLocation) then |
||
78 | local cID = tD_Temp.tradeData.containerLocation.cID |
||
79 | local sID = tD_Temp.tradeData.containerLocation.sID |
||
80 | |||
81 | local _, itemCount = GetContainerItemInfo(cID, sID) |
||
82 | PickupContainerItem(cID, sID) |
||
83 | |||
84 | if ( CursorHasItem() ) then |
||
85 | tradeDispenserVerbose(3,"tradeDispenserSlaveOnUpdate: CursorHasItem()") |
||
86 | ClickTradeButton(tD_Temp.tradeData.slotID) |
||
87 | |||
88 | if (itemCount ~= tD_Temp.Slot[tD_Temp.tradeData.slotID].itemCount) then |
||
89 | tradeDispenserMessage("WHISPER",tD_GlobalDatas.whisper[3], "WHISPER") |
||
90 | tradeDispenserMessage("SAY",tD_GlobalDatas.whisper[2]) |
||
91 | |||
92 | tD_Temp.timeSlice = LagTimer*4 |
||
93 | tD_Temp.tradeState = "accept" |
||
94 | tD_Temp.tradeData = true |
||
95 | return |
||
96 | end |
||
97 | |||
98 | tD_Temp.tradeData.slotID = tD_Temp.tradeData.slotID + 1 |
||
99 | tD_Temp.tradeData.containerLocation = nil |
||
100 | tD_Temp.tradeData.numAttempts = 0 |
||
101 | else |
||
102 | tD_Temp.tradeData.numAttempts = tD_Temp.tradeData.numAttempts + 1 |
||
103 | if (tD_Temp.tradeData.numAttempts == 32) then |
||
104 | tradeDispenserVerbose(2,"tradeDispenserOnUpdate: too many attempts") |
||
105 | tradeDispenserMessage("WHISPER",tD_GlobalDatas.whisper[1]); |
||
106 | CloseTrade() |
||
107 | return |
||
108 | end |
||
109 | end |
||
110 | end |
||
111 | else |
||
112 | --tradeDispenserVerbose(1,"tradeDispenserSlaveOnUpdate: ID ="..tD_Temp.tradeData.slotID) |
||
113 | tD_Temp.tradeData.slotID = tD_Temp.tradeData.slotID + 1 |
||
114 | if (tD_Temp.tradeData.slotID >= 7) then |
||
115 | tD_Temp.tradeState = "accept" |
||
116 | tD_Temp.timeSlice = LagTimer*4 |
||
117 | tradeDispenserVerbose(1,"tradeDispenserSlaveOnUpdate: DONE") |
||
118 | tD_Temp.tradeData = false |
||
119 | end |
||
120 | end |
||
121 | elseif (tD_Temp.tradeState == "accept") then |
||
122 | tD_Temp.timeSlice = 1000 |
||
123 | if (tD_CharDatas.AutoAccept) then tradeDispenserAccept() end |
||
124 | end |
||
125 | |||
126 | end |
||
127 | |||
128 | |||
129 | function tradeDispenserBroadcastItems() |
||
130 | if (tD_Temp.isEnabled) then |
||
131 | |||
132 | local tradeDispenserChannel, temp = tradeDispenserGetChannel(); |
||
133 | if (tradeItems) then tradeDispenserVerbose(1,"tradeItems: "..tradeItems) end |
||
134 | |||
135 | local x = math.random(1, tD_CharDatas.Random); |
||
136 | local message=""; |
||
137 | if (strlen(tD_CharDatas.RndText[x])<=2) then |
||
138 | message=tD_Loc.defaultBroadcast; |
||
139 | else message=tD_CharDatas.RndText[x] end |
||
140 | tradeDispenserMessage(tradeDispenserChannel, message) |
||
141 | end |
||
142 | end |
||
143 | |||
144 | |||
145 | function tradeDispenserGetChannel() |
||
146 | local Channel="SAY"; |
||
147 | local ChannelLoc=tD_Loc.channel.say; |
||
148 | if (tD_CharDatas.ChannelID) then |
||
149 | if (tD_CharDatas.ChannelID==1) then Channel="SAY"; ChannelLoc=tD_Loc.channel.say end |
||
150 | if (tD_CharDatas.ChannelID==2) then Channel="YELL"; ChannelLoc=tD_Loc.channel.yell end |
||
151 | if (tD_CharDatas.ChannelID==3) then --Channel="RAID"; ChannelLoc=tD_Loc.channel.raid |
||
152 | if (UnitInRaid("player")==1) then Channel="RAID"; ChannelLoc=tD_Loc.channel.raid |
||
153 | elseif (GetNumPartyMembers()>=1) then Channel="PARTY"; ChannelLoc=tD_Loc.channel.party |
||
154 | else Channel="SAY"; ChannelLoc=tD_Loc.channel.say end |
||
155 | end |
||
156 | if (tD_CharDatas.ChannelID==4) then --Channel="PARTY"; ChannelLoc=tD_Loc.channel.party |
||
157 | if ((GetNumPartyMembers()>=1)) then Channel="PARTY"; ChannelLoc=tD_Loc.channel.party |
||
158 | else Channel="SAY"; ChannelLoc=tD_Loc.channel.say end |
||
159 | end |
||
160 | if (tD_CharDatas.ChannelID==5) then Channel="GUILD"; ChannelLoc=tD_Loc.channel.guild end |
||
161 | end |
||
162 | return Channel, ChannelLoc; |
||
163 | end |
||
164 | |||
165 | |||
166 | function tradeDispenserStartTimelimiter() |
||
167 | tradeDispenserVerbose(2,"Countdown started: you've got "..tD_CharDatas.Timelimit.." sec to trade") |
||
168 | tD_Temp.Countdown=tD_CharDatas.Timelimit+2 |
||
169 | end |