// Cycles through our torches and sets them to the correct one void DoTorches(); // returns TRUE if it is night or dusk, otherwise returns false int GetisNightorDusk(); void DoTorches() { string sTime="d"; if (GetisNightorDusk()) { sTime="n"; } object oOld; object oTorch; string sTorch; int nLight; int nIdx=0; int nTile; object oBox=GetObjectByTag("jw_torch_box",nIdx); while (GetIsObjectValid(oBox)) { oOld=GetLocalObject(oBox,"mytorch"); if (GetIsObjectValid(oOld)) { SetPlotFlag(oOld,FALSE); DestroyObject(oOld); } nTile=GetLocalInt(oBox,"tile"+sTime); if (nTile>0) { vector vVector=GetPositionFromLocation(GetLocation(oBox)); if (vVector.z==0.0) { vVector.z= -0.4f; } location lLocation=Location(GetArea(oBox),vVector,GetFacing(oBox)); oTorch = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_invisobj", lLocation,FALSE, "x2_tmp_tile"); ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(nTile), oTorch); } else { sTorch=GetName(oBox)+"_"+sTime; oTorch=CreateObject(OBJECT_TYPE_PLACEABLE,sTorch,GetLocation(oBox),FALSE); } SetLocalObject(oBox,"mytorch",oTorch); nLight=GetLocalInt(oBox,"light"); if ((sTime=="n")&&(nLight>0)) { effect eLight = EffectVisualEffect(nLight); eLight=ExtraordinaryEffect(eLight); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eLight, oTorch); } nIdx=nIdx+1; oBox=GetObjectByTag("jw_torch_box",nIdx); } } int GetisNightorDusk() { int nReturn=FALSE; if (GetIsDusk()||GetIsNight()) { nReturn=TRUE; } return nReturn; }