scriptname JTCigCartonDestructionScript
ref tempref
float xpos
float ypos
float zpos
short ignorehit
short count
begin OnAdd Player
set ignorehit to 0
end
;Cigarette cartons and packs lack the model data necessary to allow for a stage change based
; on destruction data. Unfortunately, this means we have to ignore damage completely
; and just apply a hit counter.
;begin OnDestructionStageChange
begin OnHit
if ( ignorehit < 1 )
;In case a higher hit count in the condition is desired
set ignorehit to ignorehit + 1
return
endif
set xpos to GetPos x
set ypos to GetPos y
set zpos to GetPos z + 16
set count to ( GetRandomPercent / 20 ) + 1
if FOSE.isPresent
Label 1
set tempref to PlaceAtMe CigarettePack 1 0 0
tempref.SetPos X xpos
tempref.SetPos Y ypos
tempref.SetPos Z zpos
if ( count > 0 )
set count to count - 1
Goto 1
endif
else
PlaceAtMe CigarettePack count 0 0
endif
set count to ( GetRandomPercent / 3 ) + 15
if FOSE.isPresent
Label 2
set tempref to PlaceAtMe Cigarette01 1 0 0
tempref.SetPos X xpos
tempref.SetPos Y ypos
tempref.SetPos Z zpos
if ( count > 0 )
set count to count - 1
Goto 2
endif
else
PlaceAtMe Cigarette01 count 0 0
endif
tempref.PlaceAtMe JTChemContainerDestructExplosion 1 0 0
Disable
MarkForDelete
end