diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index f1b4fee802..6ddfd52819 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -1524,7 +1524,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CustomMissile) Pitch += missile->Vel.Pitch(); } missilespeed = fabs(Pitch.Cos() * missile->Speed); - missile->Vel.Z = -Pitch.Sin() * missile->Speed; + missile->Vel.Z = Pitch.Sin() * missile->Speed; } else { diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 4b99a5f527..326c0dca4c 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -262,7 +262,7 @@ void P_NoiseAlert (AActor *target, AActor *emitter, bool splash, double maxdist) } } -DEFINE_ACTION_FUNCTION(AActor, NoiseAlert) +DEFINE_ACTION_FUNCTION(AActor, SoundAlert) { PARAM_SELF_PROLOGUE(AActor); PARAM_OBJECT(target, AActor); diff --git a/src/r_things.cpp b/src/r_things.cpp index 0a9d74c204..6e1261c1bb 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1771,7 +1771,7 @@ void R_DrawPlayerSprites () else { wx = weapon->oldx + (weapon->x - weapon->oldx) * r_TicFracF; - wy = weapon->oldy + (weapon->y - weapon->oldy) * r_TicFracF + WEAPON_FUDGE_Y; + wy = weapon->oldy + (weapon->y - weapon->oldy) * r_TicFracF; } } else diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index 16025c0d0f..90fbcfe683 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 && @@ -7072,7 +7083,7 @@ FxExpression *FxFunctionCall::Resolve(FCompileContext& ctx) delete this; return nullptr; } - FxExpression *self = (ctx.Function && ctx.Function->Variants[0].Flags & VARF_Method) ? new FxSelf(ScriptPosition) : nullptr; + FxExpression *self = (ctx.Function && (ctx.Function->Variants[0].Flags & VARF_Method) && ctx.Class->IsKindOf(RUNTIME_CLASS(PClassActor))) ? new FxSelf(ScriptPosition) : (FxExpression*)new FxConstant(ScriptPosition); FxExpression *x = new FxActionSpecialCall(self, special, ArgList, ScriptPosition); delete this; return x->Resolve(ctx); @@ -7644,9 +7655,9 @@ ExpEmit FxActionSpecialCall::Emit(VMFunctionBuilder *build) unsigned i = 0; build->Emit(OP_PARAMI, abs(Special)); // pass special number - // fixme: This really should use the Self pointer that got passed to this class instead of just using the first argument from the function. - // Once static functions are possible, or specials can be called through a member access operator this won't work anymore. - build->Emit(OP_PARAM, 0, REGT_POINTER, 0); // pass self + + ExpEmit selfemit(Self->Emit(build)); + build->Emit(OP_PARAM, 0, selfemit.Konst ? REGT_POINTER | REGT_KONST : REGT_POINTER, selfemit.RegNum); // pass special number for (; i < ArgList.Size(); ++i) { FxExpression *argex = ArgList[i]; diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 1e5c394160..d804a434c6 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -300,7 +300,7 @@ class Actor : Thinker native native bool isTeammate(Actor other); native int PlayerNumber(); native void SetFriendPlayer(PlayerInfo player); - native void NoiseAlert(Actor target, bool splash = false, double maxdist = 0); + native void SoundAlert(Actor target, bool splash = false, double maxdist = 0); native void DaggerAlert(Actor target); native void ClearBounce(); native TerrainDef GetFloorTerrain(); 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); } } diff --git a/wadsrc/static/zscript/hexen/blastradius.txt b/wadsrc/static/zscript/hexen/blastradius.txt index a9c631318a..7374a4523d 100644 --- a/wadsrc/static/zscript/hexen/blastradius.txt +++ b/wadsrc/static/zscript/hexen/blastradius.txt @@ -103,10 +103,9 @@ extend class Actor action void A_Blast(int blastflags = 0, double strength = 255, double radius = 255, double speed = 20, class blasteffect = "BlastEffect", sound blastsound = "BlastRadius") { - Weapon weapon = player.ReadyWeapon; - if (player && (blastflags & BF_USEAMMO) && invoker == weapon && stateinfo != null && stateinfo.mStateType == STATE_Psprite) - + if (player && (blastflags & BF_USEAMMO) && invoker == player.ReadyWeapon && stateinfo != null && stateinfo.mStateType == STATE_Psprite) { + Weapon weapon = player.ReadyWeapon; if (weapon != null && !weapon.DepleteAmmo(weapon.bAltFire)) { return; @@ -117,7 +116,7 @@ extend class Actor if (!(blastflags & BF_DONTWARN)) { - NoiseAlert (self); + SoundAlert (self); } ThinkerIterator it = ThinkerIterator.Create("Actor"); Actor mo; diff --git a/wadsrc/static/zscript/strife/acolyte.txt b/wadsrc/static/zscript/strife/acolyte.txt index e5a019ea8c..c14cb5bf7e 100644 --- a/wadsrc/static/zscript/strife/acolyte.txt +++ b/wadsrc/static/zscript/strife/acolyte.txt @@ -302,7 +302,7 @@ class AcolyteToBe : Acolyte Door_Close(999, 64); if (target != null && target.player != null) { - NoiseAlert (target); + SoundAlert (target); } } } diff --git a/wadsrc/static/zscript/strife/klaxon.txt b/wadsrc/static/zscript/strife/klaxon.txt index 51c4d7df2d..3384ee0b5e 100644 --- a/wadsrc/static/zscript/strife/klaxon.txt +++ b/wadsrc/static/zscript/strife/klaxon.txt @@ -114,7 +114,7 @@ extend class Actor if (reactiontime == 2) { // [RH] Unalert monsters near the alarm and not just those in the same sector as it. - NoiseAlert (NULL, false); + SoundAlert (NULL, false); } else if (reactiontime > 50) { diff --git a/wadsrc/static/zscript/strife/stalker.txt b/wadsrc/static/zscript/strife/stalker.txt index cede9cae12..a9cc4dbaf0 100644 --- a/wadsrc/static/zscript/strife/stalker.txt +++ b/wadsrc/static/zscript/strife/stalker.txt @@ -67,7 +67,7 @@ class Stalker : Actor STLK QRST 4; STLK U 4 A_NoBlocking; STLK VW 4; - STLK "XYZ[" 4 Bright; + STLK XYZ[ 4 Bright; Stop; } @@ -86,7 +86,7 @@ class Stalker : Actor void A_StalkerLookInit () { State st; - if (!bNoGravity) + if (bNoGravity) { st = FindState("LookCeiling"); } @@ -94,7 +94,7 @@ class Stalker : Actor { st = FindState("LookFloor"); } - if (st.NextState != st) + if (st != CurState.NextState) { SetState (st); } diff --git a/wadsrc/static/zscript/strife/strifefunctions.txt b/wadsrc/static/zscript/strife/strifefunctions.txt index 7cfdf39746..3a0dec22f4 100644 --- a/wadsrc/static/zscript/strife/strifefunctions.txt +++ b/wadsrc/static/zscript/strife/strifefunctions.txt @@ -173,7 +173,7 @@ extend class Actor if (target != null && emitter != null) { - emitter.NoiseAlert(target, false, maxdist); + emitter.SoundAlert(target, false, maxdist); } } diff --git a/wadsrc/static/zscript/strife/strifeitems.txt b/wadsrc/static/zscript/strife/strifeitems.txt index 6d80377714..4368564cd1 100644 --- a/wadsrc/static/zscript/strife/strifeitems.txt +++ b/wadsrc/static/zscript/strife/strifeitems.txt @@ -610,7 +610,7 @@ class RaiseAlarm : DummyStrifeItem override bool TryPickup (in out Actor toucher) { - toucher.NoiseAlert (toucher); + toucher.SoundAlert (toucher); ThinkerIterator it = ThinkerIterator.Create("AlienSpectre3"); Actor spectre = Actor(it.Next()); @@ -629,7 +629,7 @@ class RaiseAlarm : DummyStrifeItem { if (dropper.target != null) { - dropper.target.NoiseAlert(dropper.target); + dropper.target.SoundAlert(dropper.target); if (dropper.target.CheckLocalView(consoleplayer)) { A_Log("You Fool! You've set off the alarm."); @@ -674,7 +674,7 @@ class CloseDoor222 : DummyStrifeItem { A_Log("You're dead! You set off the alarm."); } - dropper.target.NoiseAlert(dropper.target); + dropper.target.SoundAlert(dropper.target); } Destroy (); return true; diff --git a/wadsrc/static/zscript/strife/strifestuff.txt b/wadsrc/static/zscript/strife/strifestuff.txt index 37918aa964..f08eaa6a55 100644 --- a/wadsrc/static/zscript/strife/strifestuff.txt +++ b/wadsrc/static/zscript/strife/strifestuff.txt @@ -1857,7 +1857,7 @@ class PowerCoupling : Actor // [RH] In case the player broke it with the dagger, alert the guards now. if (LastHeard != source) { - NoiseAlert (source); + SoundAlert (source); } Door_Close(225, 16); Floor_LowerToHighestEE(44, 8);