| | 1 | #include "system.h" |
| | 2 | #include "prototyp.h" |
| | 3 | #include "stratdef.h" |
| | 4 | #include "bh_types.h" |
| | 5 | #include "bh_light.h" |
| | 6 | #include "pldghost.h" |
| | 7 | #include "particle.h" |
| | 8 | #include "userprofile.h" |
| | 9 | #include "debris.h" |
| | 10 | #include <assert.h> |
| | 11 | #include <stdlib.h> |
| | 12 | |
| | 13 | static void SetTextureAnimationSequence(int shapeindex,TXACTRLBLK* tac,int sequence) |
| | 14 | { |
| | 15 | while(tac) |
| | 16 | { |
| | 17 | tac->tac_sequence = sequence; |
| | 18 | tac->tac_txah_s = GetTxAnimHeaderFromShape(tac, shapeindex); |
| | 19 | tac = tac->tac_next; |
| | 20 | } |
| | 21 | } |
| | 22 | |
| | 23 | static void UpdatePlacedLightState(PLACED_LIGHT_BEHAV_BLOCK* pl_bhv) |
| | 24 | { |
| | 25 | int done = 0; |
| | 26 | |
| | 27 | do |
| | 28 | { |
| | 29 | switch(pl_bhv->state) |
| | 30 | { |
| | 31 | case Light_State_Standard: |
| | 32 | case Light_State_Flicker: |
| | 33 | case Light_State_Broken: |
| | 34 | done = 1; |
| | 35 | break; |
| | 36 | case Light_State_StrobeUp : |
| | 37 | if(pl_bhv->timer >= pl_bhv->fade_up_time) |
| | 38 | { |
| | 39 | pl_bhv->timer -= pl_bhv->fade_up_time; |
| | 40 | pl_bhv->state = Light_State_StrobeUpDelay; |
| | 41 | } |
| | 42 | else |
| | 43 | { |
| | 44 | done = 1; |
| | 45 | } |
| | 46 | break; |
| | 47 | case Light_State_StrobeUpDelay: |
| | 48 | if(pl_bhv->timer >= pl_bhv->up_time) |
| | 49 | { |
| | 50 | pl_bhv->timer -= pl_bhv->up_time; |
| | 51 | pl_bhv->state = Light_State_StrobeDown; |
| | 52 | } |
| | 53 | else |
| | 54 | { |
| | 55 | done = 1; |
| | 56 | } |
| | 57 | break; |
| | 58 | case Light_State_StrobeDown: |
| | 59 | if(pl_bhv->timer >= pl_bhv->fade_down_time) |
| | 60 | { |
| | 61 | pl_bhv->timer -= pl_bhv->fade_down_time; |
| | 62 | pl_bhv->state = Light_State_StrobeDownDelay; |
| | 63 | } |
| | 64 | else |
| | 65 | { |
| | 66 | done = 1; |
| | 67 | } |
| | 68 | break; |
| | 69 | case Light_State_StrobeDownDelay: |
| | 70 | if(pl_bhv->timer >= pl_bhv->down_time) |
| | 71 | { |
| | 72 | pl_bhv->timer -= pl_bhv->down_time; |
| | 73 | pl_bhv->state = Light_State_StrobeUp; |
| | 74 | } |
| | 75 | else |
| | 76 | { |
| | 77 | done = 1; |
| | 78 | } |
| | 79 | break; |
| | 80 | default : |
| | 81 | assert(1==0); |
| | 82 | done = 1; |
| | 83 | } |
| | 84 | |
| | 85 | } while(!done); |
| | 86 | |
| | 87 | switch(pl_bhv->on_off_state) |
| | 88 | { |
| | 89 | case Light_OnOff_On: |
| | 90 | case Light_OnOff_Off: |
| | 91 | break; |
| | 92 | case Light_OnOff_FadeOn: |
| | 93 | if(pl_bhv->on_off_timer >= pl_bhv->fade_up_time) |
| | 94 | { |
| | 95 | pl_bhv->on_off_timer = 0; |
| | 96 | |
| | 97 | if(!pl_bhv->swap_colour_and_brightness_alterations) |
| | 98 | { |
| | 99 | pl_bhv->light->LightBright = pl_bhv->light->LightBrightStore; |
| | 100 | } |
| | 101 | else |
| | 102 | { |
| | 103 | pl_bhv->light->RedScale = pl_bhv->colour_red; |
| | 104 | pl_bhv->light->GreenScale = pl_bhv->colour_green; |
| | 105 | pl_bhv->light->BlueScale = pl_bhv->colour_blue; |
| | 106 | } |
| | 107 | pl_bhv->on_off_state = Light_OnOff_On; |
| | 108 | } |
| | 109 | break; |
| | 110 | case Light_OnOff_FadeOff: |
| | 111 | if(pl_bhv->on_off_timer>= pl_bhv->fade_down_time) |
| | 112 | { |
| | 113 | pl_bhv->on_off_timer = 0; |
| | 114 | |
| | 115 | if(!pl_bhv->swap_colour_and_brightness_alterations) |
| | 116 | { |
| | 117 | pl_bhv->light->LightBright = 0; |
| | 118 | } |
| | 119 | else |
| | 120 | { |
| | 121 | pl_bhv->light->RedScale = pl_bhv->colour_red+pl_bhv->colour_diff_red; |
| | 122 | pl_bhv->light->GreenScale = pl_bhv->colour_green+pl_bhv->colour_diff_green; |
| | 123 | pl_bhv->light->BlueScale = pl_bhv->colour_blue+pl_bhv->colour_diff_blue; |
| | 124 | } |
| | 125 | pl_bhv->on_off_state = Light_OnOff_Off; |
| | 126 | } |
| | 127 | break; |
| | 128 | case Light_OnOff_Flicker: |
| | 129 | if(pl_bhv->on_off_timer > 2 * ONE_FIXED) |
| | 130 | { |
| | 131 | pl_bhv->on_off_timer = 0; |
| | 132 | pl_bhv->on_off_state = Light_OnOff_On; |
| | 133 | pl_bhv->light->LightBright = pl_bhv->light->LightBrightStore; |
| | 134 | } |
| | 135 | break; |
| | 136 | default: |
| | 137 | assert(1==0); |
| | 138 | } |
| | 139 | } |
| | 140 | |
| | 141 | |
| | 142 | void InitPlacedLight(void* bhdata, STRATEGYBLOCK *sbPtr) |
| | 143 | { |
| | 144 | TOOLS_DATA_PLACEDLIGHT *toolsData = (TOOLS_DATA_PLACEDLIGHT *)bhdata; |
| | 145 | |
| | 146 | PLACED_LIGHT_BEHAV_BLOCK* pl_bhv = sbPtr->dataptr = malloc(sizeof(PLACED_LIGHT_BEHAV_BLOCK)); |
| | 147 | DYNAMICSBLOCK *dynPtr = sbPtr->DynPtr = AllocateDynamicsBlock(DYNAMICS_TEMPLATE_STATIC); |
| | 148 | |
| | 149 | if((NULL == pl_bhv) || (NULL == dynPtr)) |
| | 150 | { |
| | 151 | RemoveBehaviourStrategy(sbPtr); |
| | 152 | return; |
| | 153 | } |
| | 154 | |
| | 155 | pl_bhv->bhvr_type = I_BehaviourPlacedLight; |
| | 156 | sbPtr->maintainVisibility = 1; |
| | 157 | |
| | 158 | { |
| | 159 | const NPC_DATA *NpcData = &NpcDataList[I_NPC_DefaultInanimate]; |
| | 160 | sbPtr->DamageBlock = NpcData->StartingStats; |
| | 161 | sbPtr->DamageBlock.Health = NpcData->StartingStats.Health << ONE_FIXED_SHIFT; |
| | 162 | sbPtr->DamageBlock.Armour = NpcData->StartingStats.Armour << ONE_FIXED_SHIFT; |
| | 163 | } |
| | 164 | |
| | 165 | pl_bhv->destruct_target_request = toolsData->destruct_target_request; |
| | 166 | { |
| | 167 | int i; |
| | 168 | for(i=0; i < SB_NAME_LENGTH; i++) |
| | 169 | pl_bhv->destruct_target_ID[i] = toolsData->destruct_target_ID[i]; |
| | 170 | } |
| | 171 | |
| | 172 | pl_bhv->destruct_target_sbptr = 0; |
| | 173 | pl_bhv->sequence = toolsData->sequence; |
| | 174 | pl_bhv->colour_red = toolsData->colour_red; |
| | 175 | pl_bhv->colour_green = toolsData->colour_green; |
| | 176 | pl_bhv->colour_blue = toolsData->colour_blue; |
| | 177 | pl_bhv->colour_diff_red = toolsData->colour_diff_red; |
| | 178 | pl_bhv->colour_diff_green = toolsData->colour_diff_green; |
| | 179 | pl_bhv->colour_diff_blue = toolsData->colour_diff_blue; |
| | 180 | pl_bhv->fade_up_time = toolsData->fade_up_time; |
| | 181 | pl_bhv->fade_down_time = toolsData->fade_down_time; |
| | 182 | pl_bhv->up_time = toolsData->up_time; |
| | 183 | pl_bhv->down_time = toolsData->down_time; |
| | 184 | pl_bhv->timer = toolsData->timer; |
| | 185 | pl_bhv->flicker_timer = 0; |
| | 186 | pl_bhv->type = toolsData->type; |
| | 187 | pl_bhv->on_off_type = toolsData->on_off_type; |
| | 188 | pl_bhv->state = toolsData->state; |
| | 189 | pl_bhv->on_off_state = toolsData->on_off_state; |
| | 190 | pl_bhv->swap_colour_and_brightness_alterations = toolsData->swap_colour_and_brightness_alterations; |
| | 191 | pl_bhv->on_off_timer = 0; |
| | 192 | pl_bhv->has_broken_sequence = 1; |
| | 193 | pl_bhv->has_corona = 0; |
| | 194 | |
| | 195 | sbPtr->DamageBlock.Health *= toolsData->integrity; |
| | 196 | |
| | 197 | if(!toolsData->static_light) |
| | 198 | { |
| | 199 | dynPtr->Elasticity = 16384; |
| | 200 | //dynPtr->IsStatic = 0; |
| | 201 | dynPtr->IsInanimate = 1; |
| | 202 | } |
| | 203 | |
| | 204 | dynPtr->Mass = 1; |
| | 205 | dynPtr->IsStatic = 0; |
| | 206 | dynPtr->IsNetGhost = 1; |
| | 207 | dynPtr->GravityOn = 0; |
| | 208 | dynPtr->Mass = toolsData->mass; |
| | 209 | |
| | 210 | dynPtr->PrevPosition = dynPtr->Position = toolsData->position; |
| | 211 | dynPtr->OrientEuler = toolsData->orientation; |
| | 212 | CreateEulerMatrix(&dynPtr->OrientEuler, &dynPtr->OrientMat); |
| | 213 | TransposeMatrixCH(&dynPtr->OrientMat); |
| | 214 | sbPtr->containingModule = ModuleFromPosition(&sbPtr->DynPtr->Position, NULL); |
| | 215 | |
| | 216 | if (NULL == sbPtr->containingModule) |
| | 217 | { |
| | 218 | //printf("no containing module for placed light\n"); |
| | 219 | RemoveBehaviourStrategy(sbPtr); |
| | 220 | return; |
| | 221 | } |
| | 222 | |
| | 223 | if(!UserProfile.GameOptions.AllLightsDestructable) |
| | 224 | sbPtr->DamageBlock.Indestructable = (toolsData->integrity > 20); |
| | 225 | |
| | 226 | /*check to see if object is animated.*/ |
| | 227 | /*also check for corona flag at the same time*/ |
| | 228 | { |
| | 229 | int item_num = 0; |
| | 230 | struct shapeheader* shptr = mainshapelist[sbPtr->shapeIndex]; |
| | 231 | TXACTRLBLK **pptxactrlblk = &pl_bhv->inan_tac; |
| | 232 | |
| | 233 | for(; item_num < shptr->numitems; item_num ++) |
| | 234 | { |
| | 235 | POLYHEADER *poly = (POLYHEADER*)(shptr->items[item_num]); |
| | 236 | assert(poly); |
| | 237 | |
| | 238 | if(poly->PolyFlags & iflag_txanim) |
| | 239 | { |
| | 240 | TXACTRLBLK *pnew_txactrlblk = malloc(sizeof(TXACTRLBLK)); |
| | 241 | |
| | 242 | if(pnew_txactrlblk) |
| | 243 | { |
| | 244 | pnew_txactrlblk->tac_flags = 0; |
| | 245 | pnew_txactrlblk->tac_item = item_num; |
| | 246 | pnew_txactrlblk->tac_sequence = 0; |
| | 247 | pnew_txactrlblk->tac_node = 0; |
| | 248 | pnew_txactrlblk->tac_txarray = GetTxAnimArrayZ(sbPtr->shapeIndex, item_num); |
| | 249 | pnew_txactrlblk->tac_txah_s = GetTxAnimHeaderFromShape(pnew_txactrlblk, sbPtr->shapeIndex); |
| | 250 | *pptxactrlblk = pnew_txactrlblk; |
| | 251 | pptxactrlblk = &pnew_txactrlblk->tac_next; |
| | 252 | |
| | 253 | { |
| | 254 | //see how many sequences there are |
| | 255 | int num_seq = 0; |
| | 256 | while(pnew_txactrlblk->tac_txarray[num_seq + 1]) |
| | 257 | num_seq++; |
| | 258 | |
| | 259 | if(num_seq < 3 ) |
| | 260 | pl_bhv->has_broken_sequence = 0; |
| | 261 | |
| | 262 | assert(num_seq >= 2); |
| | 263 | } |
| | 264 | } |
| | 265 | else |
| | 266 | { |
| | 267 | *pptxactrlblk = NULL; |
| | 268 | } |
| | 269 | } |
| | 270 | |
| | 271 | if(poly->PolyFlags & iflag_light_corona) |
| | 272 | { |
| | 273 | int* vertexptr = &poly->Poly1stPt; |
| | 274 | int num_verts = 0; |
| | 275 | |
| | 276 | pl_bhv->has_corona = 1; |
| | 277 | pl_bhv->corona_location.vx = pl_bhv->corona_location.vy = pl_bhv->corona_location.vz = 0; |
| | 278 | |
| | 279 | //take the average of all the points in the polygon |
| | 280 | while(*vertexptr != -1) |
| | 281 | { |
| | 282 | num_verts++; |
| | 283 | |
| | 284 | VECTORCH *v1 = (VECTORCH*)&shptr->points[0][(*vertexptr)*3]; |
| | 285 | pl_bhv->corona_location.vx += v1->vx; |
| | 286 | pl_bhv->corona_location.vy += v1->vy; |
| | 287 | pl_bhv->corona_location.vz += v1->vz; |
| | 288 | |
| | 289 | vertexptr++; |
| | 290 | } |
| | 291 | pl_bhv->corona_location.vx /= num_verts; |
| | 292 | pl_bhv->corona_location.vy /= num_verts; |
| | 293 | pl_bhv->corona_location.vz /= num_verts; |
| | 294 | } |
| | 295 | |
| | 296 | if(poly->PolyFlags & iflag_transparent) |
| | 297 | poly->PolyFlags |= iflag_glowing; |
| | 298 | } |
| | 299 | |
| | 300 | *pptxactrlblk = 0; |
| | 301 | |
| | 302 | pl_bhv->light = toolsData->light; |
| | 303 | assert(pl_bhv->light); |
| | 304 | |
| | 305 | pl_bhv->light->RedScale = pl_bhv->colour_red; |
| | 306 | pl_bhv->light->GreenScale = pl_bhv->colour_green; |
| | 307 | pl_bhv->light->BlueScale = pl_bhv->colour_blue; |
| | 308 | |
| | 309 | if(!AvP.RestartLevel) |
| | 310 | { |
| | 311 | pl_bhv->light->LightBright *= 2; |
| | 312 | pl_bhv->light->LightRange *= 3; |
| | 313 | pl_bhv->light->LightBrightStore *= 2; |
| | 314 | } |
| | 315 | } |
| | 316 | |
| | 317 | if(!pl_bhv->inan_tac) |
| | 318 | pl_bhv->has_broken_sequence = 0; |
| | 319 | |
| | 320 | SetTextureAnimationSequence(sbPtr->shapeIndex, pl_bhv->inan_tac, pl_bhv->sequence); |
| | 321 | |
| | 322 | if(SinglePlayer != AvP.PlayMode) |
| | 323 | { |
| | 324 | //If playing a network game with predestroyed lights , get rid of this light |
| | 325 | if(netGameData.preDestroyLights && !sbPtr->DamageBlock.Indestructable) |
| | 326 | KillLightForRespawn(sbPtr); |
| | 327 | } |
| | 328 | |
| | 329 | { |
| | 330 | int i; |
| | 331 | for(i=0; i < SB_NAME_LENGTH; i++) |
| | 332 | sbPtr->SBname[i] = toolsData->nameID[i]; |
| | 333 | } |
| | 334 | |
| | 335 | UpdatePlacedLightState(pl_bhv); |
| | 336 | |
| | 337 | /* these must be initialised for respawning objects in multiplayer game */ |
| | 338 | pl_bhv->startingHealth = sbPtr->DamageBlock.Health; |
| | 339 | pl_bhv->startingArmour = sbPtr->DamageBlock.Armour; |
| | 340 | } |
| | 341 | |
| | 342 | static void UpdatePlacedLightColour(PLACED_LIGHT_BEHAV_BLOCK* pl_bhv) |
| | 343 | { |
| | 344 | int mult; |
| | 345 | assert(pl_bhv); |
| | 346 | |
| | 347 | //first alter colour for stobing lights |
| | 348 | switch(pl_bhv->state) |
| | 349 | { |
| | 350 | case Light_State_Broken: |
| | 351 | break; |
| | 352 | case Light_State_Standard: |
| | 353 | if(pl_bhv->on_off_state != Light_OnOff_Off) |
| | 354 | { |
| | 355 | pl_bhv->light->RedScale = pl_bhv->colour_red; |
| | 356 | pl_bhv->light->GreenScale = pl_bhv->colour_green; |
| | 357 | pl_bhv->light->BlueScale = pl_bhv->colour_blue; |
| | 358 | } |
| | 359 | break; |
| | 360 | case Light_State_StrobeUpDelay: |
| | 361 | if(!pl_bhv->swap_colour_and_brightness_alterations) |
| | 362 | { |
| | 363 | pl_bhv->light->RedScale = pl_bhv->colour_red; |
| | 364 | pl_bhv->light->GreenScale = pl_bhv->colour_green; |
| | 365 | pl_bhv->light->BlueScale = pl_bhv->colour_blue; |
| | 366 | } |
| | 367 | else |
| | 368 | { |
| | 369 | pl_bhv->light->LightBright = pl_bhv->light->LightBrightStore; |
| | 370 | } |
| | 371 | break; |
| | 372 | case Light_State_StrobeDownDelay: |
| | 373 | if(!pl_bhv->swap_colour_and_brightness_alterations) |
| | 374 | { |
| | 375 | pl_bhv->light->RedScale = pl_bhv->colour_red+pl_bhv->colour_diff_red; |
| | 376 | pl_bhv->light->GreenScale = pl_bhv->colour_green+pl_bhv->colour_diff_green; |
| | 377 | pl_bhv->light->BlueScale = pl_bhv->colour_blue+pl_bhv->colour_diff_blue; |
| | 378 | } |
| | 379 | else |
| | 380 | { |
| | 381 | pl_bhv->light->LightBright = 0; |
| | 382 | } |
| | 383 | break; |
| | 384 | case Light_State_StrobeUp: |
| | 385 | mult = DIV_FIXED(pl_bhv->fade_up_time-pl_bhv->timer,pl_bhv->fade_up_time); |
| | 386 | |
| | 387 | if(!pl_bhv->swap_colour_and_brightness_alterations) |
| | 388 | { |
| | 389 | pl_bhv->light->RedScale = pl_bhv->colour_red+MUL_FIXED(pl_bhv->colour_diff_red,mult); |
| | 390 | pl_bhv->light->GreenScale = pl_bhv->colour_green+MUL_FIXED(pl_bhv->colour_diff_green,mult); |
| | 391 | pl_bhv->light->BlueScale = pl_bhv->colour_blue+MUL_FIXED(pl_bhv->colour_diff_blue,mult); |
| | 392 | } |
| | 393 | else |
| | 394 | { |
| | 395 | mult = ONE_FIXED - mult; |
| | 396 | pl_bhv->light->LightBright = MUL_FIXED(pl_bhv->light->LightBrightStore, mult); |
| | 397 | } |
| | 398 | break; |
| | 399 | case Light_State_StrobeDown: |
| | 400 | mult = DIV_FIXED(pl_bhv->timer,pl_bhv->fade_down_time); |
| | 401 | |
| | 402 | if(!pl_bhv->swap_colour_and_brightness_alterations) |
| | 403 | { |
| | 404 | pl_bhv->light->RedScale = pl_bhv->colour_red+MUL_FIXED(pl_bhv->colour_diff_red,mult); |
| | 405 | pl_bhv->light->GreenScale = pl_bhv->colour_green+MUL_FIXED(pl_bhv->colour_diff_green,mult); |
| | 406 | pl_bhv->light->BlueScale = pl_bhv->colour_blue+MUL_FIXED(pl_bhv->colour_diff_blue,mult); |
| | 407 | } |
| | 408 | else |
| | 409 | { |
| | 410 | mult = ONE_FIXED - mult; |
| | 411 | pl_bhv->light->LightBright = MUL_FIXED(pl_bhv->light->LightBrightStore,mult); |
| | 412 | } |
| | 413 | break; |
| | 414 | case Light_State_Flicker: |
| | 415 | if(pl_bhv->on_off_state == Light_OnOff_On) |
| | 416 | { |
| | 417 | if(pl_bhv->flicker_timer >= 1750) |
| | 418 | { |
| | 419 | mult = FastRandom() & 0xffff; |
| | 420 | |
| | 421 | if (!((mult % 24 ) >> 3)) |
| | 422 | mult |= 0xa000; |
| | 423 | else |
| | 424 | mult &=~ 0xf000; |
| | 425 | |
| | 426 | pl_bhv->light->LightBright = MUL_FIXED(pl_bhv->light->LightBrightStore, mult); |
| | 427 | } |
| | 428 | } |
| | 429 | break; |
| | 430 | default: |
| | 431 | assert(1==0); |
| | 432 | } |
| | 433 | |
| | 434 | //now alter brightness for switching on/off |
| | 435 | switch(pl_bhv->on_off_state) |
| | 436 | { |
| | 437 | case Light_OnOff_Off: |
| | 438 | if(!pl_bhv->swap_colour_and_brightness_alterations) |
| | 439 | { |
| | 440 | pl_bhv->light->LightBright = 0; |
| | 441 | } |
| | 442 | else |
| | 443 | { |
| | 444 | pl_bhv->light->RedScale = pl_bhv->colour_red+pl_bhv->colour_diff_red; |
| | 445 | pl_bhv->light->GreenScale = pl_bhv->colour_green+pl_bhv->colour_diff_green; |
| | 446 | pl_bhv->light->BlueScale = pl_bhv->colour_blue+pl_bhv->colour_diff_blue; |
| | 447 | } |
| | 448 | break; |
| | 449 | case Light_OnOff_On: |
| | 450 | if(pl_bhv->state != Light_State_Flicker) |
| | 451 | { |
| | 452 | if(!pl_bhv->swap_colour_and_brightness_alterations) |
| | 453 | { |
| | 454 | pl_bhv->light->LightBright = pl_bhv->light->LightBrightStore; |
| | 455 | } |
| | 456 | else |
| | 457 | { |
| | 458 | pl_bhv->light->RedScale = pl_bhv->colour_red; |
| | 459 | pl_bhv->light->GreenScale = pl_bhv->colour_green; |
| | 460 | pl_bhv->light->BlueScale = pl_bhv->colour_blue; |
| | 461 | } |
| | 462 | } |
| | 463 | break; |
| | 464 | case Light_OnOff_FadeOn: |
| | 465 | mult = DIV_FIXED(pl_bhv->on_off_timer,pl_bhv->fade_up_time); |
| | 466 | |
| | 467 | if(!pl_bhv->swap_colour_and_brightness_alterations) |
| | 468 | { |
| | 469 | pl_bhv->light->LightBright = MUL_FIXED(pl_bhv->light->LightBrightStore,mult); |
| | 470 | } |
| | 471 | else |
| | 472 | { |
| | 473 | mult = ONE_FIXED - mult; |
| | 474 | pl_bhv->light->RedScale = pl_bhv->colour_red+MUL_FIXED(pl_bhv->colour_diff_red,mult); |
| | 475 | pl_bhv->light->GreenScale = pl_bhv->colour_green+MUL_FIXED(pl_bhv->colour_diff_green,mult); |
| | 476 | pl_bhv->light->BlueScale = pl_bhv->colour_blue+MUL_FIXED(pl_bhv->colour_diff_blue,mult); |
| | 477 | } |
| | 478 | break; |
| | 479 | case Light_OnOff_FadeOff: |
| | 480 | mult = DIV_FIXED(pl_bhv->fade_down_time-pl_bhv->on_off_timer,pl_bhv->fade_down_time); |
| | 481 | |
| | 482 | if(!pl_bhv->swap_colour_and_brightness_alterations) |
| | 483 | { |
| | 484 | pl_bhv->light->LightBright = MUL_FIXED(pl_bhv->light->LightBrightStore,mult); |
| | 485 | } |
| | 486 | else |
| | 487 | { |
| | 488 | mult = ONE_FIXED - mult; |
| | 489 | pl_bhv->light->RedScale = pl_bhv->colour_red+MUL_FIXED(pl_bhv->colour_diff_red,mult); |
| | 490 | pl_bhv->light->GreenScale = pl_bhv->colour_green+MUL_FIXED(pl_bhv->colour_diff_green,mult); |
| | 491 | pl_bhv->light->BlueScale = pl_bhv->colour_blue+MUL_FIXED(pl_bhv->colour_diff_blue,mult); |
| | 492 | } |
| | 493 | break; |
| | 494 | case Light_OnOff_Flicker: |
| | 495 | if(pl_bhv->flicker_timer >= 3500) |
| | 496 | { |
| | 497 | mult = FastRandom() & 0xffff; |
| | 498 | |
| | 499 | if (!((mult % 24 ) >> 3)) |
| | 500 | mult |= 0xa000; |
| | 501 | else |
| | 502 | mult &=~ 0xf000; |
| | 503 | |
| | 504 | pl_bhv->light->LightBright = MUL_FIXED(pl_bhv->light->LightBrightStore,mult); |
| | 505 | } |
| | 506 | break; |
| | 507 | default: |
| | 508 | assert(1==0); |
| | 509 | } |
| | 510 | } |
| | 511 | |
| | 512 | void KillLightForRespawn(STRATEGYBLOCK *sbPtr) |
| | 513 | { |
| | 514 | /* make the light invisible, and remove it from visibility management */ |
| | 515 | sbPtr->maintainVisibility = 0; |
| | 516 | |
| | 517 | DestroyActiveObject(&sbPtr->DisplayBlock); |
| | 518 | } |
| | 519 | |
| | 520 | void PlacedLightBehaviour(STRATEGYBLOCK *sbPtr) |
| | 521 | { |
| | 522 | PLACED_LIGHT_BEHAV_BLOCK* pl_bhv = sbPtr->dataptr; |
| | 523 | |
| | 524 | if(pl_bhv->inan_tac) |
| | 525 | { |
| | 526 | DISPLAYBLOCK* dptr = sbPtr->DisplayBlock; |
| | 527 | |
| | 528 | /*deal with texture animation*/ |
| | 529 | if(dptr && !dptr->ObTxAnimCtrlBlks) |
| | 530 | dptr->ObTxAnimCtrlBlks = pl_bhv->inan_tac; |
| | 531 | } |
| | 532 | |
| | 533 | //if the light is broken , don't do anything else |
| | 534 | if(pl_bhv->state == Light_State_Broken) |
| | 535 | return; |
| | 536 | |
| | 537 | //update timer if necessary |
| | 538 | if(pl_bhv->on_off_state != Light_OnOff_Off && pl_bhv->on_off_state != Light_OnOff_On) |
| | 539 | { |
| | 540 | pl_bhv->on_off_timer += NormalFrameTime; |
| | 541 | pl_bhv->flicker_timer %= 3500; |
| | 542 | pl_bhv->flicker_timer += NormalFrameTime; |
| | 543 | } |
| | 544 | else |
| | 545 | { |
| | 546 | switch(pl_bhv->state) |
| | 547 | { |
| | 548 | case Light_State_StrobeUp: |
| | 549 | case Light_State_StrobeDown: |
| | 550 | case Light_State_StrobeUpDelay: |
| | 551 | case Light_State_StrobeDownDelay: |
| | 552 | pl_bhv->timer += NormalFrameTime; |
| | 553 | break; |
| | 554 | case Light_State_Flicker: |
| | 555 | pl_bhv->flicker_timer %= 1750; |
| | 556 | pl_bhv->flicker_timer += NormalFrameTime; |
| | 557 | default: |
| | 558 | break; |
| | 559 | } |
| | 560 | } |
| | 561 | |
| | 562 | UpdatePlacedLightState(pl_bhv); |
| | 563 | |
| | 564 | if(sbPtr->DisplayBlock) |
| | 565 | UpdatePlacedLightColour(pl_bhv); |
| | 566 | |
| | 567 | if(sbPtr->DamageBlock.IsOnFire) |
| | 568 | CauseDamageToObject(sbPtr, &TemplateAmmo[AMMO_FLAMETHROWER].MaxDamage, ONE_FIXED/400, NULL); |
| | 569 | } |
| | 570 | |
| | 571 | void MakePlacedLightNear(STRATEGYBLOCK *sbPtr) |
| | 572 | { |
| | 573 | DISPLAYBLOCK *dPtr = CreateActiveObject(); |
| | 574 | |
| | 575 | if(NULL != dPtr) |
| | 576 | { |
| | 577 | DYNAMICSBLOCK *dynPtr = sbPtr->DynPtr; |
| | 578 | PLACED_LIGHT_BEHAV_BLOCK* pl_bhv = (PLACED_LIGHT_BEHAV_BLOCK*) sbPtr->dataptr; |
| | 579 | LIGHTBLOCK *lptr_array = pl_bhv->light; |
| | 580 | |
| | 581 | dPtr->ObShape = sbPtr->shapeIndex; |
| | 582 | dPtr->ShapeData = mainshapelist[sbPtr->shapeIndex]; |
| | 583 | |
| | 584 | /* |
| | 585 | Module lights |
| | 586 | |
| | 587 | There is an option for a pointer to an array of lights in a module |
| | 588 | structure. These lights are transferred to the display block and |
| | 589 | flagged as "LFlag_WasNotAllocated" so that "DeallocateLightBlock()" |
| | 590 | knows to ignore them. |
| | 591 | |
| | 592 | The number of lights in the array is "m_numlights" and the pointer |
| | 593 | is called "m_lightarray". |
| | 594 | |
| | 595 | The addition of non-allocated does not need to be a module specific |
| | 596 | option. |
| | 597 | |
| | 598 | Non-allocated lights can co-exist peacefully with the other lights. |
| | 599 | */ |
| | 600 | |
| | 601 | /* Make sure the light is flagged correctly */ |
| | 602 | |
| | 603 | lptr_array->LightFlags |= LFlag_WasNotAllocated; |
| | 604 | |
| | 605 | AddLightBlock(dPtr, lptr_array); |
| | 606 | |
| | 607 | sbPtr->DisplayBlock = dPtr; |
| | 608 | dPtr->ObStrategyBlock = sbPtr; |
| | 609 | |
| | 610 | dPtr->ObWorld = dynPtr->Position; |
| | 611 | dPtr->ObEuler = dynPtr->OrientEuler; |
| | 612 | dPtr->ObMat = dynPtr->OrientMat; |
| | 613 | |
| | 614 | dPtr->extent.min_x = -100; |
| | 615 | dPtr->extent.max_x = 100; |
| | 616 | dPtr->extent.min_z = -100; |
| | 617 | dPtr->extent.max_z = 100; |
| | 618 | dPtr->extent.min_y = 100; |
| | 619 | dPtr->extent.max_y = 100; |
| | 620 | dPtr->extent.radius = 300; |
| | 621 | |
| | 622 | dPtr->ObFlags3 |= ObFlag3_NoLightDot; //so light will light itself |
| | 623 | UpdatePlacedLightColour(pl_bhv); |
| | 624 | } |
| | 625 | } |
| | 626 | |
| | 627 | void RespawnLight(STRATEGYBLOCK *sbPtr) |
| | 628 | { |
| | 629 | PLACED_LIGHT_BEHAV_BLOCK* pl_bhv = sbPtr->dataptr; |
| | 630 | |
| | 631 | if(netGameData.preDestroyLights) |
| | 632 | return; //don't restore lights for this type of net game |
| | 633 | |
| | 634 | if(pl_bhv->state == Light_State_Broken) |
| | 635 | { |
| | 636 | sbPtr->maintainVisibility = 1; |
| | 637 | |
| | 638 | /* must respawn health too... */ |
| | 639 | sbPtr->DamageBlock.Health = pl_bhv->startingHealth; |
| | 640 | sbPtr->DamageBlock.Armour = pl_bhv->startingArmour; |
| | 641 | |
| | 642 | //reactivate the light |
| | 643 | pl_bhv->sequence = 1; |
| | 644 | pl_bhv->light->LightBright = pl_bhv->light->LightBrightStore; |
| | 645 | pl_bhv->on_off_state = Light_OnOff_On; |
| | 646 | |
| | 647 | switch(pl_bhv->type) |
| | 648 | { |
| | 649 | case Light_Type_Standard: |
| | 650 | pl_bhv->state = Light_State_Standard; |
| | 651 | break; |
| | 652 | case Light_Type_Strobe: |
| | 653 | pl_bhv->state = Light_State_StrobeUpDelay; |
| | 654 | break; |
| | 655 | case Light_Type_Flicker: |
| | 656 | pl_bhv->state = Light_State_Flicker; |
| | 657 | } |
| | 658 | |
| | 659 | //need to use the on animation sequence again |
| | 660 | SetTextureAnimationSequence(sbPtr->shapeIndex, pl_bhv->inan_tac, pl_bhv->sequence); |
| | 661 | |
| | 662 | UpdatePlacedLightState(pl_bhv); |
| | 663 | } |
| | 664 | } |
| | 665 | |
| | 666 | /* this global flag is used to distinguish between messages from the host, and locally caused damage */ |
| | 667 | extern int InanimateDamageFromNetHost; |
| | 668 | |
| | 669 | void PlacedLightIsDamaged(STRATEGYBLOCK *sbPtr, const DAMAGE_PROFILE *damage, int multiple) |
| | 670 | { |
| | 671 | PLACED_LIGHT_BEHAV_BLOCK* pl_bhv = sbPtr->dataptr; |
| | 672 | |
| | 673 | if(pl_bhv->state == Light_State_Broken) |
| | 674 | { |
| | 675 | if (!sbPtr->DamageBlock.Indestructable && !pl_bhv->has_broken_sequence) |
| | 676 | { |
| | 677 | if(SinglePlayer == AvP.PlayMode) |
| | 678 | sbPtr->please_destroy_me = 1; |
| | 679 | else |
| | 680 | KillLightForRespawn(sbPtr); |
| | 681 | } |
| | 682 | return; |
| | 683 | } |
| | 684 | |
| | 685 | if((NetworkPeer == AvP.PlayMode) && !InanimateDamageFromNetHost) |
| | 686 | { |
| | 687 | //add light damaged net message |
| | 688 | AddNetMsg_InanimateObjectDamaged(sbPtr, damage, multiple); |
| | 689 | return; |
| | 690 | } |
| | 691 | |
| | 692 | if(sbPtr->DamageBlock.Health <= 0) |
| | 693 | { |
| | 694 | if(NetworkHost == AvP.PlayMode) |
| | 695 | { |
| | 696 | AddNetMsg_InanimateObjectDestroyed(sbPtr); |
| | 697 | return; |
| | 698 | } |
| | 699 | |
| | 700 | //change to broken sequence if it exists. |
| | 701 | //otherwise destroy light |
| | 702 | pl_bhv->state = Light_State_Broken; |
| | 703 | pl_bhv->on_off_state = Light_OnOff_Off; |
| | 704 | pl_bhv->sequence = 2; |
| | 705 | pl_bhv->light->LightBright = 0; |
| | 706 | |
| | 707 | //notify target of destruction |
| | 708 | if(pl_bhv->destruct_target_sbptr) |
| | 709 | RequestState(pl_bhv->destruct_target_sbptr, pl_bhv->destruct_target_request, 0); |
| | 710 | |
| | 711 | /* KJL 17:08:44 10/07/98 - Make some sparks */ |
| | 712 | if (sbPtr->DisplayBlock) |
| | 713 | MakeSprayOfSparks(&sbPtr->DisplayBlock->ObMat, &sbPtr->DisplayBlock->ObWorld); |
| | 714 | |
| | 715 | if(pl_bhv->has_broken_sequence) |
| | 716 | { |
| | 717 | SetTextureAnimationSequence(sbPtr->shapeIndex, pl_bhv->inan_tac, pl_bhv->sequence); |
| | 718 | } |
| | 719 | else |
| | 720 | { |
| | 721 | MakeFragments(sbPtr); // Actually only sound |
| | 722 | |
| | 723 | if(SinglePlayer == AvP.PlayMode) |
| | 724 | sbPtr->please_destroy_me = 1; |
| | 725 | else |
| | 726 | KillLightForRespawn(sbPtr); |
| | 727 | } |
| | 728 | } |
| | 729 | } |
| | 730 | |
| | 731 | #define LightRequest_AdjustIntegrity 0x00000001 |
| | 732 | #define LightRequest_AdjustType_Standard 0x00000002 |
| | 733 | #define LightRequest_AdjustType_Strobe 0x00000004 |
| | 734 | #define LightRequest_AdjustType_Flicker 0x00000008 |
| | 735 | #define LightRequest_SwapUpAndDown 0x00000010 |
| | 736 | |
| | 737 | void SendRequestToPlacedLight(STRATEGYBLOCK* sbptr, int state, int extended_data) |
| | 738 | { |
| | 739 | PLACED_LIGHT_BEHAV_BLOCK* pl_bhv = sbptr->dataptr; |
| | 740 | assert(pl_bhv); |
| | 741 | |
| | 742 | if(pl_bhv->state == Light_State_Broken) |
| | 743 | return; |
| | 744 | |
| | 745 | if(extended_data) |
| | 746 | { |
| | 747 | if(extended_data & LightRequest_AdjustIntegrity) |
| | 748 | { |
| | 749 | if(state) |
| | 750 | { |
| | 751 | int new_integrity = (extended_data >> 7) & 0xff; |
| | 752 | sbptr->DamageBlock.Indestructable = (new_integrity > 20); |
| | 753 | |
| | 754 | if(!new_integrity) |
| | 755 | { |
| | 756 | sbptr->DamageBlock.Health = 0; |
| | 757 | PlacedLightIsDamaged(sbptr, &damage_profiles[CERTAINDEATH], ONE_FIXED); |
| | 758 | } |
| | 759 | else |
| | 760 | sbptr->DamageBlock.Health = (10 << ONE_FIXED_SHIFT) * new_integrity; |
| | 761 | } |
| | 762 | } |
| | 763 | |
| | 764 | if(state) |
| | 765 | { |
| | 766 | if(extended_data & (LightRequest_AdjustType_Standard | LightRequest_AdjustType_Flicker)) |
| | 767 | { |
| | 768 | /* changing state, try to preserve strobe timer */ |
| | 769 | switch(pl_bhv->state) |
| | 770 | { |
| | 771 | /* lack of break's intended */ |
| | 772 | case Light_State_StrobeUpDelay: |
| | 773 | pl_bhv->timer += pl_bhv->fade_up_time; |
| | 774 | |
| | 775 | case Light_State_StrobeUp: |
| | 776 | pl_bhv->timer += pl_bhv->down_time; |
| | 777 | |
| | 778 | case Light_State_StrobeDownDelay: |
| | 779 | pl_bhv->timer += pl_bhv->fade_down_time; |
| | 780 | default: |
| | 781 | break; |
| | 782 | } |
| | 783 | } |
| | 784 | |
| | 785 | if(extended_data & LightRequest_AdjustType_Standard) |
| | 786 | { |
| | 787 | pl_bhv->type = Light_Type_Standard; |
| | 788 | pl_bhv->state = Light_State_Standard; |
| | 789 | } |
| | 790 | |
| | 791 | if(extended_data & LightRequest_AdjustType_Flicker) |
| | 792 | { |
| | 793 | pl_bhv->type = Light_Type_Flicker; |
| | 794 | pl_bhv->state = Light_State_Flicker; |
| | 795 | } |
| | 796 | |
| | 797 | if(extended_data & LightRequest_AdjustType_Strobe) |
| | 798 | { |
| | 799 | if(pl_bhv->type != Light_Type_Strobe) |
| | 800 | { |
| | 801 | pl_bhv->type = Light_Type_Strobe; |
| | 802 | pl_bhv->state = Light_State_StrobeDown; |
| | 803 | } |
| | 804 | } |
| | 805 | |
| | 806 | if(extended_data & LightRequest_SwapUpAndDown) |
| | 807 | { |
| | 808 | //swap the up and down colours for the light |
| | 809 | int temp_red = pl_bhv->colour_red; |
| | 810 | int temp_green = pl_bhv->colour_green; |
| | 811 | int temp_blue = pl_bhv->colour_blue; |
| | 812 | |
| | 813 | pl_bhv->colour_red += pl_bhv->colour_diff_red; |
| | 814 | pl_bhv->colour_green += pl_bhv->colour_diff_green; |
| | 815 | pl_bhv->colour_blue += pl_bhv->colour_diff_blue; |
| | 816 | |
| | 817 | pl_bhv->colour_diff_red = temp_red-pl_bhv->colour_red; |
| | 818 | pl_bhv->colour_diff_blue = temp_blue-pl_bhv->colour_blue; |
| | 819 | pl_bhv->colour_diff_green = temp_green-pl_bhv->colour_green; |
| | 820 | } |
| | 821 | } |
| | 822 | } |
| | 823 | else |
| | 824 | { |
| | 825 | if(state) //switch light on |
| | 826 | { |
| | 827 | if(pl_bhv->on_off_state != Light_OnOff_On) |
| | 828 | { |
| | 829 | switch(pl_bhv->on_off_type) |
| | 830 | { |
| | 831 | case Light_OnOff_Type_Fade: |
| | 832 | { |
| | 833 | switch(pl_bhv->on_off_state) |
| | 834 | { |
| | 835 | case Light_OnOff_FadeOn: |
| | 836 | break; |
| | 837 | |
| | 838 | case Light_OnOff_FadeOff: |
| | 839 | { |
| | 840 | //reverse direction of fade |
| | 841 | int mult = ONE_FIXED-DIV_FIXED(pl_bhv->on_off_timer,pl_bhv->fade_down_time); |
| | 842 | pl_bhv->on_off_timer = MUL_FIXED(mult,pl_bhv->fade_up_time); |
| | 843 | pl_bhv->on_off_state = Light_OnOff_FadeOn; |
| | 844 | } |
| | 845 | break; |
| | 846 | case Light_OnOff_Off: |
| | 847 | { |
| | 848 | //start to fade up |
| | 849 | pl_bhv->on_off_timer = 0; |
| | 850 | pl_bhv->on_off_state = Light_OnOff_FadeOn; |
| | 851 | } |
| | 852 | break; |
| | 853 | default: |
| | 854 | { |
| | 855 | assert(0); |
| | 856 | } |
| | 857 | } |
| | 858 | } |
| | 859 | break; |
| | 860 | case Light_OnOff_Type_Standard: |
| | 861 | pl_bhv->on_off_state = Light_OnOff_On; |
| | 862 | break; |
| | 863 | case Light_OnOff_Type_Flicker: |
| | 864 | if(pl_bhv->on_off_state != Light_OnOff_Flicker) |
| | 865 | { |
| | 866 | pl_bhv->on_off_state = Light_OnOff_Flicker; |
| | 867 | pl_bhv->on_off_timer = 0; |
| | 868 | |
| | 869 | //light is flickering on , so play the flickering on sound |
| | 870 | Sound_Play(SID_LIGHT_FLICKER_ON, "d", &sbptr->DynPtr->Position); |
| | 871 | } |
| | 872 | break; |
| | 873 | default : |
| | 874 | assert(1==0); |
| | 875 | break; |
| | 876 | } |
| | 877 | } |
| | 878 | } |
| | 879 | else //switch the light off |
| | 880 | { |
| | 881 | if(pl_bhv->on_off_state != Light_OnOff_Off) |
| | 882 | { |
| | 883 | switch(pl_bhv->on_off_type) |
| | 884 | { |
| | 885 | case Light_OnOff_Type_Fade: |
| | 886 | { |
| | 887 | switch(pl_bhv->on_off_state) |
| | 888 | { |
| | 889 | case Light_OnOff_On: |
| | 890 | //start to fade down |
| | 891 | pl_bhv->on_off_timer = 0; |
| | 892 | pl_bhv->on_off_state = Light_OnOff_FadeOff; |
| | 893 | break; |
| | 894 | case Light_OnOff_FadeOn: |
| | 895 | //reverse direction of fade |
| | 896 | { |
| | 897 | int mult = ONE_FIXED-DIV_FIXED(pl_bhv->on_off_timer,pl_bhv->fade_up_time); |
| | 898 | pl_bhv->on_off_timer = MUL_FIXED(mult,pl_bhv->fade_down_time); |
| | 899 | pl_bhv->on_off_state = Light_OnOff_FadeOff; |
| | 900 | } |
| | 901 | break; |
| | 902 | case Light_OnOff_FadeOff: |
| | 903 | break; |
| | 904 | default: |
| | 905 | { |
| | 906 | assert(0); |
| | 907 | } |
| | 908 | } |
| | 909 | } |
| | 910 | break; |
| | 911 | case Light_OnOff_Type_Standard: |
| | 912 | case Light_OnOff_Type_Flicker: |
| | 913 | { |
| | 914 | pl_bhv->on_off_state = Light_OnOff_Off; |
| | 915 | |
| | 916 | if(!pl_bhv->swap_colour_and_brightness_alterations) |
| | 917 | { |
| | 918 | pl_bhv->light->LightBright = 0; |
| | 919 | } |
| | 920 | else |
| | 921 | { |
| | 922 | pl_bhv->light->RedScale = pl_bhv->colour_red+pl_bhv->colour_diff_red; |
| | 923 | pl_bhv->light->GreenScale = pl_bhv->colour_green+pl_bhv->colour_diff_green; |
| | 924 | pl_bhv->light->BlueScale = pl_bhv->colour_blue+pl_bhv->colour_diff_blue; |
| | 925 | } |
| | 926 | } |
| | 927 | break; |
| | 928 | default: |
| | 929 | assert(1==0); |
| | 930 | break; |
| | 931 | } |
| | 932 | } |
| | 933 | } |
| | 934 | } |
| | 935 | |
| | 936 | pl_bhv->sequence = (pl_bhv->on_off_state != Light_OnOff_Off); |
| | 937 | |
| | 938 | SetTextureAnimationSequence(sbptr->shapeIndex, pl_bhv->inan_tac, pl_bhv->sequence); |
| | 939 | } |
| | 940 | |
| | 941 | /*--------------------** |
| | 942 | ** Loading and Saving ** |
| | 943 | **--------------------*/ |
| | 944 | #include "savegame.h" |
| | 945 | |
| | 946 | typedef struct placed_light_save_block |
| | 947 | { |
| | 948 | SAVE_BLOCK_STRATEGY_HEADER header; |
| | 949 | |
| | 950 | LIGHT_TYPE type; |
| | 951 | LIGHT_STATE state; |
| | 952 | LIGHT_ON_OFF_STATE on_off_state; |
| | 953 | int sequence; //texture animation sequence |
| | 954 | int colour_red; //colour for fade up state |
| | 955 | int colour_green; |
| | 956 | int colour_blue; |
| | 957 | int colour_diff_red; //difference from up colour to down colour |
| | 958 | int colour_diff_green; |
| | 959 | int colour_diff_blue; |
| | 960 | int timer; |
| | 961 | int on_off_timer; |
| | 962 | int flicker_timer; |
| | 963 | |
| | 964 | //strategyblock stuff |
| | 965 | DAMAGEBLOCK DamageBlock; |
| | 966 | |
| | 967 | } PLACED_LIGHT_SAVE_BLOCK; |
| | 968 | |
| | 969 | //defines for load/save macros |
| | 970 | #define SAVELOAD_BLOCK block |
| | 971 | #define SAVELOAD_BEHAV pl_bhv |
| | 972 | |
| | 973 | void LoadStrategy_PlacedLight(SAVE_BLOCK_STRATEGY_HEADER* header) |
| | 974 | { |
| | 975 | PLACED_LIGHT_SAVE_BLOCK* block = (PLACED_LIGHT_SAVE_BLOCK*) header; |
| | 976 | |
| | 977 | //check the size of the save block |
| | 978 | if(header->size != sizeof(*block)) |
| | 979 | return; |
| | 980 | |
| | 981 | //find the existing strategy block |
| | 982 | STRATEGYBLOCK* sbPtr = FindSBWithName(header->SBname); |
| | 983 | |
| | 984 | if(!sbPtr) |
| | 985 | return; |
| | 986 | |
| | 987 | //make sure the strategy found is of the right type |
| | 988 | if(sbPtr->type != I_BehaviourPlacedLight) |
| | 989 | return; |
| | 990 | |
| | 991 | PLACED_LIGHT_BEHAV_BLOCK* pl_bhv = sbPtr->dataptr; |
| | 992 | |
| | 993 | //start copying stuff |
| | 994 | |
| | 995 | COPYELEMENT_LOAD(type); |
| | 996 | COPYELEMENT_LOAD(state); |
| | 997 | COPYELEMENT_LOAD(on_off_state); |
| | 998 | COPYELEMENT_LOAD(sequence); //texture animation sequence |
| | 999 | COPYELEMENT_LOAD(colour_red); //colour for fade up state |
| | 1000 | COPYELEMENT_LOAD(colour_green); |
| | 1001 | COPYELEMENT_LOAD(colour_blue); |
| | 1002 | COPYELEMENT_LOAD(colour_diff_red); //difference from up colour to down colour |
| | 1003 | COPYELEMENT_LOAD(colour_diff_green); |
| | 1004 | COPYELEMENT_LOAD(colour_diff_blue); |
| | 1005 | COPYELEMENT_LOAD(timer); |
| | 1006 | COPYELEMENT_LOAD(on_off_timer); |
| | 1007 | COPYELEMENT_LOAD(flicker_timer); |
| | 1008 | |
| | 1009 | sbPtr->DamageBlock = block->DamageBlock; |
| | 1010 | |
| | 1011 | SetTextureAnimationSequence(sbPtr->shapeIndex, pl_bhv->inan_tac, pl_bhv->sequence); |
| | 1012 | UpdatePlacedLightColour(pl_bhv); |
| | 1013 | } |
| | 1014 | |
| | 1015 | void SaveStrategy_PlacedLight(STRATEGYBLOCK* sbPtr) |
| | 1016 | { |
| | 1017 | PLACED_LIGHT_SAVE_BLOCK *block; |
| | 1018 | PLACED_LIGHT_BEHAV_BLOCK* pl_bhv = sbPtr->dataptr; |
| | 1019 | |
| | 1020 | GET_STRATEGY_SAVE_BLOCK(block,sbPtr); |
| | 1021 | |
| | 1022 | //start copying stuff |
| | 1023 | COPYELEMENT_SAVE(type); |
| | 1024 | COPYELEMENT_SAVE(state); |
| | 1025 | COPYELEMENT_SAVE(on_off_state); |
| | 1026 | COPYELEMENT_SAVE(sequence); //texture animation sequence |
| | 1027 | COPYELEMENT_SAVE(colour_red); //colour for fade up state |
| | 1028 | COPYELEMENT_SAVE(colour_green); |
| | 1029 | COPYELEMENT_SAVE(colour_blue); |
| | 1030 | COPYELEMENT_SAVE(colour_diff_red); //difference from up colour to down colour |
| | 1031 | COPYELEMENT_SAVE(colour_diff_green); |
| | 1032 | COPYELEMENT_SAVE(colour_diff_blue); |
| | 1033 | COPYELEMENT_SAVE(timer); |
| | 1034 | COPYELEMENT_SAVE(on_off_timer); |
| | 1035 | COPYELEMENT_SAVE(flicker_timer); |
| | 1036 | |
| | 1037 | block->DamageBlock = sbPtr->DamageBlock; |
| | 1038 | } |