diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index 16025c0d0f..06cdfbd06a 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -3371,6 +3371,17 @@ FxExpression *FxCompareEq::Resolve(FCompileContext& ctx) { Promote(ctx); } + // allows comparing state labels with null pointers. + else if (left->ValueType == TypeStateLabel && right->ValueType == TypeNullPtr) + { + right = new FxTypeCast(right, TypeStateLabel, false); + SAFE_RESOLVE(right, ctx); + } + else if (right->ValueType == TypeStateLabel && left->ValueType == TypeNullPtr) + { + left = new FxTypeCast(left, TypeStateLabel, false); + SAFE_RESOLVE(left, ctx); + } else if (left->ValueType->GetRegType() == REGT_POINTER && right->ValueType->GetRegType() == REGT_POINTER) { if (left->ValueType != right->ValueType && right->ValueType != TypeNullPtr && left->ValueType != TypeNullPtr && diff --git a/wadsrc/static/zscript/doom/scriptedmarine.txt b/wadsrc/static/zscript/doom/scriptedmarine.txt index 9ecfbc4605..7428b7be35 100644 --- a/wadsrc/static/zscript/doom/scriptedmarine.txt +++ b/wadsrc/static/zscript/doom/scriptedmarine.txt @@ -282,7 +282,7 @@ class ScriptedMarine : Actor // //============================================================================ - void A_M_Refire (bool ignoremissile, statelabel jumpto) + void A_M_Refire (bool ignoremissile, statelabel jumpto = null) { if (target == null || target.health <= 0) { @@ -293,13 +293,15 @@ class ScriptedMarine : Actor return; } } - SetStateLabel (jumpto); + if (jumpto != null) SetStateLabel (jumpto); + else SetState(CurState + 1); return; } if (((ignoremissile || MissileState == null) && !CheckMeleeRange ()) || !CheckSight (target) || random[SMarineRefire]() < 4) // Small chance of stopping even when target not dead { - SetStateLabel (jumpto); + if (jumpto != null) SetStateLabel (jumpto); + else SetState(CurState + 1); } }