From d2d960672ce665fd073bd3fa9ce470802ab4dfd9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Dec 2016 11:39:46 +0100 Subject: [PATCH 1/9] Revert "Fixed: A_CustomMissile's CMF_AIMDIRECTION's pitch calculations were also backwards." This reverts commit b17bd65279d39ceb0c61453e38fe02f4768f161e. This would break too many existing mods. --- src/p_actionfunctions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 { From aa758159c9e982882d899e8f7a70733f7cb3798e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Dec 2016 12:10:05 +0100 Subject: [PATCH 2/9] - renamed Actor.NoiseAlert to Actor.SoundAlert to deconflict with the same-named action special. --- src/p_enemy.cpp | 2 +- wadsrc/static/zscript/actor.txt | 2 +- wadsrc/static/zscript/strife/acolyte.txt | 2 +- wadsrc/static/zscript/strife/klaxon.txt | 2 +- wadsrc/static/zscript/strife/strifefunctions.txt | 2 +- wadsrc/static/zscript/strife/strifeitems.txt | 6 +++--- wadsrc/static/zscript/strife/strifestuff.txt | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) 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/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/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/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); From 2b24fee53d1d4475c27b57d6d1cc213528015ac0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Dec 2016 12:37:12 +0100 Subject: [PATCH 3/9] - fixed: A_BlastRadius accessed the player's ReadyWeapon before ensuring it got called from a player. --- wadsrc/static/zscript/hexen/blastradius.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wadsrc/static/zscript/hexen/blastradius.txt b/wadsrc/static/zscript/hexen/blastradius.txt index a9c631318a..becc9a9bc9 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) - { + Weapon weapon = player.ReadyWeapon; if (weapon != null && !weapon.DepleteAmmo(weapon.bAltFire)) { return; From 898e2900b328cb5989d8a482b84ea319c7ab4503 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Dec 2016 12:42:55 +0100 Subject: [PATCH 4/9] - more fixes in blastradius.txt. --- wadsrc/static/zscript/hexen/blastradius.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wadsrc/static/zscript/hexen/blastradius.txt b/wadsrc/static/zscript/hexen/blastradius.txt index becc9a9bc9..7374a4523d 100644 --- a/wadsrc/static/zscript/hexen/blastradius.txt +++ b/wadsrc/static/zscript/hexen/blastradius.txt @@ -103,7 +103,7 @@ 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") { - 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)) @@ -116,7 +116,7 @@ extend class Actor if (!(blastflags & BF_DONTWARN)) { - NoiseAlert (self); + SoundAlert (self); } ThinkerIterator it = ThinkerIterator.Create("Actor"); Actor mo; From 40355f6298761e82d924e9b7df0e518981bac3d7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Dec 2016 13:07:25 +0100 Subject: [PATCH 5/9] - allow A_M_Refire to be called without state label because this seems to have been used in existing DECORATE mods. This way of calling it will revert to the old behavior of jumping one state forward instead of to a state label. --- src/scripting/codegeneration/codegen.cpp | 11 +++++++++++ wadsrc/static/zscript/doom/scriptedmarine.txt | 8 +++++--- 2 files changed, 16 insertions(+), 3 deletions(-) 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); } } From 0f9758bb7543fa87ec449133e1d1ba9da969e39c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Dec 2016 13:17:50 +0100 Subject: [PATCH 6/9] - fixed some conversion errors in A_StalkerLookInit. --- wadsrc/static/zscript/strife/stalker.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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); } From b43609c701035a20abafe11594618f1509fff478 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Dec 2016 14:45:20 +0100 Subject: [PATCH 7/9] - fixed: The weapon sprite fudge offset should not be added when just interpolating the position and calculating the delta. --- src/r_things.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 1bd2e8a025..9e9b161cdf 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1624,7 +1624,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 From e61ae9a1f95a0c62a98d9ce29ca5a2cce59f9795 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Dec 2016 21:32:19 +0100 Subject: [PATCH 8/9] - pass a proper self pointer to BuiltinCallActionSpecial instead of making bogus assumptions about a function's parameters. --- src/scripting/codegeneration/codegen.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index 06cdfbd06a..1ec74052ab 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -7083,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) ? new FxSelf(ScriptPosition) : (FxExpression*)new FxConstant(ScriptPosition); FxExpression *x = new FxActionSpecialCall(self, special, ArgList, ScriptPosition); delete this; return x->Resolve(ctx); @@ -7655,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]; From 77d9978b278bda04dc5ead665423f3a3f44f48db Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Dec 2016 21:39:35 +0100 Subject: [PATCH 9/9] - fixed: Non-Actors cannot act as activators for action specials and must pass null when acticating one. --- src/scripting/codegeneration/codegen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index 1ec74052ab..90fbcfe683 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -7083,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) : (FxExpression*)new FxConstant(ScriptPosition); + 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);