1 #using scripts\codescripts\struct;
3 #using scripts\shared\callbacks_shared;
4 #using scripts\shared\gameobjects_shared;
5 #using scripts\shared\system_shared;
6 #using scripts\shared\util_shared;
8 #insert scripts\shared\shared.gsh;
10 #namespace entityheadicons;
19 if ( isdefined( level.initedEntityHeadIcons ) )
24 level.initedEntityHeadIcons =
true;
26 assert( isdefined(game[
"entity_headicon_allies"]),
"Allied head icons are not defined. Check the team set for the level.");
27 assert( isdefined(game[
"entity_headicon_axis"]),
"Axis head icons are not defined. Check the team set for the level.");
29 if ( !level.teamBased )
34 if (!IsDefined(level.setEntityHeadIcon) )
39 level.entitiesWithHeadIcons = [];
45 if (!level.teamBased && !isdefined(owner) )
50 if( !isdefined( constant_size ) )
52 constant_size =
false;
55 if (!isdefined(
self.entityHeadIconTeam))
57 self.entityHeadIconTeam =
"none";
58 self.entityHeadIcons = [];
59 self.entityHeadObjectives = [];
62 if ( level.teamBased && !isdefined(owner) )
64 if (team ==
self.entityHeadIconTeam)
69 self.entityHeadIconTeam = team;
72 if (isdefined(offset))
74 self.entityHeadIconOffset = offset;
78 self.entityHeadIconOffset = (0,0,0);
82 if ( isdefined(
self.entityHeadIcons ) )
84 for (i = 0; i <
self.entityHeadIcons.size; i++)
86 if (isdefined(
self.entityHeadIcons[i]))
94 if ( isdefined(
self.entityHeadObjectives ) )
96 for (i = 0; i <
self.entityHeadObjectives.size; i++)
98 if (isdefined(
self.entityHeadObjectives[i]))
100 Objective_Delete(
self.entityHeadObjectives[i]);
101 self.entityHeadObjectives[i] = undefined;
106 self.entityHeadIcons = [];
107 self.entityHeadObjectives = [];
109 self notify(
"kill_entity_headicon_thread");
111 if ( !isdefined( objective ) )
113 objective = game[
"entity_headicon_" + team];
116 if ( isdefined( objective ) )
118 if ( isdefined(owner) && !level.teamBased )
122 if( !IsPlayer( owner ) )
124 assert( isdefined( owner.owner ),
"entity has to have an owner if it's not a player");
127 if( isstring(objective) )
136 else if ( isdefined(owner) && team !=
"none")
138 if( isstring(objective) )
155 friendly_blue_color =
array( 0.584, 0.839, 0.867 );
156 headicon = NewTeamHudElem(team);
157 headicon.archived =
true;
158 headicon.x = entity.entityHeadIconOffset[0];
159 headicon.y = entity.entityHeadIconOffset[1];
160 headicon.z = entity.entityHeadIconOffset[2];
162 headicon.color = ( friendly_blue_color[0], friendly_blue_color[1], friendly_blue_color[2] );
163 headicon setShader(icon, 6, 6);
164 headicon setwaypoint( constant_size );
165 headicon SetTargetEnt( entity );
168 entity.entityHeadIcons[entity.entityHeadIcons.size] = headicon;
173 headicon = newClientHudElem(
self);
174 headicon.archived =
true;
175 headicon.x = entity.entityHeadIconOffset[0];
176 headicon.y = entity.entityHeadIconOffset[1];
177 headicon.z = entity.entityHeadIconOffset[2];
179 headicon setShader(icon, 6, 6);
180 headicon setwaypoint( constant_size );
181 headicon SetTargetEnt( entity );
184 entity.entityHeadIcons[entity.entityHeadIcons.size] = headicon;
189 Objective_Add( headIconObjectiveId,
"active", entity, objective );
190 Objective_Team( headIconObjectiveId, team );
191 Objective_SetColor( headIconObjectiveId, &
"FriendlyBlue" );
194 entity.entityHeadObjectives[entity.entityHeadObjectives.size] = headIconObjectiveId;
200 Objective_Add( headIconObjectiveId,
"active", entity, objective );
201 Objective_SetInvisibleToAll( headIconObjectiveId );
202 Objective_SetVisibleToPlayer( headIconObjectiveId,
self );
203 Objective_SetColor( headIconObjectiveId, &
"FriendlyBlue" );
206 entity.entityHeadObjectives[entity.entityHeadObjectives.size] = headIconObjectiveId;
211 self notify(
"destroyHeadIconsOnDeath_singleton" );
212 self endon(
"destroyHeadIconsOnDeath_singleton" );
216 for (i = 0; i <
self.entityHeadIcons.size; i++)
218 if (isdefined(
self.entityHeadIcons[i]))
224 for (i = 0; i <
self.entityHeadObjectives.size; i++)
226 if (isdefined(
self.entityHeadObjectives[i]))
229 Objective_Delete(
self.entityHeadObjectives[i] );
236 if( isdefined(
self.entityHeadIcons ) )
238 for (i = 0; i <
self.entityHeadIcons.size; i++)
240 if (isdefined(
self.entityHeadIcons[i]))
247 if( isdefined(
self.entityHeadObjectives ) )
249 for (i = 0; i <
self.entityHeadObjectives.size; i++)
251 if (isdefined(
self.entityHeadObjectives[i]))
254 Objective_Delete(
self.entityHeadObjectives[i] );
259 self.entityHeadObjectives = [];
264 headicon.x =
self.origin[0] +
self.entityHeadIconOffset[0];
265 headicon.y =
self.origin[1] +
self.entityHeadIconOffset[1];
266 headicon.z =
self.origin[2] +
self.entityHeadIconOffset[2];
271 if( isdefined(
self.entityHeadIcons ) )
273 foreach( icon
in self.entityHeadIcons )
275 icon.hidewhileremotecontrolling =
true;