forked from leo7044/CnC_TA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNew_Raidhelper.user.js
124 lines (107 loc) · 4.02 KB
/
New_Raidhelper.user.js
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
// ==UserScript==
// @name C&C Tiberium Alliances New Raidhelper
// @namespace alexos75
// @description Removes name and level information except for interesting raidtargets. You can now toggle the display. By editing lowerRange and upperRange you can modify the range of visible targets.
// @downloadURL https://raw.githubusercontent.com/leo7044/CnC_TA/master/New_Raidhelper.user.js
// @updateURL https://raw.githubusercontent.com/leo7044/CnC_TA/master/New_Raidhelper.user.js
// @include http*://prodgame*.alliances.commandandconquer.com/*/index.aspx*
// @include http*://cncapp*.alliances.commandandconquer.com/*/index.aspx*
// @version 0.2.2
// @author alexos75
// @contributor leo7044 (https://github.com/leo7044)
// @grant none
// ==/UserScript==
/* Based on the script of Mooff */
function initHideCampsButton(){
// section for settings ->
var lowerRange = 2;
var upperRange = 99;
var hideColleaquesInfos = true;
var hidePoiInfos = true;
// <- section for settings
var activeText = "Clear View";
var inactiveText = "Show All";
var minimumlevel = 0;
var maximumlevel = 0;
var HCBtn = new qx.ui.form.Button(activeText);
var active = false;
HCBtn.set({ width: 80,
appearance: "button-text-small",
toolTipText: "Makes interesting targets more visible"
});
HCBtn.addListener("click",function(){
var currCity = ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentOwnCity();
var x = currCity.get_X();
var y = currCity.get_Y();
var region = ClientLib.Vis.VisMain.GetInstance().get_Region();
var attackDistance = ClientLib.Data.MainData.GetInstance().get_Server().get_MaxAttackDistance();
active = !active;
minimumlevel = Math.floor(currCity.get_LvlOffense() - lowerRange);
maximumlevel = Math.floor(currCity.get_LvlOffense() + upperRange);
for (var i = x - (attackDistance); i < (x+attackDistance); i++)
{
for (var j = y - attackDistance; j < (y+attackDistance); j++)
{
var visObject = region.GetObjectFromPosition(i * region.get_GridWidth(),j * region.get_GridHeight());
if(visObject != null)
{
if (visObject.get_VisObjectType() == ClientLib.Vis.VisObject.EObjectType.RegionNPCCamp)
{
var lvl = Math.round(visObject.get_BaseLevelFloat()) + 1;
if ( lvl < minimumlevel || lvl > maximumlevel )
{
if( active)
{
visObject.HideInfos();
}
else
{
visObject.ShowInfos();
}
}
}
else if( (visObject.get_VisObjectType() == ClientLib.Vis.VisObject.EObjectType.RegionCityType && hideColleaquesInfos) ||
(visObject.get_VisObjectType() == ClientLib.Vis.VisObject.EObjectType.RegionPointOfInterest && hidePoiInfos))
{
if( active)
{
visObject.HideInfos();
}
else
{
visObject.ShowInfos();
}
}
}
}
}
if( active)
{
HCBtn.set({ label : inactiveText })
}
else
{
HCBtn.set({ label : activeText })
}
},this);
var app = qx.core.Init.getApplication();
app.getDesktop().add(HCBtn, {
right: 125,
bottom:55,
});
}
/*Main*/
function waitForClientLib(){
if ((typeof ClientLib == 'undefined') || (typeof qx == 'undefined') || (qx.core.Init.getApplication().initDone == false))
{
setTimeout(waitForClientLib, 1000);
return;
}
else{
initHideCampsButton();
}
}
function startup(){
setTimeout(waitForClientLib, 1000);
};
startup();