Improved critter.psc fix

This commit is contained in:
Eddoursul 2024-01-21 15:15:07 +01:00
parent 5401437976
commit d0512f2177
2 changed files with 12 additions and 4 deletions

Binary file not shown.

View File

@ -230,14 +230,14 @@ Event OnUpdateGameTime()
DisableAndDelete(false) DisableAndDelete(false)
endEvent endEvent
Event OnLoad()
bAttached = true
endEvent
Event OnUnload() Event OnUnload()
bAttached = false bAttached = false
endEvent endEvent
Event OnAttachedToCell()
bAttached = true
endEvent
;/ Match OnCellDetach() for all critters, to clean up old critters [USKP 2.0.1] ;/ Match OnCellDetach() for all critters, to clean up old critters [USKP 2.0.1]
/; /;
EVENT OnCellAttach() EVENT OnCellAttach()
@ -260,6 +260,10 @@ endEVENT
/; /;
EVENT OnCellDetach() EVENT OnCellDetach()
bAttached = false bAttached = false
Cell parentCell = GetParentCell()
if parentCell && parentCell.IsAttached()
bAttached = true
endif
;~ Trace(self + "OnCellDetach() Killing self", 2) ;~ Trace(self + "OnCellDetach() Killing self", 2)
;! DisableAndDelete() ;! DisableAndDelete()
; Parentcell usually removed by the time this event triggers, ; Parentcell usually removed by the time this event triggers,
@ -1129,6 +1133,9 @@ endFunction
/; /;
Bool Function CheckCellAttached(ObjectReference AnyItemRef) Bool Function CheckCellAttached(ObjectReference AnyItemRef)
return bAttached && AnyItemRef
;/
if ! bAttached || ! AnyItemRef if ! bAttached || ! AnyItemRef
return false return false
endif endif
@ -1141,6 +1148,7 @@ Bool Function CheckCellAttached(ObjectReference AnyItemRef)
EndIf EndIf
Return parentCell.IsAttached() Return parentCell.IsAttached()
/;
EndFunction EndFunction