1 package net
.encode
.wurmesp
;
3 import com
.wurmonline
.client
.game
.World
;
4 import com
.wurmonline
.client
.renderer
.Color
;
5 import com
.wurmonline
.client
.renderer
.PickRenderer
;
6 import com
.wurmonline
.client
.renderer
.PickableUnit
;
7 import com
.wurmonline
.client
.renderer
.WorldRender
;
8 import com
.wurmonline
.client
.renderer
.backend
.Primitive
;
9 import com
.wurmonline
.client
.renderer
.backend
.Queue
;
10 import com
.wurmonline
.client
.renderer
.backend
.RenderState
;
11 import net
.encode
.wurmesp
.util
.ReUtils
;
16 private String modelName
;
17 private String hoverName
;
18 private PickableUnit pickableUnit
;
19 private float[] color
= new float[]{0.0f, 0.0f, 0.0f};
20 private float[] conditionedcolor
= new float[]{0.0f, 0.0f, 0.0f};
21 private String condition
;
22 public static float[] colorPlayers
= new float[]{0.0f, 0.0f, 0.0f};
23 public static float[] colorPlayersEnemy
= new float[]{0.0f, 0.0f, 0.0f};
24 public static float[] colorMobs
= new float[]{0.0f, 0.0f, 0.0f};
25 public static float[] colorMobsAggro
= new float[]{0.0f, 0.0f, 0.0f};
26 public static float[] colorSpecials
= new float[]{0.0f, 0.0f, 0.0f};
27 public static float[] colorSpotted
= new float[]{0.0f, 0.0f, 0.0f};
28 public static float[] colorUniques
= new float[]{0.0f, 0.0f, 0.0f};
29 public static float[] colorAlert
= new float[]{0.0f, 0.0f, 0.0f};
30 public static float[] colorAngry
= new float[]{0.0f, 0.0f, 0.0f};
31 public static float[] colorChampion
= new float[]{0.0f, 0.0f, 0.0f};
32 public static float[] colorDiseased
= new float[]{0.0f, 0.0f, 0.0f};
33 public static float[] colorFierce
= new float[]{0.0f, 0.0f, 0.0f};
34 public static float[] colorGreenish
= new float[]{0.0f, 0.0f, 0.0f};
35 public static float[] colorHardened
= new float[]{0.0f, 0.0f, 0.0f};
36 public static float[] colorLurking
= new float[]{0.0f, 0.0f, 0.0f};
37 public static float[] colorRaging
= new float[]{0.0f, 0.0f, 0.0f};
38 public static float[] colorScared
= new float[]{0.0f, 0.0f, 0.0f};
39 public static float[] colorSlow
= new float[]{0.0f, 0.0f, 0.0f};
40 public static float[] colorSly
= new float[]{0.0f, 0.0f, 0.0f};
41 public static String
[] aggroMOBS
;
42 public static String
[] uniqueMOBS
;
43 public static String
[] specialITEMS
;
44 public static String
[] spottedITEMS
;
45 public static String
[] conditionedMOBS
;
47 public Unit(World world
, long id
, PickableUnit pickableUnit
, String modelName
, String hoverName
) {
50 this.pickableUnit
= pickableUnit
;
51 this.modelName
= modelName
;
52 this.hoverName
= hoverName
;
53 this.determineColor();
60 public PickableUnit
getPickableUnit() {
61 return this.pickableUnit
;
64 public float[] getColor() {
68 public float[] getConditionedColor() {
69 return this.conditionedcolor
;
72 public String
getHoverName() {
73 return this.hoverName
;
76 public String
getModelName() {
77 return this.modelName
;
80 public boolean isPlayer() {
81 return this.getModelName().contains("model.creature.humanoid.human.player") && !this.getModelName().contains("zombie");
84 public boolean isEnemyPlayer() {
85 return this.getModelName().contains("ENEMY");
88 public boolean isMob() {
89 return this.getModelName().contains("model.creature") && !this.getModelName().contains("humanoid.human");
92 public boolean isAggroMob() {
93 for (String mob
: aggroMOBS
) {
94 if (!this.getHoverName().contains(mob
)) continue;
100 public boolean isChampion() {
101 return this.getHoverName().contains("champion");
104 public boolean isConditioned() {
105 for (String condition
: conditionedMOBS
) {
106 if (!this.getHoverName().contains(condition
)) continue;
107 this.condition
= condition
;
113 public boolean isUnique() {
114 for (String mob
: uniqueMOBS
) {
115 if (!this.getHoverName().contains(mob
)) continue;
121 public boolean isSpecial() {
122 for (String item
: specialITEMS
) {
123 if (this.getHoverName().contains(item
)) {
126 if (!this.getModelName().contains(WurmEspMod
.search
)) continue;
132 public boolean isSpotted() {
133 for (String item
: spottedITEMS
) {
134 if (this.getHoverName().contains(item
)) {
137 if (!this.getModelName().contains(WurmEspMod
.search
)) continue;
140 if (WurmEspMod
.searchType
== WurmEspMod
.SEARCHTYPE
.HOVER
) {
141 if (this.getHoverName().contains(WurmEspMod
.search
)) {
144 } else if (WurmEspMod
.searchType
== WurmEspMod
.SEARCHTYPE
.MODEL
) {
145 if (this.getModelName().contains(WurmEspMod
.search
)) {
148 } else if (WurmEspMod
.searchType
== WurmEspMod
.SEARCHTYPE
.BOTH
) {
149 if (this.getHoverName().contains(WurmEspMod
.search
)) {
152 if (this.getModelName().contains(WurmEspMod
.search
)) {
159 private void determineColor() {
160 if (this.isPlayer()) {
161 this.color
= !this.isEnemyPlayer() ? colorPlayers
: colorPlayersEnemy
;
162 } else if (this.isUnique()) {
163 this.color
= colorUniques
;
164 } else if (this.isAggroMob()) {
165 this.color
= colorMobsAggro
;
166 } else if (this.isMob()) {
167 this.color
= colorMobs
;
168 } else if (this.isSpecial()) {
169 this.color
= colorSpecials
;
170 } else if (this.isSpotted()) {
171 this.color
= colorSpotted
;
173 if (this.isConditioned()) {
174 float[] color
= new float[]{0.0f, 0.0f, 0.0f};
175 switch (this.condition
) {
185 color
= colorChampion
;
189 color
= colorDiseased
;
197 color
= colorGreenish
;
201 color
= colorHardened
;
205 color
= colorLurking
;
224 this.conditionedcolor
= color
;
228 public void renderUnit(Queue queue
, boolean showconditioned
) {
229 if (this.pickableUnit
== null) {
233 RenderState renderStateFill
= new RenderState();
234 RenderState renderStateFillDepth
= new RenderState();
235 RenderState renderStateOutline
= new RenderState();
236 Color color
= new Color();
237 if (this.isConditioned() && showconditioned
) {
238 color
.set(this.conditionedcolor
[0], this.conditionedcolor
[1], this.conditionedcolor
[2]);
240 color
.set(this.color
[0], this.color
[1], this.color
[2]);
242 renderStateFill
.alphaval
= color
.a
= br
;
243 color
.a
*= this.pickableUnit
.getOutlineColor().a
;
245 WorldRender worldRenderer
= (WorldRender
)ReUtils
.getField(this.world
, "worldRenderer");
246 PickRenderer
.CustomPickFillRender customPickFill
= (PickRenderer
.CustomPickFillRender
)ReUtils
.getField(worldRenderer
, "customPickFill");
247 PickRenderer
.CustomPickFillDepthRender customPickFillDepth
= (PickRenderer
.CustomPickFillDepthRender
)ReUtils
.getField(worldRenderer
, "customPickFillDepth");
248 PickRenderer
.CustomPickOutlineRender customPickOutline
= (PickRenderer
.CustomPickOutlineRender
)ReUtils
.getField(worldRenderer
, "customPickOutline");
249 renderStateFill
.twosided
= false;
250 renderStateFill
.depthtest
= Primitive
.TestFunc
.ALWAYS
;
251 renderStateFill
.depthwrite
= true;
252 renderStateFill
.customstate
= customPickFill
;
253 this.pickableUnit
.renderPicked(queue
, renderStateFill
, color
);
254 renderStateOutline
.alphaval
= color
.a
= br
* 0.25f;
255 color
.a
*= this.pickableUnit
.getOutlineColor().a
;
256 renderStateOutline
.twosided
= false;
257 renderStateOutline
.depthtest
= Primitive
.TestFunc
.LESS
;
258 renderStateOutline
.depthwrite
= false;
259 renderStateOutline
.blendmode
= Primitive
.BlendMode
.ALPHABLEND
;
260 renderStateOutline
.customstate
= customPickOutline
;
261 this.pickableUnit
.renderPicked(queue
, renderStateOutline
, color
);
262 renderStateFillDepth
.customstate
= customPickFillDepth
;
263 renderStateFillDepth
.depthtest
= Primitive
.TestFunc
.ALWAYS
;
264 this.pickableUnit
.renderPicked(queue
, renderStateFillDepth
, color
);