@@ -362,13 +362,34 @@ if SERVER then
362362 doorProp :SetCollisionGroup (COLLISION_GROUP_NONE )
363363 doorProp :SetMoveType (MOVETYPE_VPHYSICS )
364364 doorProp :SetSolid (SOLID_BBOX )
365- doorProp :SetPos (self :GetPos () + Vector ( 0 , 0 , 2 ) )
365+ doorProp :SetPos (self :GetPos ())
366366 doorProp :SetAngles (self :GetAngles ())
367367 doorProp :SetModel (self :GetModel ())
368368 doorProp :SetSkin (self :GetSkin ())
369369
370+ local bodygroups = self :GetBodyGroups ()
371+ for i = 1 , # bodygroups do
372+ local id = bodygroups [i ].id
373+ doorProp :SetBodygroup (id , self :GetBodygroup (id ))
374+ end
375+
376+ -- if there are entities parented to the door, transfer them over
377+ local children = self :GetChildren ()
378+ for i = 1 , # children do
379+ local child = children [i ]
380+ local pos , ang = child :GetLocalPos (), child :GetLocalAngles ()
381+
382+ child :SetParent (doorProp )
383+ child :SetLocalPos (pos )
384+ child :SetLocalAngles (ang )
385+ end
386+
370387 door .HandleDestruction (self )
371388
389+ -- hide away the real door while it is being opened and destroyed
390+ self :SetNoDraw (true )
391+ self :SetSolid (SOLID_NONE )
392+
372393 -- disable the door move sound for the destruction
373394 self :SetKeyValue (" soundmoveoverride" , " " )
374395
@@ -379,6 +400,38 @@ if SERVER then
379400 -- this function is called multiple times for the same door in the same tick
380401 self .isDestroyed = true
381402
403+ if IsValid (ply ) and ply :IsPlayer () then
404+ DamageLog (
405+ string.format (
406+ " TTT2Doors: The door with the index %s has been destroyed by %s." ,
407+ self :EntIndex (),
408+ ply :Nick ()
409+ )
410+ )
411+ else
412+ DamageLog (
413+ string.format (
414+ " TTT2Doors: The door with the index %s has been destroyed." ,
415+ self :EntIndex ()
416+ )
417+ )
418+ end
419+
420+ doorProp :Spawn ()
421+ doorProp :SetHealth (cvDoorPropHealth :GetInt ())
422+
423+ doorProp .isDoorProp = true
424+
425+ local physObj = doorProp :GetPhysicsObject ()
426+
427+ if IsValid (physObj ) then
428+ physObj :ApplyForceCenter (pushForce or vector_origin )
429+ end
430+
431+ ---
432+ -- @realm server
433+ hook .Run (" TTT2DoorDestroyed" , doorProp , ply )
434+
382435 -- if the door is grouped as a pair, call the other one as well
383436 if not surpressPair and IsValid (self .otherPairDoor ) then
384437 self .otherPairDoor :SafeDestroyDoor (ply , pushForce , true )
@@ -392,37 +445,6 @@ if SERVER then
392445 -- we have to kill the entity here instead of removing it because this way we
393446 -- have no problems with area portals (invisible rooms after door is destroyed)
394447 self :Fire (" Kill" , " " , 0 )
395-
396- if IsValid (ply ) and ply :IsPlayer () then
397- DamageLog (
398- " TTT2Doors: The door with the index "
399- .. self :EntIndex ()
400- .. " has been destroyed by "
401- .. ply :Nick ()
402- .. " ."
403- )
404- else
405- DamageLog (
406- " TTT2Doors: The door with the index "
407- .. self :EntIndex ()
408- .. " has been destroyed."
409- )
410- end
411-
412- doorProp :Spawn ()
413- doorProp :SetHealth (cvDoorPropHealth :GetInt ())
414-
415- doorProp .isDoorProp = true
416-
417- local physObj = doorProp :GetPhysicsObject ()
418-
419- if IsValid (physObj ) then
420- physObj :ApplyForceCenter (pushForce or Vector (0 , 0 , 0 ))
421- end
422-
423- ---
424- -- @realm server
425- hook .Run (" TTT2DoorDestroyed" , doorProp , ply )
426448 end )
427449
428450 return doorProp
0 commit comments