2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
31 //static Rect alarm_rect = {{10, 10},{10 + 80, 10 + 78}};
32 static Rect alarm_rect
= {{10, 278},{10 + 64, 278 + 64}};
34 // Here's the type of my global
40 // Here's my descriptor, which identifies my stuff to the tag file & editor
41 sFileVarDesc gAlarmCountDesc
=
43 kMissionVar
, // Where do I get saved?
44 "ALARMCOUNT", // Tag file tag
45 "Alarm Count", // friendly name
46 FILEVAR_TYPE(sAlarmCount
), // Type (for editing)
48 { 1, 0}, // last valid version
49 "DPC", // optional: what game am I in NULL means all
52 // The actual global variable
53 cFileVar
<sAlarmCount
,&gAlarmCountDesc
> gAlarmCount
;
54 //--------------------------------------------------------------------------------------
55 void DPCAlarmInit(int which
)
58 gAlarmHnd
= LoadPCX("alarm");
59 DPCOverlaySetFlags(which
, kOverlayFlagTranslucent
);
64 use_rect
.ul
.x
= alarm_rect
.ul
.x
;
65 use_rect
.ul
.y
= smode
.h
- (480 - alarm_rect
.ul
.y
);
66 use_rect
.lr
.x
= use_rect
.ul
.x
+ RectWidth(&alarm_rect
);
67 use_rect
.lr
.y
= use_rect
.ul
.y
+ RectHeight(&alarm_rect
);
69 DPCOverlaySetRect(which
, use_rect
);
72 //--------------------------------------------------------------------------------------
73 void DPCAlarmTerm(void)
75 SafeFreeHnd(&gAlarmHnd
);
78 //--------------------------------------------------------------------------------------
79 void DPCAlarmDraw(unsigned long inDeltaTicks
)
82 Rect r
= DPCOverlayGetRect(kOverlayAlarm
);
89 if (!gPropHackTime
->Get(PlayerObject(),&duration
))
91 deltat
= duration
- t
;
98 sprintf(temp
,"%.1f",(float)(deltat
)/1000.0F
);
99 w
= gr_font_string_width(gDPCFont
, temp
);
100 h
= gr_font_string_height(gDPCFont
, temp
);
101 p
.x
= r
.ul
.x
+ (RectWidth(&r
) - w
) / 2;
102 p
.y
= r
.ul
.y
+ RectHeight(&r
) + 2;
103 gr_set_fcolor(gDPCTextColor
);
104 gr_font_string(gDPCFont
, temp
, p
.x
, p
.y
);
107 //--------------------------------------------------------------------------------------
108 IRes
*DPCAlarmBitmap(void)
112 //--------------------------------------------------------------------------------------
113 static IRes
*gHackIconHnd
;
114 static Rect full_rect
= {{10,278},{10 + 64, 278 + 64}};
116 //--------------------------------------------------------------------------------------
117 void DPCHackIconInit(int which
)
119 gHackIconHnd
= LoadPCX("HackIcon");
121 DPCOverlaySetFlags(which
, kOverlayFlagTranslucent
);
127 use_rect
.ul
.x
= full_rect
.ul
.x
;
128 use_rect
.ul
.y
= smode
.h
- (480 - full_rect
.ul
.y
);
129 use_rect
.lr
.x
= use_rect
.ul
.x
+ RectWidth(&full_rect
);
130 use_rect
.lr
.y
= use_rect
.ul
.y
+ RectHeight(&full_rect
);
132 DPCOverlaySetRect(which
, use_rect
);
135 //--------------------------------------------------------------------------------------
136 void DPCHackIconTerm(void)
138 SafeFreeHnd(&gHackIconHnd
);
141 //--------------------------------------------------------------------------------------
142 IRes
*DPCHackIconBitmap(void)
144 return(gHackIconHnd
);
146 //--------------------------------------------------------------------------------------
147 void DPCHackIconDraw(unsigned long inDeltaTicks
)
155 Rect r
= DPCOverlayGetRect(kOverlayHackIcon
);
157 AutoAppIPtr(DPCPlayer
);
159 plr
= PlayerObject();
164 if (!gPropHackTime
->Get(plr
,&duration
))
166 deltat
= duration
- t
;
168 // okay, this is kind of dumb to do during drawing
169 // but life is hard, then you die
172 SchemaPlay((Label
*)"xer04",NULL
);
173 DPCOverlayChange(kOverlayHackIcon
, kOverlayModeOff
);
174 gPropHackVisibility
->Set(plr
,1.0);
175 pDPCPlayer
->RecalcData(plr
);
179 sprintf(temp
,"%.1f",(float)(deltat
)/1000.0F
);
180 w
= gr_font_string_width(gDPCFont
, temp
);
181 h
= gr_font_string_height(gDPCFont
, temp
);
182 p
.x
= r
.ul
.x
+ (RectWidth(&r
) - w
) / 2;
183 p
.y
= r
.ul
.y
+ RectHeight(&r
) + 2;
184 gr_set_fcolor(gDPCTextColor
);
185 gr_font_string(gDPCFont
, temp
, p
.x
, p
.y
);
187 //--------------------------------------------------------------------------------------
188 void DPCAlarmAdd(int time
)
190 // so that there is never both hacked and alert at same time
191 AutoAppIPtr(DPCPlayer
);
192 DPCOverlayChange(kOverlayHackIcon
, kOverlayModeOff
);
193 gPropHackVisibility
->Set(PlayerObject(),1.0);
194 pDPCPlayer
->RecalcData(PlayerObject());
196 if (gAlarmCount
.m_count
== 0)
197 DPCOverlayChange(kOverlayAlarm
,kOverlayModeOn
);
199 //mprintf("Hey! AlarmCount is %d!\n",gAlarmCount.m_count);
201 gAlarmCount
.m_count
++;
202 gPropHackTime
->Set(PlayerObject(),time
);
204 //--------------------------------------------------------------------------------------
205 void DPCAlarmRemove(void)
207 if (gAlarmCount
.m_count
> 0)
209 gAlarmCount
.m_count
--;
210 if (gAlarmCount
.m_count
== 0)
212 DPCOverlayChange(kOverlayAlarm
, kOverlayModeOff
);
213 gPropHackTime
->Set(PlayerObject(),0);
217 //--------------------------------------------------------------------------------------
218 void DPCAlarmDisableAll(void)
220 // iterate through all objects, and anything with a population system on it,
221 // and is alarmed, send it a reset, which will in turn reset any associated
224 sPropertyObjIter iter
;
227 AutoAppIPtr(ScriptMan
);
229 gPropEcology
->IterStart(&iter
);
230 while (gPropEcology
->IterNext(&iter
, &obj
))
233 if (gPropEcoState
->IsRelevant(obj
))
235 gPropEcoState
->Get(obj
, &ecostate
);
236 if (ecostate
== kEcologyAlert
)
238 // resetting the ecology will in turn reset any associated
240 sScrMsg
msg(obj
,"Reset");
241 // This method may be running on any machine, so make sure the
242 // message gets through to the owner of the object:
243 msg
.flags
|= kSMF_MsgPostToOwner
;
244 pScriptMan
->SendMessage(&msg
);
248 gPropEcology
->IterStop(&iter
);
250 //--------------------------------------------------------------------------------------
251 sOverlayFunc OverlayAlarm
=
253 DPCAlarmDraw
, // draw
254 DPCAlarmInit
, // init
255 DPCAlarmTerm
, // term
257 NULL
, // dclick (really use)
260 DPCAlarmBitmap
, // bitmap
264 NULL
, // transparency
270 sOverlayFunc OverlayHackIcon
=
272 DPCHackIconDraw
, // draw
273 DPCHackIconInit
, // init
274 DPCHackIconTerm
, // term
276 NULL
, // dclick (really use)
279 DPCHackIconBitmap
, // bitmap
283 NULL
, // transparency